705 Commits

Author SHA1 Message Date
Martin von Zweigbergk
3a650c3a68 repo: move StoreFactories::default() etc. to separate module
This is high-level glue code that we want to remove from the `repo`
module, so that module can be moved into a lower-level `jj-core`
crate.
2026-08-02 14:51:08 +00:00
Yuya Nishihara
60b05d21de cli: remove dummy git_util module, inline conditional blocks
There were only two callers of the stub functions.
2026-07-30 22:47:05 +00:00
Yuya Nishihara
6c6b572260 cli: acquire Git import/export lock early, remove unneeded op head reloading
Now the only remaining caller of maybe_snapshot() is "jj git init". We don't
need to reload the operation head for the newly created repository.
2026-07-30 07:48:54 +00:00
Yuya Nishihara
767bb22088 cli: move lock_git_import_export() helper to WorkspaceCommandEnvironment
This helps acquire a lock before constructing a WorkspaceCommandHelper instance.
2026-07-30 07:48:54 +00:00
Yuya Nishihara
4dd0faea0b cli: leverage workspace_helper_with_status() in "util snapshot"
"jj util snapshot" now matches the behavior of the other commands. It updates a
stale working copy if configured, which should be more correct.
2026-07-30 07:48:54 +00:00
Yuya Nishihara
28be60ab60 cli: extract inner function from recover_stale_working_copy()
recover_stale_working_copy_impl() will be called after the Git import/export
lock is acquired.
2026-07-30 07:48:54 +00:00
Yuya Nishihara
8d3621e4d7 cli: split workspace_helper_no_snapshot(), reuse loaded workspace if any
This allows us to acquire the Git import/export lock before resolving the
operation head.
2026-07-30 07:48:54 +00:00
Martin von Zweigbergk
2daed5c183 iter_util: make all fallible_*() async
All current callers pass in callbacks that should eventually become
async.
2026-07-29 15:00:12 +00:00
Yuya Nishihara
c12c3bcd54 cli: test --ignore-working-copy flag by callers of maybe_snapshot_impl()
Most callers do check_working_copy_writable()? first.
2026-07-27 03:07:30 +00:00
Yuya Nishihara
cc6cf25b7b cli: manage Git colocation flag by WorkspaceCommandEnvironment
This helps determine whether we need to acquire a Git import/export lock
without constructing a WorkspaceCommandHelper.
2026-07-27 03:07:30 +00:00
Yuya Nishihara
acf0374091 cli: remove redundant repo argument from is_colocated_git_workspace() 2026-07-27 03:07:30 +00:00
Yuya Nishihara
57c8760086 cli: pass may_snapshot_working_copy from CommandHelper
I'm going to move lock_git_import_export() there so we don't have to reload the
head operation after acquiring the lock. This patch clarifies that
may_snapshot_working_copy is set to self.is_working_copy_writable().
2026-07-27 03:07:30 +00:00
Yuya Nishihara
29328447c0 cli: create new mutable working-copy commit proactively at tx.finish()
This partially restores the old behavior from 36f4f09be4 "cli: create mutable
working-copy commit only when needed". Since an immutable wc behaves weirdly,
it should be better to avoid creating such state as possible.
2026-07-20 14:30:25 +00:00
Yuya Nishihara
4e55a6cbe4 revset: propagate error from is_empty(), replace .try_next().is_some() 2026-07-20 13:55:32 +00:00
Yuya Nishihara
b51edf06c8 cli: reset Git HEAD to parent of newly created working-copy snapshot
Since snapshot_working_copy() cannot use the finish_transaction() helper, we
need to manually export changes to Git. recover_stale_working_copy() now
acquires the Git import/export lock for the first snapshot, which seems more
correct.

Fixes #9827
2026-07-18 23:27:17 +00:00
David Rieber
f2acc3e43a lib/cli: bring back cli_util start_repo_transaction 2026-07-15 00:12:52 +00:00
David Rieber
34c044d22c lib: more versatile merge_operations, use it more broadly in CLI
This is all prep work to make merge_operations non-recursive, because at
Google we are sometimes seeing stack overflow in merge_operations due to
very large (merge_operations) stack frames.
2026-07-15 00:12:52 +00:00
David Rieber
fac2d7d3d3 cli: move start_repo_transaction factory method from cli_util to Transaction
In follow up commits I plan to use start_repo_transaction within a more
versatile and more unified merge_operations method in jj lib.
2026-07-15 00:12:52 +00:00
Josh McKinney
db49e5ff7b templates: Add FsPath template type
Add a core template type for filesystem paths backed by `PathBuf`.

`FsPath` renders native path bytes directly, so templates can print
paths that are not valid UTF-8. It also provides `.absolute()` and
`.relative()` methods for templates that need to choose between
absolute paths and paths relative to the command's current working
directory.

`json()` uses the existing `PathBuf` serialization behavior. This keeps
common UTF-8 paths as ordinary JSON strings, while non-UTF-8 paths
produce the same serialization error as `PathBuf`.

