1209 Commits

Author SHA1 Message Date
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
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
3f5f872204 view: rename workspace "id" to "name"
This matches the current implementation.
2025-03-31 03:39:29 +00:00
Yuya Nishihara
e66c545438 view: replace WorkspaceId by string-like newtypes
I think this makes more sense because WorkspaceId is currently a human-readable
name. In error/status messages, workspace names are now printed in revset
syntax.

New WorkspaceId types do not implement Default. It would be weird if string-like
type had non-empty Default::default(). The DEFAULT constant is provided instead.
2025-03-31 03:39:29 +00:00
Yuya Nishihara
a08d53bef8 cli: do not panic on non-utf-8 workspace name to add 2025-03-31 03:39:29 +00:00
Yuya Nishihara
f87db58617 view: rename RemoteRefState::Tracking to Tracked
In jj's model, a local bookmark "tracks" remote bookmarks. It's wrong to call
a remote bookmark state as "tracking".
2025-03-31 01:41:31 +00:00
Jakob Hellermann
68ef93ebd6 cli: add revsets.log-graph-prioritize setting
The option will be used to prioritize branches of the `jj log` graph to
be displayed on the left.
This can make them more readable in some situations.
An example would be
```
[revsets]
log-graph-prioritize = "coalesce(description("megamerge\n"), trunk())"
```
2025-03-29 13:50:55 +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
7124d1b90a cli: move has_tracked_remote_bookmarks() to cli_util 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
Yuya Nishihara
d6be4a598e git: use GitRefName newtypes in push functions 2025-03-28 01:29:30 +00:00
Yuya Nishihara
fb8e45d6f9 view: introduce GitRefName newtypes
We don't reuse the RefName type here because fully-qualified Git ref name
shouldn't be considered a local ref name in jj.
2025-03-28 01:29:30 +00:00
Yuya Nishihara
a50f3881f0 cli: move revset_parse_context() and template_aliases_map() to env object
There aren't many callers of these functions.
2025-03-26 13:03:41 +00:00
Yuya Nishihara
3656a62bf5 git: use RemoteName newtype in remote management functions 2025-03-26 13:03:37 +00:00
Yuya Nishihara
4ff2827d00 git: use RemoteName/RefName newtypes in fetch functions 2025-03-26 13:03:37 +00:00
Yuya Nishihara
b9f51ff992 ref_name: add RefName::to_remote_symbol(remote) for convenience 2025-03-26 13:03:37 +00:00
Yuya Nishihara
02722eae54 view: port bookmark/tag name types to RefName/RemoteName
I tried to minimize this patch, but it seemed rather complicated than porting
most callers all at once. Remote management functions in git.rs are unchanged.
They'll be ported separately.

With this change, many non-template bookmark/remote name outputs should be
rendered in revset syntax.
2025-03-26 11:07:06 +00:00
Yuya Nishihara
cc8a80c548 ref_name: move RemoteRefSymbol types from refs module 2025-03-26 11:07:06 +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
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
Yuya Nishihara
5ee1dbbd22 git: wrap list of failed exports in struct
I have no immediate plan, but I think we can make "jj git export" show exported
refs. The FailedRefExport type is replaced with a plain tuple since we have a
named type wrapping (symbol, reason) pairs now.
2025-03-24 01:18:24 +00:00
Yuya Nishihara
7404338362 git: replace remaining caller of old parse_git_ref() 2025-03-23 11:02:49 +00:00
Yuya Nishihara
e52ddda98f conflicts: pack MaterializedTreeValue::File fields, use read_all() helper
This pattern is common.
2025-03-23 01:31:15 +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
Yuya Nishihara
6f31ba9042 cli: git-push: use RemoteRefSymbol to format and pass name@remote around
This ensures that remote symbols are printed with quoting as needed. Local
bookmark names aren't quoted, which will be fixed separately by introducing
RefName(str) newtype.
2025-03-19 14:28:56 +00:00
Yuya Nishihara
8ae605703e cli: git-push: rename bookmark name/remote variables, bind reference
I'm going to replace (name, remote) pair with RemoteRefSymbol. The underlying
name types will also be changed to RefName/RemoteName newtypes.
2025-03-19 14:28:56 +00:00
Yuya Nishihara
f37f927bc2 cli: abandon: remove --summary flag, just print elided list
AFAICT, this option was needed when we're going to abandon hundreds of commits.
However, I typically notice that I had to use --summary to suppress the output
after the fact. Since the list is now truncated up to 10 commits, I don't think
the --summary flag is useful anymore. This patch also removes the special case
for 1 item, which existed primarily for overriding --summary.
2025-03-19 05:32:26 +00:00
Yuya Nishihara
976f3585e1 cli: truncate list of abandoned/created/updated commits
The choice of the upper limit is arbitrary. We use 5 in "multiple revisions"
error, but I feel 5 would be too small for "jj absorb", where the stack of
mutable commits may be ~10, but wouldn't likely be ~100s.
2025-03-19 05:32:26 +00:00
Yuya Nishihara
f07203cb3b cli: extract helper that prints list of indented commit summary 2025-03-19 05:32:26 +00:00
Yuya Nishihara
ccf927e1d8 cli: pass CheckoutStats to "print" function by reference 2025-03-18 14:35:54 +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
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
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
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
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
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
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
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