1247 Commits

Author SHA1 Message Date
Benjamin Tan
48b850b3a5 cli: new: --insert-after: remove special handling of commits which are ancestors
The previous implementation of `new --insert-after` excluded children
that were ancestors of the new commit. This was done to avoid creating
cycles in the commit graph. However, this does not align with the
behavior of the `--insert-after` in the other commands, which explicitly
error if inserting a new commit after the given `--insert-after` commits
would create a cycle.

For consistency, and given that the desired behavior can be achieved
using by using `--insert-after` along with `--insert-before`, this
behavior is removed.
2025-03-03 14:56:32 +00:00
Yuya Nishihara
7e8dba8d94 op_store: validate operation/view id length to detect corruption earlier
After system crash, file contents are often truncated or filled with zeros. If
a file was truncated to empty, it can be decoded successfully and we'll get
cryptic "is a directory" error because of an empty view ID. We should instead
report data corruption with the ID of the corrupted file.

#4423
2025-03-03 01:18:34 +00:00
Burak Varlı
7b52ff51f0 cli git fetch: support string pattern syntax in remote option
Signed-off-by: Burak Varlı <unexge@gmail.com>
2025-03-01 12:11:19 +00:00
Baltasar Dinis
038da961c0 cli/tests: move test_git_colocated_unborn_bookmarks to gitoxide 2025-03-01 09:54:31 +00:00
Baltasar Dinis
071e724c1c cli/tests: move test_git_colocated_fetch_deleted_or_moved_bookmark to gitoxide 2025-03-01 09:54:31 +00:00
Baltasar Dinis
05479df69e cli/tests: move most of the test_git_colocated tests to gitoxide 2025-03-01 09:54:31 +00:00
pylbrecht
7b229e6b97 sign: format link in help
Following the existing conventions for formatting links.
2025-03-01 07:31:55 +00:00
pylbrecht
0e498c7dcb sign: link to docs in jj sign and jj unsign 2025-03-01 07:31:55 +00:00
Evan Mesterhazy
2af5b60d32 cli split: Disable the new bookmark behavior for jj split
The consensus about this change, if one ever existed, seems to have dissolved
into two cohorts, one which is happy with the change, and one which thinks we
should move both the bookmark and change id to the child commit instead of
leaving them on the parent.

We may decide to add flags to allow users to choose between the two behaviors,
but there are also other concerns such as where @ should go (parent or child).
Until we agree on a path forward it seems reasonable to delay the breaking
change by disabling it via the config option we added. I don't think it's
necessary to fully revert the code and new tests since we aren't announcing the
option.


#3419
2025-02-28 23:23:06 +00:00
pylbrecht
e5ca254084 sign: add --key argument to jj sign
Following up on #4747 (see
https://github.com/jj-vcs/jj/pull/4747#discussion_r1968720554).
2025-02-28 07:52:57 +00:00
Yuya Nishihara
b15769448b cli: provide better hint on bookmark name parse error
It should be better to say parsing failed, rather than starting with detailed
pest error message.
2025-02-28 07:27:40 +00:00
pylbrecht
c90f0b96a4 sign: add default revisions for jj sign
When signing commits with `jj sign`, one might want to use a workflow
like:

```bash
jj fix && jj sign .. && jj git push
```

Making the default value for `-r`/`--revisions` configurable, will allow
such a workflow.

Co-Authored-By: Yuya Nishihara <yuya@tcha.org>
2025-02-28 07:14:59 +00:00
Aleksey Kuznetsov
cfcd034879 docs: Add pointers to usage of jj help -k <keyword>
Relates to #5306
2025-02-28 06:52:52 +00:00
Yuya Nishihara
6c71f3cbf2 git: use RemoteRefSymbolBuf to represent RefName::RemoteBranch variant
This also changes the formatting to use revset compatible form.
2025-02-26 03:17:45 +00:00
Yuya Nishihara
2fd842ebf7 tests: normalize formatting in insta macro that could leave trailing whitespace
rustfmt occasionally complains about that.
2025-02-25 15:40:14 +00:00
Yuya Nishihara
7fa8420908 tests: resolve directory path to run_jj_in() relative to env_root
Suppose we'll add test_env.init_workspace(path) or something, this will probably
make sense.
2025-02-25 15:40:14 +00:00
Yuya Nishihara
3634ff298c tests: simplify jj_cmd() interface, rename to new_jj_cmd() 2025-02-25 15:40:14 +00:00
Yuya Nishihara
28803eef94 tests: rewrite remaining callers of jj_cmd() to use run_jj_in/with() 2025-02-25 15:40:14 +00:00
pylbrecht
f7ceac3bf4 unsign: implement jj unsign command
The output of `jj unsign` is based on that of `jj abandon`.

