Commit graph

1809 commits

Author SHA1 Message Date
Scott Taylor
6dab2911f1 cli_util: print warning if working copy contains '.jjconflict' files
I put this outside of the check for whether the tree changed because I
think it could be easy to miss the warning on the first snapshot, so
it's helpful if it prints the warning every time.
2025-12-21 21:37:14 -06:00
Scott Taylor
3fe784d50c git_backend: use first tree as base tree for conflicts
Currently, checking out a commit with conflicts in a colocated workspace
causes many editors to show all existing files as added since they
aren't present in the Git HEAD commit. Using the tree of the first side
of the commit as a base tree and then adding the '.jjconflict-*' trees
on top of it would cause any files identical to the first tree to show
as unchanged, matching Git's conflict behavior.

One potential downside to this change is that it becomes harder for a
user to notice if they incorrectly check out a conflicted commit using
`git switch`, since previously all of their files would've disappeared
so it would be more difficult to ignore. However, I think this could be
solved a different way, such as by adding a warning when snapshotting if
'.jjconflict' files are detected. Keeping the files from the first
tree also has the benefit that '.gitignore' files will still be present,
meaning that when a user does `jj abandon` to recover, it won't delete
their ignored files.

Using 'JJ-CONFLICT-README' as the name for the readme file instead of
'README' makes it more clear that this file is related to the
'.jjconflict-*' trees, since now the repo's actual README file might be
present as well in the tree.
2025-12-21 21:37:14 -06:00
David Higgs
223470295e cli: remove newline addition between template and content
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Commands `jj log`, `jj evolog`, and `jj op log` automatically added a
terminating newline when the expanded template did not include one in graph
mode. No-graph mode did not do this, so the expanded template could combine with
any following content (diff, op changes, etc) in confusing or problematic ways.

Instead of trying to compensate in all cases, remove the auto-fixups. Users
should confirm their custom templates still expand correctly for their needs.
2025-12-22 02:47:58 +00:00
Scott Taylor
d8e51087a2 cli_util: use change offset in conflict hint when necessary
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Resolves #8330.
2025-12-21 14:44:31 +00:00
Yuya Nishihara
3fad6ead29 tests: set up local TMPDIR which should be cleaned up by test runner
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Otherwise a few editor-*.jjdescription files would be left in /tmp.
2025-12-21 01:54:31 +00:00
Scott Taylor
2ce2a445b0 conflicts: show "noeol" state separately for each side of a diff
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Now that we can put the "from" and "to" sides on separate lines, we can
use the normal "(no terminating newline)" comment on each side
separately. This should also be more clear, since previously the
"(no terminating newline)" comment could possibly be confused for
"(removes terminating newline)".

Before:

```
<<<<<<< conflict 1 of 1
+++++++ rtsqusxu 2768b0b9 "commit A" (no terminating newline)
grapefruit
%%%%%%% diff from: vpxusssl 38d49363 "merge base"
\\\\\\\        to: ysrnknol 7a20f389 "commit B" (adds terminating newline)
-grape
+grape
>>>>>>> conflict 1 of 1 ends
```

After:

```
<<<<<<< conflict 1 of 1
+++++++ rtsqusxu 2768b0b9 "commit A" (no terminating newline)
grapefruit
%%%%%%% diff from: vpxusssl 38d49363 "merge base" (no terminating newline)
\\\\\\\        to: ysrnknol 7a20f389 "commit B"
-grape
+grape
>>>>>>> conflict 1 of 1 ends
```
2025-12-20 17:43:41 +00:00
Scott Taylor
33ad38bfed templates: add "divergent" label to log for divergent changes
It would be good to include the word "divergent" in the log when a
change is divergent, since users are often unsure what's happening when
they see a divergent change, and giving them a term to search for would
be helpful. However, I don't think it looks good to put this label next
to the change ID itself if both are the same color, since it ends up
being hard to distinguish from the change offset at a glance. Also,
putting the label next to the change ID also messes up the alignment of
fields in the log. Therefore, I think it looks better to put the
"divergent" label at the end of the line.

Since divergence and hidden commits are similar, it makes sense for both
labels to be in the same place, so I also moved the hidden label to the
end for consistency.

One downside is that the labels are less obviously connected with the
change ID itself due to them being farther apart. I think this could be
fine, since they are still visually connected by being the same color.
2025-12-20 16:55:51 +00:00
Scott Taylor
144ba766b1 rewrite: add conflict labels for rebased commits
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
An example of rebasing `ysrnknol` onto `rtsqusxu`:

```
<<<<<<< conflict 1 of 1
%%%%%%% diff from: vpxusssl 38d49363 "base" (parents of rebased commit)
\\\\\\\        to: rtsqusxu 2768b0b9 "left" (rebase destination)
-base
+left
+++++++ ysrnknol 7a20f389 "right" (rebased commit)
right
>>>>>>> conflict 1 of 1 ends
```
2025-12-20 04:03:57 +00:00
Scott Taylor
04a91217f5 rewrite: add conflict labels when merging commit trees
An example with parents `rtsqusxu` and `ysrnknol`:

```
<<<<<<< conflict 1 of 1
%%%%%%% diff from: vpxusssl 38d49363 "description of base"
\\\\\\\        to: rtsqusxu 2768b0b9 "description of left"
-base
+left
+++++++ ysrnknol 7a20f389 "description of right"
right
>>>>>>> conflict 1 of 1 ends
```
2025-12-20 04:03:57 +00:00
Scott Taylor
ba73442b2a conflicts: update conflict marker format
Conflict labels will generally start with lowercase change IDs, so
making all of the text lowercase makes it more consistent. I also
removed the "contents of" text, since conflict labels will already be
long enough, and this text doesn't add anything. Similarly, I removed
the "(conflict 1 of 1)" note from the Git conflict markers since Git
doesn't include this information, and including it would result in extra
long lines once we add conflict labels.
2025-12-20 04:03:57 +00:00
Steve Klabnik
5dd63d691e docs: improve interdiff command documentation
Rewrite the `interdiff` help text to be clearer about what the command does.

Closes #7033
2025-12-20 00:03:02 +00:00
Steve Klabnik
e00d154c92 cli: document -r as alias for positional revision arguments
Several commands accept both positional arguments and a `-r` flag for
specifying revisions. The `-r` flag exists for consistency with other
commands, but was previously hidden from help output.

Instead of unhiding `-r` (which would clutter the Options section),
document the aliasing by adding `[aliases: -r]` to the positional
argument's help text. This makes the relationship discoverable while
keeping the help output clean.

Commands updated: abandon, describe, duplicate, edit, metaedit, new, show

Fixes #8104
2025-12-19 22:29:01 +00:00
Steve Klabnik
a59c2d2efe docs: elaborate on jj git push behavior
Add more detail about both the range of commits that will be pushed, as well as
it being a --force-with-lease.

Fixes #3672
2025-12-19 22:01:42 +00:00
Steve Klabnik
ba0e9a4946 docs: clarify behavior of selected vs remaining changes
The help text for `jj split` was confusing about what happens to
"selected" vs "remaining" changes, especially with the `-o/-A/-B` flags.

This change:
- Adds ASCII diagrams showing the commit graph transformations for
  default split, --parallel, and -o/-A/-B modes
- Clarifies that by default, selected changes stay in the original
  commit while remaining changes go to a new child
- Explains that with -o/-A/-B, selected changes are extracted to a
  new commit at the destination while remaining changes stay in place
- Improves the --message flag description to clarify it applies to
  the first commit (containing selected changes)
- Adds explanatory text to the -o, -A, and -B flag descriptions
2025-12-19 20:22:57 +00:00
Yuya Nishihara
5e22ae6bd9 cli: new: parse -r/-o option properly, merge with positional arguments
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Because the order of parents matters, we have to merge positional and -o
arguments in order of appearance.
2025-12-19 09:39:53 +00:00
Yuya Nishihara
be34efe22b cli: show: parse -r option properly
The default can no longer be set by clap because there may be "-r" argument.
2025-12-19 09:39:53 +00:00
Yuya Nishihara
e461f2401a cli: edit: parse -r option properly
This one is easy since there should be exactly one REVSET argument.
2025-12-19 09:39:53 +00:00
Martin von Zweigbergk
980ac17d36 bisect: add missing closing backtick, make tests pass on Windows
This removes the dependencies on `true`, `false`, and `test`
executables, which are often not available on Windows.
2025-12-19 04:18:46 +00:00
Martin von Zweigbergk
a9fc4e8905 cli: add a very basic jj file search (like git grep)
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
This is lacking a lot but should be good as a starting point.
2025-12-18 06:31:37 +00:00
Yuya Nishihara
ad5ae40b04 cli: gerrit: remove excessive newlines and "warning:" prefix, respect --quiet
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
It seemed weird that the test snapshots had random blank lines.
2025-12-18 00:13:25 +00:00
Yuya Nishihara
e0a725736d cli: add debug command that dumps stats of stacked table
This is pretty low level, but we can at least know which extras table files are
active. The --key-size parameter doesn't matter so long as it is smaller than
the actual key size, but we might add sanity check later.
2025-12-17 10:38:11 +00:00
Scott Taylor
dc325cbdb2 complete: include offset in completions for divergent changes
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
2025-12-17 02:12:55 +00:00
Jonathan Hoelzel
69477cd465 gerrit: handle mixed explicit & implicit Change-Ids in upload
The 'gerrit upload' cli command is meant to support uploading commits
that have an explicit "Change-Id: ..." footer, and those that don't. In
the latter case, a temporary copy of the commit being uploaded will be
created, with the Change-Id set based on the jj change id.

