2112 Commits

Author SHA1 Message Date
Yuya Nishihara
f07203cb3b cli: extract helper that prints list of indented commit summary 2025-03-19 05:32:26 +00:00
Yuya Nishihara
322c9951cf ui: do not pass empty choice input to parse function
Since prompt_choice_with() is now public, it should handle the default value
more consistently. parse() shouldn't be a function that can potentially feed a
default value.

We no longer print "unrecognized response" on empty input. I think this is
correct because an empty input is noop.
2025-03-18 15:43:43 +00:00
Yuya Nishihara
c2c2196b14 cli: split name/email not configured message to warning and hint
We usually print a short error message plus detailed hints.
2025-03-18 14:35:54 +00:00
Yuya Nishihara
b9e88be191 cli: extract common formatting function for updated working-copy stats
It's not important to print the parent commits on update-stale, but there should
be no reason to deviate the output formatting.
2025-03-18 14:35:54 +00:00
Yuya Nishihara
ccf927e1d8 cli: pass CheckoutStats to "print" function by reference 2025-03-18 14:35:54 +00:00
Yuya Nishihara
1a4d8dbbf4 ui: reimplement prompt_yes_no() by using prompt_choice_with()
It was odd that uppercase "Y"/"N" wasn't accepted.
2025-03-18 11:17:34 +00:00
Yuya Nishihara
083292d198 ui: extract prompt_choice_with(..callback)
I think "jj next/prev" prompt can also support selection by change ID prefix.
Maybe we can also add ui.prompt_choice_range(prompt, range, default) if that's
common?
2025-03-18 11:17:34 +00:00
Ilya Grigoriev
2a4b2dedf0 simple backend: document the lack of fetching and pushing
This is barely worth doing, but since I did it once...

I feel that some people might treat the simple backend as an easter egg, and
this will help them know what to expect.
2025-03-18 06:38:18 +00:00
Ilya Grigoriev
659325f9c3 cli git fetch: stop tracing the arguments of the outer function
The important arguments are traced in the inner function.

Previously:

```
2025-03-18T05:01:44.714692Z DEBUG run_command:cmd_git_fetch{args=GitFetchArgs { branch: [Exact("main"), Exact("master"), Glob(GlobPattern("gh-readonly-queue*")), Glob(GlobPattern("ig/*"))], remotes: [Exact("upstream")], all_remotes: false }}:fetch{remote_name="upstream" branch_names=[Exact("main"), Exact("master"), Glob(GlobPattern("gh-readonly-queue*")), Glob(GlobPattern("ig/*"))] depth=None}: jj_lib::git_subprocess: spawning a git subprocess cmd=LC_ALL="C" "git" "--git-dir" "/Users/ilyagr/dev/jj/.git" "branch" "--remotes" "--delete" "--" "upstream/master"
```

Now:

```
2025-03-18T05:06:29.573444Z DEBUG run_command:cmd_git_fetch:fetch{remote_name="upstream" branch_names=[Exact("main"), Exact("master"), Glob(GlobPattern("gh-readonly-queue*")), Glob(GlobPattern("ig/*"))] depth=None}: jj_lib::git_subprocess: spawning a git subprocess cmd=LC_ALL="C" "git" "--git-dir" "/Users/ilyagr/dev/jj/.git" "branch" "--remotes" "--delete" "--" "upstream/master"
```
2025-03-18 06:02:05 +00:00
Philip Metzger
f8ab8a0e72 lib: rename the LocalBackend to SimpleBackend
This makes it clear to source code readers, that it isn't the _native backend_ the project
talks about in the Roadmap.
2025-03-17 17:17:11 +00:00
Benjamin Tan
2bf5d6aa8f cli: deprecate backout command 2025-03-17 15:03:29 +00:00
Benjamin Tan
8a816b2622 cli: add revert command
This adds a revert command which is similar to backout, but adds the
`--destination`, `--insert-after`, and `--insert-before` optoins to
customize the location of the new reverted commits.

`jj backout` will subsequently be deprecated.

