2532 Commits

Author SHA1 Message Date
Yuya Nishihara
4ff6150df7 tests: port test_commit_template.rs to TestWorkDir API
std::fs::rename() and symlink() aren't added to TestWorkDir. There are few
instances of rename(). work_dir.symlink() would be a bit unclear whether the
link content path is normalized, which usually shouldn't.
2025-03-13 03:45:45 +00:00
Yuya Nishihara
55eeac9ddd tests: port test_commit_command.rs to TestWorkDir API 2025-03-13 03:45:45 +00:00
Yuya Nishihara
86beeea50c tests: configure fake editor early in test_commit_command.rs
This works around borrowing issue of test_env.
2025-03-13 03:45:45 +00:00
Yuya Nishihara
c07db5a4d8 tests: port test_builtin_aliases.rs to TestWorkDir API
The local work_dir is created by caller since it borrows &test_env.
2025-03-13 03:45:45 +00:00
Joachim Desroches
67ffbfa14f cli: annotate: do not panic on reaching initial commit.
As described in #5909, in the case where jj was initialized in a
shallowly cloned repository which was then unshallow'd, jj does not
import the fetched commits that were outside the shallow boundary.

However, it does import the ones after the boundary, which after
unshallowing do not contain the changes made before the boundary.

Therefore, when running annotate in such a case, jj would panic because
it does not find the commit from which a line originates. This sets the
empty commit as carrying the blame for that line.
2025-03-12 13:45:57 +00:00
Yuya Nishihara
dcf4771a07 cli: emit warning for deprecated diff.format, move default to config/misc.toml
The old name "diff.format" has been deprecated since 0.7.0, but there was no
deprecation warning.
2025-03-12 13:42:41 +00:00
Benjamin Tan
d928ef6f96 cli_util: compute_commit_location: return CommitId instead of Commit
Not all callers of `compute_commit_location` require the full `Commit`
struct.
2025-03-12 10:12:05 +00:00
Benjamin Tan
3f78de300b cli_util: WorkspaceCommandHelper::resolve_some_revsets_default_single: return CommitId instead of Commit 2025-03-12 10:12:05 +00:00
Yuya Nishihara
902ef9fce3 diff: fix inconsistent handling of "short" format arguments
All "short" formats should be able to be combined with -p/--patch. It was also
weird that "short" diff stats followed "long" color-words/git diffs.

Fixes #5986
2025-03-12 04:32:01 +00:00
Martin von Zweigbergk
a01d0bf773 cli: resolve: leave executable bit unchanged when using external tool
`jj resolve` will currently try to resolve the executable bit and will
clear it if it can't be resolved. I don't think the executable bit
should be affected by the external merge tool. We could preset the
flags on the files we pass to the merge tool and then expect the merge
tool to update the flags, but we don't do that. I'm not sure that's a
good idea (few merge tools probably expect that), but since we don't
do it, I think it's better to leave the executable bits
unchanged. This patch makes it so by calling
`Merge::with_new_file_ids()` on the original conflict whether or not
the content-level conflict was resolved.

I noticed this was while working on the copy-tracking proposal in PR
#4988, which involves adding copy information in the `TreeValue`. If
we do implement that, then we should preserve copy information here
too (in addition to the executable flag). That will automatically work
after this patch.
2025-03-12 04:15:17 +00:00
Martin von Zweigbergk
9fe2075650 cli: chmod: update TreeValues in place
If we add copy info to `TreeValue::File`, we will want to preserve
that when the user runs `jj chmod`. It's easier to preserve it by
updating the `Merge<Option<TreeValue>>` in place, so that's what this
patch does.
2025-03-12 04:15:17 +00:00
Ilya Grigoriev
2f97d4a3d8 cli clone and init: remove unhelpful parts of clap error
We could replace clap's "SuggestedSubcommand" instead of removing it,
but then the user might not notice that this is a custom suggestion and
not pay enough attention to it.

