1243 Commits

Author SHA1 Message Date
Yuya Nishihara
de462a6268 tests: add helper to snapshot command output and exit status all at once
It's easier to review insta snapshot diffs than scanning panic log containing
lengthy output. I think this will also help printf debugging.

test_global_opts.rs is migrated to new API as an example.
2025-02-20 05:22:32 +00:00
Yuya Nishihara
740d8a2b1b tests: add #[must_use] to helper functions that return value to be tested 2025-02-20 05:22:32 +00:00
George Christou
a5e079f543 ui: add color to help text 2025-02-20 01:22:02 +00:00
Baltasar Dinis
f233de5f69 cli: remove error hint for invalid remote names
Existing hint suggests using `jj git remote rename`, but that's not
applicable to `jj git clone`.

This commit removes that hint.
2025-02-19 07:14:00 +00:00
Yuya Nishihara
48b02226f5 cli: add "Hint: " prefix to conflict hints 2025-02-19 06:52:09 +00:00
Yuya Nishihara
a2a9a9935c cli: render "conflicts" message as warning
I don't have strong feeling, but this might be better because conflicts are
unusual?
2025-02-19 06:52:09 +00:00
Yuya Nishihara
1fa4e5a340 cli: status: do not label message lines as "conflict"
The "conflict" label is supposed to highlight "(conflict)" markers in commit
template. This patch just removes the label as we don't colorize the same
message in update_working_copy().
2025-02-19 06:52:09 +00:00
Yuya Nishihara
067e2ebaaa cli: status: reorder conflict message to match checkout stats
It seems also nice that the list of conflict files is displayed closer to the
resolution hints.
2025-02-19 06:52:09 +00:00
Yuya Nishihara
630036eeb0 tests: add [EOF] marker to command output when displaying
It's important to test that command output is (usually) terminated with newline,
but insta::assert_snapshot!() is lax about that.
2025-02-19 02:31:59 +00:00
Yuya Nishihara
a54165230a tests: add CommandOutputString wrapper
I'm going to add "[EOF]" marker to test that command output is terminated by
newline char. This patch ensures that callers who expect a raw output string
would never be affected by any normalization passes.

Some common normalization functions are extracted as CommandOutputString
methods.
2025-02-19 02:31:59 +00:00
Yuya Nishihara
0eddf5f3d6 tests: extract helper function that substitutes $TEST_ENV
I'm going to add wrapper type for normalized output, and this change makes
porting a bit easier.
2025-02-19 02:31:59 +00:00
Baltasar Dinis
64ea8bee47 git: reject remotes with forward slashes
Although this behaviour is accepted by git, it's a degenerate case.
Especially because we implicitely rely on being able to parse out the
remote from the refname (i.e., `refs/remotes/<remote>/<branch>`).

Branches can have forward slashes, but if remotes can also have them,
parsing the refname becomes ambiguous, and a pain. Especially because it
would be totally legal to have a branch "c" on remote "a/b" and a branch
"b" on remote "a".

Fixes #5731
2025-02-18 07:10:01 +00:00
Baltasar Dinis
d6e7047142 cli: add hint to rename on remote management error 2025-02-18 07:10:01 +00:00
Antoine Martin
149702ef7d working_copy: adjust max-size hint to fit all configurations
In the case where the user has set `snapshot.auto-track` to something
other than `all()`, running `jj st` with a higher file size set just for
that command will not actually fix the user's problem, `jj file track`
needs to be called instead.
2025-02-17 20:52:18 +00:00
Scott Taylor
00f87a2846 cli: untrack remote bookmarks on bookmark forget
Forgetting remote bookmarks can lead to surprising behavior since it
causes the repo state to become out-of-sync with the remote until the
next `jj git fetch`. Untracking the bookmarks should be a simpler and
more intuitive default behavior. The old behavior is still available
with the `--include-remotes` flag.

