2398 Commits

Author SHA1 Message Date
Yuya Nishihara
d9c58446e8 templates: rename inner "config list" helper to format_*()
This is our convention, and helper functions can be hidden from the builtin
aliases list.
2025-03-15 01:51:47 +00:00
Yuya Nishihara
d79b93707c config: minor cleanup around new path/source template handling
Cow<str> provides .into_owned(). I don't care much about .to_string() vs
.to_owned(), but it was originally .to_owned(), so reverted the change.
2025-03-15 01:51:47 +00:00
Yuya Nishihara
ee89fd34a3 tests: port test_config_list_origin() to TestWorkDir API 2025-03-15 01:51:47 +00:00
Yuya Nishihara
b24c4eb758 cli: use RemoteRefSymbol to format trackable bookmarks 2025-03-14 15:40:58 +00:00
Yuya Nishihara
caa0e75936 cli: move print_trackable_remote_bookmarks() back to git/init.rs
We no longer have external callers of git_init() functions.
2025-03-14 15:40:58 +00:00
Yuya Nishihara
896424db76 templater: rename RefName type to CommitRef
I'm thinking of adding RefName(str) and RemoteName(str) newtypes, and the
templater type name would conflict with that. Since the templater RefName type
is basically a (name, target) pair, I think it should be called a "Ref", and I
added "Commit" prefix for disambiguation.

This isn't a breaking change since template type names only appear in docs and
error messages.
2025-03-14 14:58:29 +00:00
Jakob Hellermann
1f751e28cc templates: expose format_short_signature_oneline template alias hook
For `builtin_log_compact` you can specify how you want signatures to be
displayed via `format_short_signature`, but the same wasn't possible for
`builtin_log_compact_oneline` which always chose `email().local()`.
2025-03-14 13:50:51 +00:00
Baltasar Dinis
4e5260dad2 git: detect remote refusal of a push
When we push a ref to a git remote, we use --force-with-lease
Our understanding was that this could fail iff the expected location of
the ref on the remote was not that of the local tracking ref

However, if the ref is from a protected branch (e.g., main) it will be
rejected by the remote for a different reason.

This commit solves this, by detecting this difference.
2025-03-14 08:09:37 +00:00
Caleb White
67e17d5474 cli: config list: show origin of config values
Adds a `templates.config.list` config option to control whether the
detailed list is shown or not.

The `builtin_config_list_detailed` template adds the config origin to
the end of the line for each config value in the list. Options coming
from files will show the file path.
2025-03-13 23:59:45 +00:00
Yuya Nishihara
81f8ae42d6 tests: port test_debug_command.rs to TestWorkDir API 2025-03-13 16:13:12 +00:00
Yuya Nishihara
8520557aaa tests: port test_copy_detection.rs to TestWorkDir API 2025-03-13 16:13:12 +00:00
Yuya Nishihara
e35da6988c tests: port test_config_command.rs to TestWorkDir API
Some setup bits are reordered manually to work around mutable borrows.
2025-03-13 16:13:12 +00:00
Yuya Nishihara
dd00489235 tests: port test_concurrent_operations.rs to TestWorkDir API 2025-03-13 16:13:12 +00:00
Yuya Nishihara
334c9e184e tests: port test_completion.rs to TestWorkDir API 2025-03-13 16:13:12 +00:00
Yuya Nishihara
1ba5af082f config: externalize ConfigPath::Unavailable variant
We're going to add support for multiple user config paths, and it would be
weird if Unavailable could be included in a Vec.
2025-03-13 15:38:40 +00:00
Caleb White
7e944f0d11 cli: config {edit,set,unset}: prompt when multiple files exist
This allows the user to select a particular file when using multiple
configs. In the event that a prompt cannot be displayed, the first
file will be automatically selected.
2025-03-13 03:51:52 +00:00
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