Closes #5688.
2025-03-17 15:03:29 +00:00
Yuya Nishihara
dd0e4f8f66 tests: define config TestCase types early
I feel it's easier to follow if types are defined first.
2025-03-17 01:39:55 +00:00
Yuya Nishihara
93aa697ca1 tests: remove redundant .to_path_buf() from test_config_path() 2025-03-17 01:39:55 +00:00
Yuya Nishihara
0e32223d9a tests: inline config TestCase::run() into test function, use assert!()s
We generally use panicking functions in tests.
2025-03-17 01:39:55 +00:00
Yuya Nishihara
27c777b3e5 tests: reorganize config TestCase as parameterized test_case
The TestCase type will be a pure value type.
2025-03-17 01:39:55 +00:00
Yuya Nishihara
cdc2ddf822 tests: remove generic parameters from config TestCase
We don't care about the memory layout here, and it'll become verbose to spell
them out in the following patches.
2025-03-17 01:39:55 +00:00
Jonathan Gilchrist
153c972822 diff-editor: Always use Section::FileMode when creating or deleting files
The code in this area gets significantly simpler, since there's no
longer any ambiguity to resolve. The scm-record changes expect that any
mode changes are represented by file mode sections, and adds UI hooks to
simplify working with them (e.g. automatically de-selecting a deletion
mode change if any lines in the file are de-selected, since the file
still needs to exist to hold those lines).

If the user selects a file mode change, the new mode comes back as part
of .get_selected_contents(), so we can use this directly to figure out
whether the file was removed or just changed.
2025-03-16 18:18:46 +00:00
David Rieber
7e1901fefa jj fix: Refactor jj fix CLI, move some logic to lib to make it usable in other tools (e.g. in servers).
* The lib part should not deal with tools, or tool config, or running stuff in subprocesses. That stays in the CLI.
* Adds a fix_files function. This is the entry point.
* Adds a FileFixer trait with a single method to process a set of files. This is a high-level plugin point.
* Adds a ParallelFileFixer which implements the FileFixer trait and invokes a function to fix one file a time, in parallel.
* The CLI uses ParallelFileFixer.

The FileFixer trait allows environments (other than jj CLI) to plug in their own implementation; for example, a server could implement a FileFixer that sends RPCs to a "formatting service".
2025-03-16 17:59:22 +00:00
Emily
cce229d914 config: warn on unsupported git.subprocess = false 2025-03-16 06:07:28 +00:00
Emily
a56b78bdb6 git: make git2 support optional
This helps us prepare for removing the functionality down the line and
makes things easier for people building or packaging their own Jujutsu.
2025-03-16 06:07:28 +00:00
Baltasar Dinis
142ba74427 cli: change debug logging behaviour to whitelist jj crates
The current behaviour means (transitively) dependent crates' debug logs end up
in our logs when `--debug` is active.

The biggest offender here is `globset`, imported from the `ignore
crate`. These logs are extremely noisy and mostly irrelevant from our usecase.

This commit changes this behaviour to whitelist `jj` related debug logs,
while allowing more debugging to come from env vars
2025-03-16 04:12:01 +00:00
Ilya Grigoriev
acaedc3382 cleanup: enable unused_trait_names clippy lint and run clippy --fix 2025-03-16 00:35:56 +00:00
Caleb White
669bfaf09b cli: config: support multiple user configuration files
Multiple user configs are now supported and are loaded in the following precedence order:
  - `$HOME/.jjconfig.toml`
  - `$XDG_CONFIG_HOME/jj/config.toml`
  - `$XDG_CONFIG_HOME/jj/conf.d/*.toml`

Which removes the need to set `JJ_CONFIG` for a multi-file approach.
Later files override earlier files and the `JJ_CONFIG` environment
variable can be used to override the default paths.

The `JJ_CONFIG` environment variable can now contain multiple paths separated
by a colon (or semicolon on Windows).
2025-03-15 18:43:42 +00:00
Yuya Nishihara
67a2f41b80 ui: make prompt_choice() return index of choices
It's easier to process index than re-parsing stringified choice.
2025-03-15 06:29:01 +00:00
Yuya Nishihara
efabaa48b2 cli: print list of next/prev candidates to stderr
Follows up 0c7357ec5f55 "ui: write prompt messages to stderr."

I also removed &mut since writing to Ui doesn't require mutable reference.
2025-03-15 06:29:01 +00:00
Yuya Nishihara
f8082a052d templates: do not apply "overridden" label twice to detailed config list 2025-03-15 01:51:47 +00:00
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
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
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
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
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
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
Martin von Zweigbergk
dc7216d73a cli: diff: support multiple revisions to -r 2025-03-11 06:27:51 +00:00