I also changed the displayed number of forgotten branches. Previously
when forgetting "bookmark", "bookmark@remote", and "bookmark@git" it
would display `Forgot 1 bookmarks`, but I think this would be confusing
with the new flag since the user might think that `--include-remotes`
didn't work. Now it shows separate `Forgot N local bookmarks` and
`Forgot M remote bookmarks` messages when applicable.
2025-02-17 17:02:58 +00:00
Yuya Nishihara
3cdaa5b1d8 cli: bookmark: remove hint about upsert behavior
It was added at 3c80e3453db6 "cli: branch: make "set" do upsert as before" in
order to remind behavior change.
2025-02-17 12:44:03 +00:00
Martin von Zweigbergk
3bfbec1c83 undo: fix check for double-undo
The condition we were checking (which I suggested during review) is
very broken. It checks if the new view is equal to view before the
current operation, but that's supposed to always be true (except for
operation that update remote bookmarks). The reason the warning didn't
trigger all the time was that we did the comparison after calling
`merge_view()` but before calling `rebase_descendants()` (via
`tx.finish()`). The former only records commits as abandoned without
actually hiding them. However, because of [the hack][hack] in
`merge_view()` to make it work reasonably well in huge repos, every
undo operation at Google would print the warning.

This patch fixes the bug by checking if the to-be-undone operation is
an undo by comparing its view to its grandparent's view.

 [hack]: ec6f8278fd/lib/src/repo.rs (L1693-L1708)
2025-02-16 16:52:51 +00:00
Martin von Zweigbergk
3470a48345 undo: demonstrate how double-undo warning isn't shown correctly
Will be fixed in the next patch.
2025-02-16 16:52:51 +00:00
maan2003
ec6f8278fd signing: allow specifying sign behavior 2025-02-16 05:56:52 +00:00
Evan Mesterhazy
a4b064ea8d cli split: Move bookmarks to the first commit instead of the second
After even more discussion on Discord, we decided to use the new bookmark
behavior immediately and only print a warning during `jj split` if the user has
opted out of the new behavior using the `split.legacy-bookmark-behavior` config
setting.

The reasoning is that if the behavior change breaks someone's workflow or is
very disruptive, they are likely to check the changelog and learn about the
config option. For users that are not adversely impacted, printing a warning
that can only be silenced by changing their config is also disruptive.

#3419
2025-02-16 04:02:24 +00:00
Yuya Nishihara
4ec22dde38 templater: port annotation line content to template
I originally thought we would have to add BString template type first, but we
can use opaque Template type instead.
2025-02-15 11:07:17 +00:00
Bryce Berger
3bc111e60e annotate: make AnnotationLine template type
Allows:
* self.commit()
* self.line_number()
* self.first_line_in_hunk()

Certain pagers (like `delta`), when used for `git blame`, only show the
commit information for the first line in a hunk. This would be a nice
addition to `jj file annotate`.

`jj file annotate` already uses a template to control the rendering of
commit information --- `templates.annotate_commit_summary`. Instead of
a custom CLI flag, the tools necessary to do this should be available in
the template language.

If `1 % 2` or `1.is_even()` was available in the template language, this
would also allow alternating colors (using `raw_escape_sequence`).

Example:

```toml
[templates]
# only show commit info for the first line of each hunk
annotate_commit_summary = '''
if(first_line_in_hunk,
  show_commit_info(commit),
  pad_end(20, " "),
)
'''
```
2025-02-15 02:34:38 +00:00
Martin von Zweigbergk
5e896b22fe repo: make commit visible when pointing bookmark to it
This was discussed in the Discord a while ago, and this is the logical and consistent
conclusion. Implementing it as such makes it consistent with both `jj edit` and `jj new`
which make hidden commits such as predecessors visible.

This actually was Martins work, I just added the tests.