We output warnings when unsigning commits, which are not authored by the
user. This is encouraging to use `jj undo`, in case one unintentionally
drops signatures of others.

---

Co-authored-by: julienvincent <m@julienvincent.io>
Co-authored-by: necauqua <him@necauq.ua>
2025-02-25 13:36:44 +00:00
Anton Bulakh
76f79961fb sign: implement the jj sign command
We always sign commits. This means commits, which are already signed,
will be resigned. While this is cumbersome for people using hardware
devices for signatures, we cannot reliably check if a commit is already
signed at the moment (see https://github.com/jj-vcs/jj/issues/5786).

We output warnings when signing commits, which are not authored by the
user. This is encouraging to use `jj undo`, in case one unintentionally
signs commits of others.

The output of `jj sign` is based on that of `jj abandon`.

---

Co-authored-by: julienvincent <m@julienvincent.io>
Co-authored-by: necauqua <him@necauq.ua>
2025-02-25 13:36:44 +00:00
Yuya Nishihara
ad6985fd9c tests: migrate unusual patterns of jj_cmd_ok() to run_jj_in()
These callers are manually ported to run_jj_in().
2025-02-24 15:39:11 +00:00
Yuya Nishihara
804d175fd9 tests: migrate non-snapshot users of jj_cmd_ok() to run_jj_in().success()
These callers were mostly substituted mechanically.
2025-02-24 15:39:11 +00:00
Yuya Nishihara
3193513049 tests: migrate snapshot users of jj_cmd_ok() to run_jj_in()
These callers were mostly substituted mechanically, then fixed up formatting.
2025-02-24 15:39:11 +00:00
Yuya Nishihara
255532b6b8 tests: reorder comments and snapshots, split insta::allow_duplicates! { .. }
This helps replace jj_cmd_ok() by pattern matching.
2025-02-24 15:39:11 +00:00
Yuya Nishihara
b7e2932dba tests: compare CommandOutput where makes sense 2025-02-24 00:57:24 +00:00
Yuya Nishihara
c9926eae4c tests: implement Debug and Eq for CommandOutput
This helps assert that two command invocations generate exactly the same
results.
2025-02-24 00:57:24 +00:00
Yuya Nishihara
a1270f0149 tests: remove stale comment about CommandOutput wrapper 2025-02-24 00:57:24 +00:00
Yuya Nishihara
c83abc9dec tests: migrate non-snapshot users of jj_cmd_success() to run_jj_in().success() 2025-02-23 13:34:17 +00:00
Yuya Nishihara
cdcc777730 tests: migrate snapshot users of jj_cmd_success() to run_jj_in()
These callers were mostly substituted mechanically, then fixed up minor
formatting and name errors.
2025-02-23 13:34:17 +00:00
Yuya Nishihara
317993894b tests: migrate unusual users of jj_cmd_success() to run_jj_in/with()
These callers are manually ported to run_jj_in(). assert_eq!() is changed to
insta::assert_snapshot!() where possible.
2025-02-23 13:34:17 +00:00
Yuya Nishihara
a326b6e792 tests: migrate jj_cmd_success() output wrappers to run_jj_in() 2025-02-23 13:34:17 +00:00
Yuya Nishihara
2543329c78 tests: remove unused jj_cmd_panic() 2025-02-23 03:06:59 +00:00
Yuya Nishihara
79a0867050 tests: migrate callers of jj_cmd_internal_error() to run_jj_in() 2025-02-23 03:06:59 +00:00
Yuya Nishihara
b79b29c288 tests: migrate callers of jj_cmd_cli_error() to run_jj_in() 2025-02-23 03:06:59 +00:00
Yuya Nishihara
14ad894e47 tests: rewrite some alias tests to use normalize_stderr_with() 2025-02-23 03:06:59 +00:00
Yuya Nishihara
d19e58f591 tests: migrate callers of jj_cmd_failure() to run_jj_in() 2025-02-23 03:06:59 +00:00
Yuya Nishihara
696cfee55f tests: stop using assert_eq!() in cli tests where possible
Normalize the output instead.
2025-02-23 03:06:59 +00:00
Yuya Nishihara
7c2f723935 tests: unify parsing output helpers in revset and templater tests
run_jj_in() can handle both success and failure cases.
2025-02-23 03:06:59 +00:00
Bryce Berger
708e1c58cd cli: improve hint message when suggesting --ignore-immutable
There have been a number of users confused about why
their commits are immutable, or what to do about it, ex.
[https://github.com/jj-vcs/jj/discussions/5659].

Separately, I feel that the cli is too quick to suggest
`--ignore-immutable`, without context of the consequences. A new user
could see that the command is failing, see a helpful hint to make it not
fail, apply it and move on. This has wildly different consequences, from
`jj squash --into someone_elses_branch@origin` rewriting a single commit,
to `jj edit 'root()+'` rewriting your entire history.

This commit changes the immutable hint by doing the following:

* Adds a short description of what immutable commits are used for, and a
  link to the relevant docs, to the hint message.
* Shows the number of immutable commits that would be rewritten if
  the operation had succeeded.
* Removes the suggestion to use `--ignore-immutable`.
2025-02-23 02:24:43 +00:00
Bryce Berger
a17ed203ab fix: invoke tools from the workspace root
Previously, tools invoked by `jj fix` did not have their
`.current_dir()` set, and would just run from whatever directory the
user was in.

Now, the tools will always be invoked from the same directory that
`jj root` gives.

As a motivating example, consider a configuration path that's always at
the workspace root:

```toml
[fix.tools.something]
# previous:
command = ["cmd", "--config", "$root/tool.toml"]
#                              ^^^^^^ not possible
# now:
command = ["cmd", "--config", "./tool.toml"]
#                              ^^ now, just use a relative path
```
2025-02-23 02:21:57 +00:00
Bryce Berger
35936463ed cli: warn when command differs after --config, including when subcommand not found
Aliases and `ui.default-command` are loaded before `--config` and
`--config-file` arguments are parsed (#5282).

There is supposed to be a warning when the result of these arguments
would change the parsed args: #5286.

However, that warning was not being printed if the arguments failed to
parse due to an unrecognized subcommand. Example:

```bash
# correct:
$ jj --config ui.default-command=nonsense
Warning: Command aliases cannot be loaded from -R/--repository path or --config/--config-file arguments.

# previous, confusing:
$ jj --config aliases.some-alias=nonsense some-alias
error: unrecognized subcommand 'some-alias'

# now:
$ jj --config aliases.some-alias=nonsense some-alias
Warning: Command aliases cannot be loaded from -R/--repository path or --config/--config-file arguments.
error: unrecognized subcommand 'some-alias'
```
2025-02-22 20:19:42 +00:00
Yuya Nishihara
679a5c567a tests: migrate some jj_cmd_ok() output wrappers to run_jj_in()
Some of the wrapper functions are deduplicated as we can now handle success
and failure cases in the same way.
2025-02-22 01:23:04 +00:00
Yuya Nishihara
f1cd3a4e53 tests: migrate some jj_cmd_success() output wrappers to run_jj_in() 2025-02-22 01:23:04 +00:00
Yuya Nishihara
18ea718113 tests: migrate some helper functions that uses jj_cmd_*() to run_jj_in()
Snapshotted operation IDs are changed because this patch reorders "jj new"
command arguments.
2025-02-22 01:23:04 +00:00
Antoine Martin
631b9ada3d track: only print snapshot stats and hints once
Move the `track` specific logic to track.rs, let print_snapshot_stats
handle just the default case.

Previously print_snapshot_stats would get called twice and could warn
twice about a file (if that file was both in the auto-track fileset as
well as in the fileset passed to `jj file track`), so now we merge the
snapshot stats and display appropriate hints for each file.
2025-02-21 17:35:04 +00:00
George Christou
19cf1368f1 cli: restore: Fix --to placeholder 2025-02-21 05:40:43 +00:00
Yuya Nishihara
e23290d95d tests: migrate users of strip_last_line() to run_jj_in() function 2025-02-21 01:49:41 +00:00
Yuya Nishihara
2581cd82be tests: migrate users of normalize_with() to run_jj_in() function 2025-02-21 01:49:41 +00:00
Yuya Nishihara
cf7f1dfc88 tests: migrate users of normalize_exit_status() to run_jj_in() function 2025-02-21 01:49:41 +00:00
Yuya Nishihara
53664ce2a4 tests: migrate jj_cmd_stdin*() to run_jj*() functions 2025-02-21 01:49:41 +00:00