1247 Commits

Author SHA1 Message Date
Ilya Grigoriev
ecde53c5bb cli completion: add completion for jj git push --named
Follow-up to https://github.com/jj-vcs/jj/pull/5698
2025-04-01 16:56:33 +00:00
Remo Senekowitsch
fb1a27ff09 cli: require --deleted to push deleted bookmarks 2025-04-01 15:58:50 +00:00
Yuya Nishihara
5db62a6b96 tests: port test_revset_output.rs to TestWorkDir API 2025-04-01 15:00:17 +00:00
Yuya Nishihara
f1a52d8504 tests: port test_revert_command.rs to TestWorkDir API 2025-04-01 15:00:17 +00:00
Yuya Nishihara
4d4de68c91 tests: port test_restore_command.rs to TestWorkDir API 2025-04-01 15:00:17 +00:00
Yuya Nishihara
3ba2ea7ace tests: port test_resolve_command.rs to TestWorkDir API 2025-04-01 15:00:17 +00:00
Yuya Nishihara
169a8b3f35 tests: set up fake editor early in test_{resolve,restore}_command.rs
This helps avoid borrowing issue in the next patch.
2025-04-01 15:00:17 +00:00
Yuya Nishihara
4bcebe678c cli: pad empty description intro/instruction lines with "JJ:"
Since 7618b52b "cli: consider 'JJ:' lines as comments also when not followed by
space", lines starting with "JJ:" (without space) are also ignored. We can
simply add "JJ:" prefix to empty intro/instruction lines.

Closes #5484
2025-04-01 02:02:02 +00:00
Yuya Nishihara
fd05b6f4cb cli: make description template insert blank line if old description was empty
This helps detect whether the last line is "JJ:" instruction or not. It seems
also nice that I don't have to insert newline to reflow the edited paragraph.
2025-04-01 02:02:02 +00:00
Robin Stocker
0456701e18 cli: Print @ and @- in status and print_updated_working_copy_stats
This helps newcomers learn/remember what @ and @- stand for.
2025-03-31 11:57:04 +00:00
Robin Stocker
2d9c72ffb1 cli/tests: Prevent git.subprocess from reading outside git config
A subset of cli tests could fail if the system /etc/gitconfig had
configuration interfering with the tests. The cause seems to be running
of `jj` commands that would in turn use a `git` subprocess.

Fix this by setting `GIT_CONFIG_SYSTEM` and `GIT_CONFIG_GLOBAL`, like
in `hermetic_git`.

Fixes #6159
2025-03-31 10:46:57 +00:00
Yuya Nishihara
60372ead43 tests: port test_repo_change_report.rs to TestWorkDir API 2025-03-31 10:35:36 +00:00
Yuya Nishihara
d15aa8c1c1 tests: port test_rebase_command.rs to TestWorkDir API 2025-03-31 10:35:36 +00:00
Yuya Nishihara
f3ed4cfed6 tests: port test_parallelize_command.rs to TestWorkDir API 2025-03-31 10:35:36 +00:00
Yuya Nishihara
da8ff3083c tests: port test_operations.rs to TestWorkDir API 2025-03-31 10:35:36 +00:00
Ilya Grigoriev
9db0739320 cli git push: new --named NAME=REVISION argument to create and immediately push bookmark
Fixes #5472
2025-03-31 03:51:28 +00:00
Yuya Nishihara
e4982a9c33 git: report HEAD export failure as warning
It's safe to commit transaction even if HEAD couldn't be updated due to
concurrent changes.

Closes #6098
2025-03-30 01:46:00 +00:00
Yuya Nishihara
69f278a581 tests: port test_next_prev_commands.rs to TestWorkDir API 2025-03-29 14:42:08 +00:00
Yuya Nishihara
1df956bfb5 tests: port test_new_command.rs to TestWorkDir API 2025-03-29 14:42:08 +00:00
Yuya Nishihara
511d0bd499 tests: port test_log_command.rs to TestWorkDir API 2025-03-29 14:42:08 +00:00
Yuya Nishihara
7f1bc15469 tests: port test_interdiff_command.rs to TestWorkDir API 2025-03-29 14:42:08 +00:00
Yuya Nishihara
76283dc4b6 tests: port test_immutable_commits.rs to TestWorkDir API 2025-03-29 14:42:08 +00:00
Yuya Nishihara
96cfae1ff7 cli: abandon: show warning if deleted bookmarks had tracking remotes
This should mitigate the issue that user might push deleted bookmarks without
noticing by "jj abandon && jj git push --all".