This uses the just-released https://github.com/clap-rs/clap/pull/5941.
2025-03-12 04:02:52 +00:00
Ilya Grigoriev
2bb8775c44 cli clone and init: color test for the error message
There are alternative ways to solving the problem addressed by the next
commit, but they don't seem to preserve color well. So, let's have a
test to make sure future refactorings can tell whether this issue is
still relevant.
2025-03-12 04:02:52 +00:00
Ilya Grigoriev
c38e316a91 cli op diff: show changes to the working copy positions
I find this useful for debugging what happened sometimes,
e.g. after some concurrent operations mess.
2025-03-12 03:41:27 +00:00
Ilya Grigoriev
ca46ce1d3a view: store working copies in BTreeMap
This is analogous to how bookmarks are stored and simplifies the
following commit.
2025-03-12 03:41:27 +00:00
Ilya Grigoriev
7d7a2fa390 cli string patterns: explain case-insensitive string prefixes
Before reading the docs, my instinct was to try `iglob:` instead of the
correct `glob-i:`.
2025-03-12 03:09:03 +00:00
Yuya Nishihara
e054a291b1 git: use translated remote symbols in import_refs()
This removes the special case for RefName::LocalBranch(_), which can be
processed as a remote bookmark.

"jj git import" now prints local bookmarks and tags with @git suffix. I think
this is more correct since these refs are imported from the backing Git
repository.
2025-03-12 02:20:00 +00:00
Yuya Nishihara
78361eb4f8 cli: deduplicate RefKind types
They're identical except for naming.
2025-03-12 02:20:00 +00:00
Yuya Nishihara
d8ae6dc8c9 tests: port test_bookmark_command.rs to TestWorkDir API 2025-03-12 02:18:56 +00:00
Yuya Nishihara
8fc6dea310 tests: port test_backout_command.rs to TestWorkDir API 2025-03-12 02:18:56 +00:00
Yuya Nishihara
b87a50783d tests: port test_alias.rs to TestWorkDir API 2025-03-12 02:18:56 +00:00
Yuya Nishihara
a68620a803 tests: port test_advance_bookmarks.rs to TestWorkDir API 2025-03-12 02:18:56 +00:00
Yuya Nishihara
76e9342bbb tests: port test_acls.rs to TestWorkDir API 2025-03-12 02:18:56 +00:00
Yuya Nishihara
d5d4c7fe79 tests: port test_absorb_command.rs to TestWorkDir API, add read_file() helper
read_file() returns BString as it implements Display.
2025-03-12 02:18:56 +00:00
Martin von Zweigbergk
dc7216d73a cli: diff: support multiple revisions to -r 2025-03-11 06:27:51 +00:00
Emily
185a09b9ca git: add test for Git state clean‐up 2025-03-11 03:09:13 +00:00
Ilya Grigoriev
09426ac222 cli fileset errors: insert link to docs 2025-03-11 03:00:58 +00:00
Emily
fe9e71b90e git: remove .gitmodules parsing code
This is redundant with `gix`’s native API and not used by anything
but a hidden debugging command.
2025-03-11 02:37:13 +00:00
Yuya Nishihara
1a8d2f5195 tests: use TestWorkDir in test_abandon_command.rs 2025-03-11 01:23:13 +00:00
Yuya Nishihara
e802c4b8fe tests: move current_operation_id() to TestWorkDir 2025-03-11 01:23:13 +00:00
Yuya Nishihara
61a449554b tests: pass &TestWorkDir to create_commit*() helper
Callers will be ported to TestWorkDir API separately.
2025-03-11 01:23:13 +00:00
Jo Liss
4e3f43c261 docs: explain that jj root is synonymous with jj workspace root 2025-03-10 21:44:06 +00:00
Emily
eeb34146ca tests: remove libgit2 test performance hack
I think we should only initialize the library for the fetch/push
tests now, so it should be okay to drop this.
2025-03-10 15:08:08 +00:00
Caleb White
072af8448f cli: bookmark move: allow short aliases for --to/--from
If `--to` is going to become a required argument, it should
have a short alias as it will be used quite frequently.