Pass the command's current working directory through template languages
so `.relative()` is evaluated against the directory the command is
acting from, not `std::env::current_dir()`.

`Option<FsPath>` follows the existing optional-value truthiness
pattern: unset values are false, and set values are true.
2026-07-13 00:45:14 +00:00
Joseph Lou
d6c4fa8b21 logging: Add trailing periods in log messages
Removed some in #9804, but a decision was made to prefer trailing
periods instead of not having them. Updated the style guide to reflect
this decision.

Did a search for `writeln!` and checked that each one ended with a
period or was printing some interpolated value. `Err()` and
`tx.finish()` calls were left alone.
2026-07-11 13:59:46 +00:00
Remo Senekowitsch
af0521cfd0 cli: resolve default command during alias resolution
Some users accidentally type jj multiple times, which causes an error.
One solution in use is to define an alias `jj = []`, which makes the
command `jj jj ...` work as if jj was typed only once. However, typing
only `jj jj` didn't work. It still caused an error, instead of using
the default command like `jj`. This is because the default command was
resolved before any aliases. By resolving the default command during the
alias-resolution loop, the above example works as intended.
2026-07-11 08:35:50 +00:00
Joseph Lou
badd1643c7 logging: Remove trailing periods in some log messages
Noticed this when I did a `jj git fetch` and got:

```
Updated 10 rewritten commits.
Rebased 1 descendant commits
```

Basically did a regex search for `commits\."`, so I might have missed
messages with different formats.
2026-07-11 04:02:29 +00:00
TogarashiPepper
e49fc32ea0 cli: make print_large_file_hint use shell_quote helper 2026-07-10 23:24:44 +00:00
TogarashiPepper
8ef966f4da git init: use shlex::try_quote on remote names in bookmark hints
Fixes an issue where remote names with special characters like 'foo@bar' couldn't be properly added as bookmarks using the hints. Escaping the names using shlex::try_quote fixes it.
2026-07-10 23:24:44 +00:00
Caleb White
cc95c8759a remotes: suppress spurious trunk() warning
When renaming or removing a remote that the trunk() alias references,
finish_transaction() would warn about the broken alias because the
in-memory revset alias still pointed to the old remote name. The config
file was only updated after the transaction finished.

Fix this by:
1. Moving the repo config update (rename_remote_in_repo_config /
   remove_remote_from_repo_config) to before tx.finish(), so the
   persistent trunk() alias is fixed before the next command loads it.
2. Removing the trunk() resolution check from finish_transaction()
   entirely — the workspace_helper() check at command startup already
   covers broken trunk() aliases.
2026-07-09 18:37:33 +00:00
Remo Senekowitsch
e81ddd5a7d cli: fix false-positives in recursive alias detection
The previous recursion detection simply checked for repeated alias
expansions. This is simple and incorrect only in rare cases, where
repeated alias expansion is desired.

Intuitively, `aliases.jj = []` should be able to solve the "jj jj jj"
problem, where users accidentally type "jj" multiple times (rarely, but
sometimes, more than twice). Blocking repeated alias expansion prevents
the empty alias from being a general solution to that problem.

For non-empty aliases, a possible use case could be to compose
configuration overrides on the command line using the `--config` flag,
but using aliases to make it convenient to type spontaneously.
2026-07-04 14:58:12 +00:00
Remo Senekowitsch
12c420a44f cli: refactor resolve_aliases to reduce nesting 2026-07-04 13:30:55 +00:00
Yuya Nishihara
d9d98b4cf9 rewrite: don't rebase immutable descendants of rewritten revisions
Commands like "jj git fetch"/"import" can update immutable commits to reflect
the remote changes. When this happens, we should avoid rebasing their immutable
descendants.

I also updated the doc comment for transform_commits(), which already supports
disconnected ranges. Because find_descendants_for_rebase() excludes commits
within parent_mappings, the graph isn't always connected (without this patch).

The new changelog entry also covers the changes from 44146561 "git: look for
predecessors also in locally reachable commits".
2026-06-29 10:09:50 +00:00
Yuya Nishihara
163fb32b0b cli: move rebase_descendants() to finish_transaction() callers
While repeated rebase_descendants() calls should be noop, it seems slightly
better to do rebase_descendants() once.
2026-06-29 10:09:50 +00:00
Benjamin Tan
60c42fd9db cli: fix typo 2026-06-15 02:08:11 +00:00
figsoda
eef08f23cf cli: look for config files in /etc/jj
Allows users to set up system-wide config files, for e.g. multi-user setups,
which has lower precedence than per-user config files, unlike $JJ_CONFIG or
--config-file.

closes jj-vcs#7321
2026-06-13 14:01:38 +00:00
Yuya Nishihara
4211b00f9f cli: bookmark: add proper support for track/untrack by <name>@<remote> syntax
While it's a bit odd that the glob pattern and exact remote symbol arguments are
overloaded, the symbol syntax is undeniably convenient.