Co-Authored-by: martinvonz <martinvonz@google.com>
2025-02-14 16:24:01 +00:00
Benjamin Tan
e021036740 cli: backout: add templates.backout_description configuration
Closes #5676.
2025-02-14 07:56:40 +00:00
Josh Steadmon
23691a636c config-schema: validate default configs in tests with taplo
Set up tests using `taplo check --schema` to validate the default configs.
Install taplo in GitHub CI and in the Nix flake.

Fixes #5670.
2025-02-14 04:17:37 +00:00
Evan Mesterhazy
37992412b6 cli split: Recommend jj config set --user instead of --repo in deprecation warning
It only occurred to me after I rebuilt jj and actually had to run the command
that we should probably recommend a change to the user config instead of the
repo config.

#3419
2025-02-14 01:41:41 +00:00
Yuya Nishihara
381bb8a869 tests: create parent directory of .git link file by caller
It seems a bit safer to set up the working directory by caller who knows the
test environment directory exists.
2025-02-14 01:14:39 +00:00
Yuya Nishihara
d5493e6b10 tests: inline create_gitlink() option to caller
Since we don't set up Git worktree properly, it's odd that init_git_repo() has
a option to create a workspace at the specified path.
2025-02-14 01:14:39 +00:00
Evan Mesterhazy
d5d21643d5 cli split: Add a config option controlling how bookmarks move during splits
Currently, `jj split` moves bookmarks from the target revision to the second
revision created by the split. Since the first revision inherits the change id
of the target revision, moving the bookmarks to the first revision is less
surprising (i.e. the bookmarks stay with the change id). This no-implicit-move
behavior also aligns with how `jj abandon` drops bookmarks instead of moving
them to the parent revision.