Given that `--to` has a short alias it only makes sense to
allow `-f` for `--from` as this is consistent with other
commands and nothing makes this particular command special.
2025-03-10 13:02:08 +00:00
Yuya Nishihara
16028245d6 tests: add workspace test helper, use it in test_global_opts.rs
It's super common to pair test_env with repo_path.

Some of the tests still use absolute paths because it seemed rather confusing
to mix paths relative to the repo_root and to the env_root.
2025-03-10 07:50:18 +00:00
Yuya Nishihara
c0066083ad git: make import of refs/remotes/git/* non-error, warn failed refs instead
I'm going to reimplement git_ref_filter to process translated remote bookmark
names, and "git" remote will mean the local Git-tracking remote there. The
reserved remote name is checked prior to filtering because refs in that remote
cannot be represented as remote symbols.

I originally implemented the error handling the other way because we didn't
have a machinery to report partial import failure. Now we have stats, it's
easy to report skipped ref names.
2025-03-10 02:04:33 +00:00
Yuya Nishihara
cc1b716d39 git: plumbing to report unimportable refs, warn non-utf-8 names
Tests will be added by the next patch. It's not important to report non-utf-8
refs, but this patch implements it as doing that was easy.
2025-03-10 02:04:33 +00:00
Emily
fd7f1f558e cli: remove git_util::get_git_repo
No longer used by anything.
2025-03-09 21:17:10 +00:00
Emily
2e0bdd3396 cli: use gix in maybe_set_repository_level_trunk_alias 2025-03-09 21:17:10 +00:00
Emily
8297938feb git: port remote management to gix 2025-03-09 21:17:10 +00:00
Emily
09f6cafa2b git: add remote management tests 2025-03-09 21:17:10 +00:00
Emily
c25aa6e417 git: abstract git2 in remote management API
This is more consistent with other similar APIs and minimizes churn
in the test code as we move these to `gix`.
2025-03-09 21:17:10 +00:00
Yuya Nishihara
3318d172ff cli: bookmark: scan deleted local bookmarks in separate loop
We no longer have to do multiple things in one loop.
2025-03-09 09:33:07 +00:00
Yuya Nishihara
791e04954e cli: bookmark: collect all list items to temporary vec
I think this will help implement sorting options. Untracked remote bookmarks
should be sorted independently, whereas tracked remote bookmarks should always
be listed after the associated local bookmarks.
2025-03-09 09:33:07 +00:00
Yuya Nishihara
cdcaee62f1 templater: add public getter methods to RefName type
Some of these will be called from "jj bookmark list". The template RefName type
is useful as an abstract local/remote ref object. Maybe it should be renamed to
RefEntry or CommitRef.
2025-03-09 09:33:07 +00:00
Martin von Zweigbergk
0055cd4e0b cli tests: move create_commit() tests helpers to common/ 2025-03-09 00:44:25 +00:00
Martin von Zweigbergk
169c131902 test_git_fetch: move clarification of description to template
I'm about to move the `create_commit()` helper to a common
place. However, this version of `create_commit()` is different from
the others in that it put a prefix of "descr_for_" in the
description. This patch removes that and instead updates the template
so it's still clear what's a description and what's a bookmark name.
2025-03-09 00:44:25 +00:00
Caleb White
813d2f1e6d config: update diff-editor and merge-editor schema
The docs show that the diff-editor, and merge-editor settings
can be a string or an array of strings. This updates the config
schema to reflect that.
2025-03-09 00:16:04 +00:00
Benjamin Tan
c248d97679 cli: debug copy-detection: fix help text
It looks like the help text was copied from another command and not
updated.
2025-03-08 15:28:55 +00:00
Ilya Grigoriev
7b38f82b3f cli op log: short -d alias for --op-diff
`--op-diff` is often more useful than `-p`/`--patch`.
2025-03-08 06:49:34 +00:00