https://github.com/jj-vcs/jj/issues/3505#issuecomment-2646024815
2025-03-28 14:34:51 +00:00
Yuya Nishihara
fb1c5da3db cli: git-push: remove support for existing long --change bookmark names
It's deprecated since 1aad25042029 "Shorten the git push branch when possible
using the short change ID hash" (2023-01-12). I don't think we need the
fallback. I also removed the check for ambiguous prefixes as I believe it
wouldn't practically matter. If needed, we can add a check for existing bookmark
pointing to different commit. We can also make it templated with default
"'push-' ++ change_id.shortest(12)".
2025-03-28 14:34:11 +00:00
Remo Senekowitsch
f295817fe3 cli: completion: fix renamed paths
Previously, the completions suggested the literal string:
`{f_not_yet_renamed => f_renamed}`. Instead, the old and new file names
should be completed separately.
2025-03-27 22:23:29 +00:00
Remo Senekowitsch
4c8ddd47d0 cli: completion: fix test for renamed paths
Previously, the "renamed" file wasn't deleted at its old location, so it
wasn't renamed at all. Correcting this reveals a bug in the completions
of renamed paths. The completions suggest the literal string:
`{f_not_yet_renamed => f_renamed}`. Instead, the old and new file names
should be completed separately.
2025-03-27 22:23:29 +00:00
Baltasar Dinis
8ae80523e4 git: forward rejection reason on push
We've been finding that a lot of bug reports on `jj git push` come from
sub-standard error reporting on the reasons the failure happens.

It can come from a number of places:
 - hook failure
 - remote branch protection
 - git config

This commit forwards the reason as explained by the ouptut of git push
to help users figure out what is happening.
2025-03-26 04:46:38 +00:00
Baltasar Dinis
89bb1c4e71 git: refactor push ref error reporting
We need to report more complicated errors on push.
Firstly, we can have a mix of unexpected ref locations and remote
rejections. We should report both at the same time.

Second, git gives us a reason for why a push failed.
For this to work, it's relevant to refactor the current error reporting
path to allow us to inject this information.
2025-03-26 04:46:38 +00:00
Evan Mesterhazy
83ce245995 cli split: Check the evolog in two tests
This is to ensure two things:

1. That the evolog isn't missing the history from the target commit.
2. That the evolog doesn't include extra "temporary" commits due to
   the way `jj split` is implemented.

The impetus for this is the discussion in https://github.com/jj-vcs/jj/pull/5926.
The changes added here detect the extra temporary commit added to the evolog
when `split --parallel` is run using the implementation in #5926.
2025-03-25 14:21:44 +00:00
Martin von Zweigbergk
108aae1d9b git: set --intent-to-add on new files
In colocated repos, we set up the Git index to make `git diff` closely
match `jj diff`. However, `git diff` will not include new files. We're
long talked about using the `git add --intent-to-add` feature to make
the match closer. This patch implements that. It does so both after
updating the working copy and after snapshotting. After updating the
working copy, the new file in the working-copy commit (compared to the
parent(s)) are marked as intent-to-add. After snapshotting, newly
snapshotted files are marked as intent-to-add, and deleted ones that
were previously marked as intent-to-add are removed from the index.

Closes #6122
2025-03-25 13:40:13 +00:00
Martin von Zweigbergk
5d7ab9be6b git: also test how we set the index flags
I'm about to set the intent-to-add flag for newly added files. It's
also somewhat useful to see the index flags for conflict stages (the
different stages).
2025-03-25 13:40:13 +00:00
Benjamin Tan
60ce0b87d8 cli: git: add git root command
This was discussed briefly in [1], and makes it easier to execute
scripts which require a reference to the Git directory.