Two releases from now, `jj split` will no longer move bookmarks to the second
revision created by the split. Instead, local bookmarks associated with the
target revision will move to the first revision created by the split (which
inherits the target revision's change id). You can opt out of this change by
setting `split.legacy-bookmark-behavior = true`, but this will likely be
removed in a future release. You can also try the new behavior now by setting
`split.legacy-bookmark-behavior = false`.

Users who have not opted into the new behavior via the config setting will see
a warning when they run `jj split` informing them about the change. The default
behavior be changed in the future.

The `jj split` tests for bookmarks are updated to run in all three configurations:

- Config setting enabled
- Config setting disabled
- Config setting unset


#3419
2025-02-13 21:45:56 +00:00
Evan Mesterhazy
b90e5af51c json schema: Fix bad indentation for jj fix settings
The fix settings weren't indented consistent with the rest of the settings,
causing them to appear in the redacted snapshot in the test_util_config_schema
test.
2025-02-13 02:37:19 +00:00
Evan Mesterhazy
b2e2c79088 cli split: Move bookmark testing to a separate test
We are planning to add a config option that controls how bookmarks and change
ids move during `jj split` based on feedback in https://github.com/jj-vcs/jj/pull/5618.
I think the tests will be more readable after the config option is added if we
move the bookmark testing to its own test.

#3419
2025-02-12 19:45:37 +00:00
Baltasar Dinis
9ca6d179b2 cli/tests: port test_gitignore to gitoxide 2025-02-12 17:06:59 +00:00
Baltasar Dinis
6746942a06 cli/tests: port test_git_init to gitoxide
cargo-insta was re-run.
This is due to centralizing git interaction code to use a particular
different signature, which changes the commit hashes
2025-02-12 17:06:59 +00:00
Baltasar Dinis
18cd4d3010 cli/tests: add more gitoxide helpers
These are helpers for:
 - gitlinks
 - removing config values
 - symbolic references
 - status
 - index management
2025-02-12 17:06:59 +00:00
Ilya Grigoriev
3f9e55ffee json schema: set schema version to draft-4, clarify taplo support
"$comment" is not officially supported by draft-4, but it is in newer
drafts, and JSON schema readers are supposed to skip fields that
are not known to them.
2025-02-11 23:25:00 +00:00
David Rieber
dd73b5ab7d bookmarks: First step to make target revision a required argument to bookmark create/move/set.
With this change a warning is shown if the user does not explicitly specify the target revision, but the behavior is unchanged (it still defaults to the working copy).
In the future the warning will be turned into an error. In other words, it will be required to specify target revision.

The bulk of the changes here are to prepare tests for the upcoming change, to make the transition easier.

For additional details please see:
* https://github.com/jj-vcs/jj/issues/5374
* https://github.com/jj-vcs/jj/discussions/5363
2025-02-11 22:21:19 +00:00
Baltasar Dinis
39fe9aad3a cli/tests: remove allow(unused) from git helpers 2025-02-11 13:46:25 +00:00
Baltasar Dinis
5b174c9109 cli/tests: port test_git_import_export to gitoxide 2025-02-11 13:46:25 +00:00
Baltasar Dinis
4f6a2fcfc0 cli/tests: port test_commit_template to gitoxide 2025-02-11 13:46:25 +00:00
Baltasar Dinis
5076d0e6b1 cli/tests: port test_bookmark to gitoxide
cargo-insta was re-run.
This is due to centralizing git interaction code to use a particular
different signature, which changes the commit hashes
2025-02-11 13:46:25 +00:00
Baltasar Dinis
a8eb76f9c4 cli/tests: port test_operations to gitoxide
cargo-insta was re-run.
This is due to centralizing git interaction code to use a particular
different signature, which changes the commit hashes
2025-02-11 13:46:25 +00:00
Baltasar Dinis
d56d910db8 cli/tests: port test_undo to gitoxide 2025-02-11 13:46:25 +00:00
Baltasar Dinis
806e76613b cli/tests: port test_git_submodule to gitoxide 2025-02-11 13:46:25 +00:00
Baltasar Dinis
b80e73b7cf cli/tests: port test_tag_command to gitoxide 2025-02-11 13:46:25 +00:00
Baltasar Dinis
cd6141693b cli/tests: add gitoxide helpers 2025-02-11 13:46:25 +00:00
Baltasar Dinis
769dbd8f5f cli/tests: move test environment to its own file
The `mod.rs` was becoming crowded and this makes way for unrelated
additions to the test utilities module
2025-02-11 13:46:25 +00:00
Emily
77f54a267e git: enable subprocessing by default
Given the previously‐stated intention of making this default
for the 0.27 release, prepare for that decision ahead of time by
enabling subprocessing by default on trunk. This will help surface
any regressions and workflow incompatibilities and therefore give
us more information to decide whether to keep or revert this commit,
without inconveniencing any users who haven’t already opted in to
the bleeding edge.

Please feel free to revert without hesitation if any major issues
arise; this is not intended as a strong commitment to enable this
option for the next stable release if it turns out to not be ready. In
that case, it’s better that we learn that early on in the cycle,
rather than having to revert at the last minute or, worse, cutting
a stable release that we later find contains a serious regression.
2025-02-10 22:10:22 +00:00
Martin von Zweigbergk
1e25101cea
cli: status: replace "is clean" by "has no changes"
"The working copy has no changes" seems much easier to understand for
new users. Thanks to @Wilfred for the suggestion.
2025-02-10 08:01:50 -08:00
Martin von Zweigbergk
65dc6750e0 docs: move Git command table to a separate page
The table can be easy to miss in its current location.
2025-02-10 15:29:32 +00:00
Evan Mesterhazy
915fe8f11e cli split: Test how the working copy commit changes across multiple workspaces
When a commit is split, the second commit produced by the split becomes the
working copy commit for all workspaces whose working copy commit was the target
of the split.

This commit adds two tests for this behavior:

1. Split a commit which is the working copy commit for two workspaces.
2. Split a commit which is the working copy commit for only one of the two
   workspaces.

These tests check that the working copy commits for the workspaces are updated
correctly. Both parallel and non-parallel splits are tested.
2025-02-10 14:05:45 +00:00