Prior to this commit, there was a bug in this implementation when a
chain of commits contained some with Change-Id footers and some without.

Say we have commits a->b->c, where b has no Change-Id footer but c does
(this case is what's now tested in the test_gerrit_upload_local case).

The old logic would:
- create a new version of b (let's call it b*), with a CommitId footer,
  and populate the 'old_to_new' map with 'b -> b*'
- not create a new version of c, and populate the 'old_to_new' map with
  'c -> c'
- push the 'new' version of c, which is c itself. However, c has b as a
  parent, not b*, so this fails to send to gerrit because b has no
  Commit-Id footer!

After this commit, we create a new temporary commit if either the
description is changed (as before), or if any parents are different from
the original commit's parents. This does not change the behavior for
either the all-explicit or all-implicit ChangeId cases, but fixes the
behavior in this mixed case.
2025-12-17 00:30:17 +00:00
Jonathan Hoelzel
ea5f23d3ce gerrit: add test for all-explicit change-ids for upload command
The 'gerrit upload' command has logic to handle commits with the
"Change-Id" explicitly set within the commit message, and commits
without the Change-Id explicitly set. This commit adds a test for the
behavior when all commits have the Change-Id explicitly set.

Also fix typo in existing test comment
2025-12-17 00:30:17 +00:00
Scott Taylor
1fb5a9656b command_error: use offset in hint for divergent changes
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
It's usually going to be easier for a user to run the same command again
but with a change offset appended, so I think these are more helpful
than commit IDs.
2025-12-16 02:02:31 +00:00
Scott Taylor
edc578c56b docs: update examples of divergence to include change offsets 2025-12-16 02:02:31 +00:00
Scott Taylor
0dffb6f108 templates: show change offsets for divergent and hidden commits
For now, I just replaced `??` with the change offset for divergent
commits. We can add an explicit "divergent" label later.
2025-12-16 02:02:31 +00:00
Scott Taylor
7fd50edc65 index: add ResolvedChangeTargets to return all commits with change ID
I'm going to add a way to select a specific commit from the set of
commits with a given change ID. We could sort these by committer
timestamp or something else, but index position is convenient because it
doesn't require reading the commits. The exact order isn't too
important, but giving newer commits lower offset numbers is nice because
newer commits are used more frequently.
2025-12-16 02:02:31 +00:00
Yuya Nishihara
b9317da0f8 cli: enable glob string matching globally
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
The goal of this change is to unify defaults of string patterns in revsets and
command arguments. Glob is a good default because it's largely the same as exact
matching, and we can easily express substring patterns with globs.

The hint for "jj git fetch -b<glob>" is deleted since exact:<glob> is now
required in order to trigger the error.

This patch also updates help of clone/fetch --branch patterns. Glob and operator
support in refspecs is limited.
2025-12-15 04:27:32 +00:00
Yuya Nishihara
8765e92eca cli: update one missed hint about "bookmark untrack glob:{name}@*"
This should have been made by f4dc07eb3c.
2025-12-15 04:27:32 +00:00
Yuya Nishihara
97375fa041 revset: enable glob string matching by default
Follows up c93682f2 "revset: parameterize default string pattern kind, add
config knob".
2025-12-15 04:27:32 +00:00
Steve Klabnik
c969da4b55 docs: clarify what happens to unselected changes in jj commit
When using `--interactive` or path arguments, it wasn't clear from the
help text what happens to the changes that aren't selected. This adds
an explanation to the main command documentation and updates the flag
and argument descriptions to use "current commit" instead.

Fixes #6666
2025-12-15 04:00:05 +00:00
Anton Älgmyr
840ae9ebf4 templates: Expose conflicted files in the template language
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
2025-12-14 17:11:16 +00:00
Yuya Nishihara
051a1e5343 cli: complete: omit @remote part from bookmarks to track/untrack 2025-12-13 01:32:49 +00:00
Yuya Nishihara
f4dc07eb3c cli: update hints to use new "track/untrack --remote" syntax 2025-12-13 01:32:49 +00:00
Yuya Nishihara
e921791574 cli: bookmark: add --remote argument to track/untrack, deprecate name@remote
These two are the last commands which don't support logical operators in string
patterns. The old <kind>:<name>@<remote> syntax had various problems including:

 1. substring patterns look weird (e.g. `substring:x@y` means `*x*@*y*`)
 2. cannot express "all but <name> for all remotes" (e.g. `(~gh-pages)@(*)`)

In addition to that, the revset parser doesn't support `<name>@<remote>`
prefixed by `<kind>:`.

This patch introduces separate --remote argument to address these problems. The
default is `glob:*` (or `~git`), so we wouldn't have to specify the remote in
many cases. One caveat is that `jj bookmark track` is not idempotent if there
are multiple remotes:

    # there are two remotes: origin and upstream,
    # and only foo@origin exists
    $ jj bookmark track foo
    # tracks foo@origin and creates new local bookmark foo
    $ jj bookmark track foo
    # tracks absent foo@upstream as we now have a local bookmark

This is wild. We might want to add a flag or a new command to track absent
remote bookmarks to push.

"Unmatched names" warnings are now emitted for bookmark and remote names
separately. To keep the implementation simple, the search space isn't restricted
by the other parameter. For example, "jj bookmark track foo --remote=bar" won't
show a warning if "foo" exists locally or in any remote.

Closes #4260
2025-12-13 01:32:49 +00:00
Yuya Nishihara
2f9041b842 diff: reduce intensity of context line numbers in color-words diffs
This will help notice small hunks in inlined diff lines. Not all terminals would
support "dim" attribute, but I think that's okay since the diff output should be
readable with/without this change.

Closes #5140
2025-12-13 00:56:55 +00:00
Yuya Nishihara
2ff13a9aae formatter: add support for "dim" attribute
Handling of dim and bold is a bit complicated because these two attributes
cannot be unset individually. I think NormalIntensity will work for resetting
both bold and dim, but I don't have expertise on terminal implementations. So
this patch applies the same workaround as bold to dim.
2025-12-13 00:56:55 +00:00
David Higgs
a1fd576e85 tests: exercise retagging the same commit 2025-12-12 02:55:55 +00:00
David Higgs
5128c2e0df tests: exercise unsigning triggering rebasing 2025-12-12 02:55:55 +00:00
David Higgs
d67fe32470 tests: exercise signing and unsigning nothing 2025-12-12 02:55:55 +00:00
David Higgs
4d066cd1bd tests: exercise sparse edit with invalid path 2025-12-12 02:55:55 +00:00
David Higgs
23496ffa65 tests: exercise util install-man-pages 2025-12-12 02:55:55 +00:00
David Higgs
29979e0c32 tests: exercise util exec when the program crashes 2025-12-12 02:55:55 +00:00
David Higgs
349bca031b tests: exercise util completion with elvish and powershell 2025-12-12 02:55:55 +00:00
xtqqczze
7c89dc3d23 refactor: remove non-binding let
Follow-up https://github.com/jj-vcs/jj/pull/8271
2025-12-11 19:16:16 +00:00
Yuya Nishihara
24c1197aaf git: use try_find_reference() and propagate error when exporting refs
I also renamed git_repo_ref to git_ref because there aren't any other "git_ref"
variables.
2025-12-11 00:50:29 +00:00
Yuya Nishihara
c6cc177103 config: remove outdated migration rules 2025-12-11 00:49:58 +00:00
Steve Klabnik
e5e4805ef4 docs: Improve squash command description
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Add an explanation for why it's called "squash".

Fixes #7661
2025-12-10 23:07:53 +00:00
Yuya Nishihara
9620b00d95 revset, templater: deprecate git_head() and git_refs() functions
While these two are stored in view objects, we intentionally ignore them when
undoing. This means that these fields don't have to be tracked by
view/operation. I think we can move them away to GitBackend-specific data.

We could provide git_head()/git_refs() that load data from GitBackend, but I
don't think these template/revset functions are useful. I've never used them
except for the git_head() template function, and its use case was to see whether
the repository is colocated or not.
2025-12-10 14:26:47 +00:00