[1]: https://github.com/jj-vcs/jj/discussions/5767#discussioncomment-12480764
2025-03-25 08:58:43 +00:00
Martin von Zweigbergk
e392448288 time_util: replace use of chrono-english by interim
https://rustsec.org/advisories/RUSTSEC-2024-0395 recommends switching
from `chrono-english` to `interim` because the former is unmaintained.
2025-03-24 23:59:21 +00:00
Baltasar Dinis
f4d89fb6df cli/tests: add a filter to remove trailing whitespace in test_git_push_rejected_by_remove
The git remote sideband adds a dummy suffix of 8 spaces to attempt to clear
any leftover data. This is done to help with cases where the line is
rewritten.

However, a common option in a lot of editors removes trailing whitespace.
This means that anyone with that option that opens this file would make the
following snapshot fail. Using the insta filter here normalizes the
output.
2025-03-24 21:49:20 +00:00
Evan Mesterhazy
6ba5a76f51 cli split: Rename "siblings" test to "parallel"
The name of the flag was changed from --siblings to --parallel a while back,
but the tests weren't renamed.

#cleanup
2025-03-24 14:42:40 +00:00
Evan Mesterhazy
bb78c06d76 cli split: Add a simple split with descendants test
We have this test for split --parallel, but we don't actually have a
non-parallel split test where the target commit has descendants.
2025-03-24 14:42:06 +00:00
Evan Mesterhazy
b627924828 cli split: Explain how the diff script works in test_split_interactive_with_paths
It wasn't immediately obvious to me what was happening here, but once I
understood it it seemed pretty simple. Perhaps it's worth a comment to explain
it to the next reader.
2025-03-24 13:58:21 +00:00
Yuya Nishihara
7d59d0564e git: use translated remote symbols in export_refs()
I also made to_git_ref_name() stricter as it seemed odd that empty tag name and
remote name were allowed.
2025-03-23 01:32:29 +00:00
Yuya Nishihara
5ae63a2355 tests: port test_gitignores.rs to TestWorkDir API 2025-03-23 01:31:28 +00:00
Yuya Nishihara
0d8aeee3e5 tests: port test_git_remotes.rs to TestWorkDir API 2025-03-23 01:31:28 +00:00
Yuya Nishihara
d5226aad0a tests: port test_git_push.rs to TestWorkDir API 2025-03-23 01:31:28 +00:00
Yuya Nishihara
b80e5e07b8 tests: port test_git_private_commits.rs to TestWorkDir API 2025-03-23 01:31:28 +00:00
Yuya Nishihara
1466bce13c tests: move instantiation out of set_up() in test_git_{private_commits,push}.rs
set_up() doesn't have to create TestEnvironment by itself, and the local
TestWorkDir will borrow &test_env.
2025-03-23 01:31:28 +00:00
Yuya Nishihara
7583b9108e tests: port test_git_init.rs to TestWorkDir API 2025-03-23 01:31:28 +00:00
Yuya Nishihara
c2f2461b5f cli: truncate list of newly conflicted commits
If there are hundreds of new conflict commits, the user wouldn't want to see all
of them.
2025-03-23 01:31:22 +00:00
Yuya Nishihara
00c2d15f29 cli: do not print commit summary for previously-conflicted commits
I usually don't read these messages carefully, and the red "(conflict)" label
looked scary. Suppose we don't have to take further action on resolved commits,
I don't think we need to print commit summary for each resolved commit.
2025-03-23 01:31:22 +00:00
Yuya Nishihara
9a615b5b62 config: relax bare string rule to accept middle apostrophes, etc.
Closes #5748
2025-03-22 09:00:44 +00:00
Caleb White
caf172f651 templates: create builtin_draft_commit_description template
This moves the default template to `builtin_draft_commit_description` and
points `draft_commit_description` to it. This makes it easier to override
the template while still being able to refer to the default.
2025-03-22 02:06:10 +00:00
Yuya Nishihara
ca616fade2 tests: port test_git_import_export.rs to TestWorkDir API 2025-03-21 01:19:20 +00:00
Yuya Nishihara
569a405cea tests: port test_git_fetch.rs to TestWorkDir API 2025-03-21 01:19:20 +00:00