`RemoteBookmarkNamePattern` and `Display for StringPattern` have been removed as
they are no longer used.

Closes #9226
Closes #9426
2026-06-12 13:27:27 +00:00
Yuya Nishihara
7d16343025 cli: print uncommitted snapshot and reset-head operations
Fixes #9534
2026-06-11 14:42:38 +00:00
Yuya Nishihara
5698985957 revset: remove deprecated ui.revsets-use-glob-by-default flag 2026-06-11 14:42:30 +00:00
Yuya Nishihara
36f4f09be4 cli: create mutable working-copy commit only when needed
This will probably work better when the immutable set is defined by the current
working copy.

Closes #7751
Closes #9338
2026-06-07 03:55:41 +00:00
Yuya Nishihara
705f639e93 cli: extract resolve_immutable_expression(), replace callers of find_*()
It should be better to resolve the expression once and reuse the result.
2026-06-07 03:55:41 +00:00
Niko Savola
60b21fda8d dsl: add description support to AliasesMap
Allows AliasesMap to store and retrieve optional descriptions for each
alias. This is a prerequisite for surfacing these descriptions in
shell completions.
2026-05-11 11:43:22 +00:00
Martin von Zweigbergk
9b9656d06d cli_util: make workspace_helper*() async 2026-05-07 12:38:45 +00:00
Martin von Zweigbergk
609b2eb286 cli: use get_commit_async() + try_join_all() in a few more places 2026-05-04 14:00:31 +00:00
Martin von Zweigbergk
22b04970fb working_copy: make start_mutation() async
This method may reasonably need to do slow I/O, and the implementation
for Google's VFS indeed does that, so it should be async.
2026-05-04 14:00:31 +00:00
Martin von Zweigbergk
fd2fcad680 cli_util: make unchecked_start_working_copy_mutation() async 2026-05-04 14:00:31 +00:00
Martin von Zweigbergk
7ade7fcb75 cli: use get_commit_async() in more places where trivial 2026-05-03 05:31:57 +00:00
Martin von Zweigbergk
6ac9cf7a30 cli_util: make LogContentFormat::write() take async closure
Some of these closures read from the commit backend (and maybe other
places), so they should be async.
2026-05-03 05:31:57 +00:00
Yuya Nishihara
b07d48c5cf gitignore: use RepoPath to guarantee that path is slash-separated
Since our GitIgnoreFile is a thin wrapper type, we wouldn't have to support
random string inputs.
2026-04-13 00:43:53 +00:00
Yuya Nishihara
85461a2eec cli: git-push: add --tag=NAME flag, push tracked tags
The new flag --tag=NAME tracks and pushes new tags in the same way as
--bookmark. Other flags are also updated to include tags, but there are a few
exceptions:

* --all doesn't track and push new tags. Since remote tags are still
  experimental, creation of new tracked remote tags should be explicit.
* -rREVSET doesn't push tracked tags yet because there would be non-trivial
  implementation changes. This will be addressed separately.
2026-04-09 01:14:15 +00:00
Martin von Zweigbergk
c38d69ee00 templater: deprecate Operation.tags() in favor of .attributes()
As we have discussed in at least
https://github.com/jj-vcs/jj/pull/8148, the name `.tags()` is not a
good name because it can be assumed to be related to the usual kind of
VCS tags.
2026-04-07 05:17:34 +00:00
Sebastian Barfurth
76bb6bf401 fix: prevent write to disk when operation should not be integrated
Small follow-up fix from #8882 that prevents an incorrect write to disk using
`finish` when importing git HEAD and `--no-integrate-operation` is set.
2026-04-03 13:28:52 +00:00
Sebastian Barfurth
90cf756e6e cli: add global option to not commit transaction
This patch adds a global `--no-integrate-operation` flag that prevents
integration/publishing of most operations, including the ones created by
`snapshot_working_copy()` and `finish_transaction()`. The operations
are still created as usual.

We provide `jj op integrate` to manually reintegrate operations created by
commands with this flag enabled.

Closes #2562

Co-authored-by: Martin von Zweigbergk <martinvonz@google.com>
2026-04-02 18:36:15 +00:00
Ben Warren
5342585f79 op restore: warn if user restores to an operation where the current workspace no longer exists
- Fixed [issue #8153](https://github.com/jj-vcs/jj/issues/8153)
2026-03-25 04:44:20 +00:00
Martin von Zweigbergk
6ef9b28556 op_store: record workspace where operation was run
There are two reasons for this:

 * It helps understanding why divergence happened to see which
   workspace an operation was run from. For example, perhaps an agent
   is running in another workspace and it's not obvious from the
   operation log which commands it ran without seeing the workspace
   name.

 * We may want to check that e.g. `jj undo` is run from the same
   workspace as the operation it's undoing. We may want to print a
   warning otherwise, or maybe we want to skip over operations create
   from other workspaces. I'm not sure what's best but having the
   workspace recorded at least enables such features.
2026-03-24 05:27:00 +00:00