Commit graph

2751 commits

Author SHA1 Message Date
Yuya Nishihara
6df3e240ed cli: add top-level context label to commit templates
Since operation templates have "operation" label, commit templates should have
"commit" for consistency.

The [colors] table is not updated to use the "commit" prefix. There are some
non-template outputs which use unqualified "bookmark"/"tag"/"git_ref" labels.
That's also a reason why "bookmark_list" template doesn't have a "bookmark"
context label yet. (We'll need to qualify the color definition as "commit
bookmark" so the whole bookmark list wouldn't be colorized as "bookmark".)
2025-05-19 01:41:15 +00:00
Yuya Nishihara
28cb16e83e cli: add top-level command-name label to op diff/show templates 2025-05-19 01:41:15 +00:00
Yuya Nishihara
d43d8c4e23 cli: add top-level command-name/context labels to graph "node" templates
It's inconsistent that the content templates have e.g. "op_log operation", but
the graph node templates don't.
2025-05-19 01:41:15 +00:00
Yuya Nishihara
f8a0fcfc47 templater: make .labeled() accept list of labels
I'm going to add top-level "<command> <context>" labels to templates, and many
of .labeled() callers will have to set at least two labels.
2025-05-19 01:41:15 +00:00
Yuya Nishihara
9e5205daee cli: git: fix "tag" labeling in import stats 2025-05-18 07:30:46 +00:00
Yuya Nishihara
86d4f4b90f cli: git: do not attempt to align bookmark and tag changes in stats
It was broken when we renamed "branch" to "bookmark", and there were no
complaints since then. Let's simply align changes per ref type.
2025-05-18 07:30:46 +00:00
Martin von Zweigbergk
23de072c14 store: drop "_async" suffix from read_file()/read_symlink()
There's no sync version anymore.
2025-05-18 02:45:43 +00:00
Martin von Zweigbergk
12bcd04459 store: delete read_file(), update callers to use async version 2025-05-18 02:45:43 +00:00
Yuya Nishihara
a1abe46c45 cli: define "operation tags" color properly
It's unrelated to (commit) "tags", and the color of "current_operation" seemed
wrong.
2025-05-18 01:42:14 +00:00
Yuya Nishihara
183a7b6eba cli: label "working_copy" by commit_summary template, not by code
I'm thinking of adding a top-level context label consistently. If we added
"commit" to the summary template (in code), the status output would be labeled
as "working_copy commit ..", whereas log entries would be labeled as "commit
working_copy ..". The latter should be more correct since the "commit" label
is global.

Now the working-copy entry is highlighted in op log and bookmark list, which
I think is good.
2025-05-18 01:42:14 +00:00
Yuya Nishihara
f7f85383bc tests: snapshot a few more colored outputs 2025-05-18 01:42:14 +00:00
Vincent Ging Ho Yim
53619359e2 cli describe: refactor to use pattern matching
This is both more idiomatic and explicit.
2025-05-17 15:44:57 +00:00
Vincent Ging Ho Yim
9d5c146c9b cli describe: remove redundant assertion of conflicting flags
This assertion is redundant given both the `conflicts_with = "edit"` declaration on the
`no_edit` flag and the passing `test_edit_cannot_be_used_with_no_edit` test.
2025-05-17 14:19:16 +00:00
Vincent Ging Ho Yim
459ed85f62 cli describe: move use_editor variable closer to use sites 2025-05-17 14:19:16 +00:00
Vincent Ging Ho Yim
e18eb8e05e test: clean up op log output to show short op ids 2025-05-17 12:20:38 +00:00
Vincent Ging Ho Yim
9d995c7f43 test: use --at-op and templates instead of manually parsing op ids from op log
There is an additional run of `jj op log`, so a commit id has changed here.
2025-05-17 12:20:38 +00:00
Vincent Ging Ho Yim
1398f1c174 test: rename op id variables and reword comment
The `previous_op_id` doesn't belong to the operation immediately before the
`current_op_id`. There is one operation in between, namely the latest snapshot taken.
2025-05-17 12:20:38 +00:00
Vincent Ging Ho Yim
2a596f7516 test: remove redundant --at-op argument 2025-05-17 12:20:38 +00:00
Vincent Ging Ho Yim
3dcf2e4d75 test: refactor to use get_log_output() helper function 2025-05-17 12:20:38 +00:00
Vincent Ging Ho Yim
1636202413 test: omit commit ids from log template
We are not interested in the commit ids here.
2025-05-17 12:20:38 +00:00
Vincent Ging Ho Yim
1447ff8f25 test: fix grammar in comment 2025-05-17 12:20:38 +00:00
Isaac Corbrey
85d54eb3d8 docs: Don't include unnecessary shebangs
It isn't necessary to include shebangs in scripts passed into
`util exec` since you're already explicitly calling out the shell you'd
like to use. This change removes shebangs from examples for `util exec`
and adds a note below calling this out.
2025-05-17 11:51:07 +00:00
Martin von Zweigbergk
275504235b cli: replace ExitCode by u8
I'd like to make the internal `jj` binary at Google log the exit code,
but `ExitCode` doesn't seem to provide any way of getting the numeric
code out of it. This patch therefore replaces `ExitCode` by `u8` and
lets the `main()` function convert it to `ExitCode`. It's a bit
unfortunate but I don't see a better solution. It doesn't seem worth
it to create our own newtype for it.
2025-05-17 05:45:59 +00:00
Yuya Nishihara
88d79c135b cli: accept --tool=:<format> argument as builtin diff format
This is just for completeness. I don't think this is practically useful, but the
:<format> syntax should work in both config files and command arguments.
2025-05-17 00:11:00 +00:00
Nicole Patricia Mazzuca
f9d59a36c0 config: clarify warning
Instead of saying to move configuration files from
`~/Library/Application Support` to `~/.config`, jj now tells you to move
configuration files from `~/Library/Application Support/jj` to
`~/.config/jj`.
2025-05-16 13:46:22 +00:00
T6
13c6257aac templater: add arithmetic operators 2025-05-16 12:45:09 +00:00
Yuya Nishihara
a9bae8bc91 templater: deprecate CommitId::normal_hex()
If CommitId and ChangeId were separate types in templates, we wouldn't add
CommitId::normal_hex().
2025-05-16 11:12:33 +00:00
Yuya Nishihara
e9600ccfdb templater: split ChangeId/CommitId types
This isn't complex compared to the enum version, and provides a better error
message.
2025-05-16 11:12:33 +00:00
Yuya Nishihara
0140aa59a9 templater: inline CommitOrChangeId::short/shortest() helpers
I'll replace the enum with distinct ChangeId/CommitId template types.
2025-05-16 11:12:33 +00:00
Gaëtan Lehmann
0b0d313583 split: use "selected/remaining changes" instead of "first/second commits"
With the new -A/-B/-d flags, the new commit may be created anywhere in
the tree, making the denomination first/second commit inaccurate.
2025-05-16 07:55:12 +00:00
Vincent Ging Ho Yim
20fd0b7daf cli bookmark move: move names argument before --from argument
The usage line originally showed `--from <REVSETS>|NAMES`, which was confusing as it
could be parsed as `--from (<REVSETS> or NAMES)`, rather than the correct `(--from
<REVSETS>) or NAMES`.

The order of the two arguments are now swapped, so that Clap displays it as
`NAMES|--from <REVSETS>` instead. Using bookmark names as the move targets should be
more common anyway. This is also consistent with the order in which the two arguments
are described in the command's doc comment.
2025-05-16 05:06:15 +00:00
Yuya Nishihara
851d25cd68 cli: unify diff format/tool config variables
This allows users to override the external tool set in ~/.jjconfig.toml. The
config variable is renamed to ui.diff-formatter to be consistent with the other
diff/merge editor settings.

--tool=:<format> support will be added separately.

Closes #3327
2025-05-16 00:33:49 +00:00
Yuya Nishihara
f0386e2fae cli: add CommandNameAndArgs::as_str() helper
This is convenient as Option type provides monadic methods.
2025-05-16 00:33:49 +00:00
Yuya Nishihara
79cb3d231a cli: keep short/long diff formats specified by args separately 2025-05-16 00:33:49 +00:00
Yuya Nishihara
e4656ce359 cli: split builtin diff format resolution into two parts
If we add --tool=:<builtin-format> syntax, name resolution failure shouldn't be
translated to a ConfigGetError. This change prepares for that.
2025-05-16 00:33:49 +00:00
Vincent Ging Ho Yim
b99116fc23 cli: improve hint to abandon commits when divergent change appears
A divergent change could point to more than two commits, so the hint now suggests
abandoning unneeded commits rather than just one of them.

The `-r` flag is unnecessary for `jj abandon` as it is implied.

Also changed `<REVISION>` to `<commit_id>` to be clear that using the change id here
will not work.
2025-05-16 00:21:38 +00:00
Vincent Ging Ho Yim
cfce146f8f commit: show a hint if --message is not provided and the description is empty
This addresses part of #4414 and implements something akin to what's described in
@arxanas's [suggestion], with the exception that the editor contents don’t need to be
completely cleared, since whether cleared or not it is not obvious whether the user
intended to add an empty description or abort entirely.

[suggestion]: https://github.com/jj-vcs/jj/issues/4414#issuecomment-2359123535

The hint is not shown if an empty description is provided via `--message ""`, since the
user is explicitly bypassing the editor and wants to commit the change directly.

Otherwise, if a user exits the editor with an empty description (notwithstanding any
`JJ:` lines), it could be one of the following cases:

1. The user wants to commit the changes but no longer wants to add a description. The
hint can simply be ignored.

2. The user wants to commit the changes and add a description but accidentally exits the
editor. The second hint shows how to add a description to the parent commit.

3. The user no longer wants to commit the changes. However, a new commit is still
created to maintain consistent behaviour as when an empty description is provided via
the CLI. The first hint shows how to undo the commit.
2025-05-15 13:02:53 +00:00
Vincent Ging Ho Yim
c683756533 commit: add tests for committing with empty description from CLI and from editor 2025-05-15 13:02:53 +00:00
Vincent Ging Ho Yim
9a39bf6c41 commit: remove trailing whitespace 2025-05-15 13:02:53 +00:00
Yuya Nishihara
dd33f9ae08 cli: git clone: add config to not track default remote bookmark
Since jj operates in detached HEAD state, a tracking bookmark isn't technically
needed in order to check out a commit. I usually employ this and delete
unmanaged local bookmarks after cloning repository. This option will automate
the setup.
2025-05-15 09:08:07 +00:00
Yuya Nishihara
2ac5ba0c18 cli: git clone: include "tracked" default bookmark in stats output
Since the default remote bookmark is tracked at the end of "jj git clone"
command, it's probably better to show that in the stats output. I originally
implemented it the other way because "git clone --no-checkout" wouldn't create a
local bookmark. However, the tracking bookmark is unrelated to the check-out
state in "jj", so I think it's okay to set up tracking within the "fetch"
transaction.
2025-05-15 09:08:07 +00:00
Yuya Nishihara
a5b30a20b1 tests: use "jj git fetch" instead of "clone" in op show/diff tests
These tests set up conflicting bookmarks, and doing that would become a little
bit harder in the next patch.
2025-05-15 09:08:07 +00:00
Yuya Nishihara
a7c3202e12 cli: git clone: rename "tx" variables
We no longer have two transactions in the same scope.
2025-05-15 09:08:07 +00:00
Vincent Ging Ho Yim
e46e5f7ea6 cli, lib: update MutRepo references in comments to MutableRepo 2025-05-14 08:41:20 +00:00
Vincent Ging Ho Yim
e0bd530686 cli git init: show jj bookmark track command on new line
I often copy and run this command after running `jj git init --colocate`. Having it on a
separate line makes it stand out more and easier to copy, especially if there are many
bookmarks listed.
2025-05-14 07:14:47 +00:00
Yuya Nishihara
2d79c6431d templater: introduce newtype to format ref/remote name in revset syntax
This is the last part of the series 02722eae54 "view: port bookmark/tag name
types to RefName/RemoteName." Templater doesn't use these name types internally
because we wouldn't gain much type safety in template language.

The return type of .remote() is changed to Option<RefSymbol>. An empty symbol is
rendered with quotes, so it would be weird if local_bookmark.remote() returned
an empty RefSymbol.
2025-05-13 23:54:47 +00:00
Yuya Nishihara
5e7bc347e7 tests: add helper to insert function to commit template environment
To test comparison operators, we'll need constructor functions in templates.
2025-05-13 23:54:47 +00:00
Yuya Nishihara
3e182c17f0 tests: add utility for commit template types, port trivial tests
Non-CLI tests are cheap, and we can express the condition and expectation more
directly.
2025-05-13 23:54:47 +00:00
Gaëtan Lehmann
193d9452b0 split: implement -A/-B/-d flags
the feature reused as much as possible of the `jj rebase` code, with
minimum modifications, in order to avoid reimplementing or complexifying
the rebase code.
It leads to some cases where some commits may be rewritten twice.

For example:

    ❯ jj -s
    @  ylrkuwto (empty) (no description set)
    ○  qsorlqym file4
    │  A file4
    ○  mmkvzzpw file3
    │  A file3
    ○  uttlrpzl file1&2
    │  A file1
    │  A file2
    ◆  zzzzzzzz root()

    ❯ jj split -r u -A m -m file1 file1
    Rebased 3 descendant commits
    First part: ulpvupsv aaf064bc file1
    Second part: uttlrpzl 0d4358c2 file1&2
    Working copy  (@) now at: ylrkuwto 60d905c5 (empty) (no description set)
    Parent commit (@-)      : qsorlqym 8cfbe2d8 file4

    ❯ jj -s
    @  ylrkuwto (empty) (no description set)
    ○  qsorlqym file4
    │  A file4
    ○  ulpvupsv file1
    │  A file1
    ○  mmkvzzpw file3
    │  A file3
    ○  uttlrpzl file1&2
    │  A file2
    ◆  zzzzzzzz root()

There is an intermediate state created as

    @  ylrkuwto (empty) (no description set)
    ○  qsorlqym file4
    │  A file4
    ○  mmkvzzpw file3
    │  A file3
    ○  uttlrpzl file1&2
    │  A file2
    ○  ulpvupsv file1
    │  A file1
    ◆  zzzzzzzz root()

where the commits in `uttlrpzl::` have been rewritten, then `ulpvupsv`
is moved, effectively rewriting the commits in `ulpvupsv::`.

The number of user visible rewritten commits is accurately reported.

`jj split --parallel` is still done as a special case: implementing
it with the rebase code would put the first commits on the right
branch.
2025-05-13 17:26:00 +00:00
Vincent Ging Ho Yim
bb115fe33d cli util gc: fix typo in doc comment 2025-05-13 10:15:13 +00:00