Commit graph

2972 commits

Author SHA1 Message Date
Gaëtan Lehmann
8a9c356f5e touch: add an option to generate a new change-id 2025-08-14 17:36:20 +00:00
Gaëtan Lehmann
8bc11f272c touch: add options to modify author and author timestamp 2025-08-14 17:36:20 +00:00
Gaëtan Lehmann
de74f88cfc touch: a command to modify some revision metadata 2025-08-14 17:36:20 +00:00
Yuya Nishihara
01e2a85555 commit_builder: make .generate_new_change_id() not imply commit is duplicated
This will allow us to "touch" change id without duplicating commits.

The caller should also do .generate_new_change_id() to not make commits
divergent. This function could do that automatically, but I'm not sure if that's
good. Alternatively, we can add mut_repo.duplicate_commit(predecessor), but
we'll need to refactor CommitRewriter.
2025-08-14 08:44:32 +00:00
Ian Wrzesinski
c6ccfabf70 diff: Remove unneeded & 2025-08-14 00:52:43 +00:00
Yuya Nishihara
e31069cd3c index: index changed paths by add_commit()
Tests of the indexed contents will be added with the revset engine integration.
We don't have a public interface to get the indexed changed paths right now.
2025-08-11 11:50:39 +00:00
Yuya Nishihara
6bb26d8e73 index: include changed-path index in stats() 2025-08-11 11:50:39 +00:00
Gaëtan Lehmann
2e2127c56b log: add templates to anonymize the output 2025-08-10 19:24:36 +00:00
Gaëtan Lehmann
d526a6f0fd template: add a hash function 2025-08-10 19:24:36 +00:00
Isaac Corbrey
55764e822c cli describe: Clarify short description for --reset-author
The short description for `--reset-author` previously made no mention of
updating the author timestamp as well as the author name and email. This
change adds verbiage to clarify that.
2025-08-10 11:42:43 +00:00
Daniel Luz
5d63b11e39 cli: provide file completion for util exec args
Makes command aliases provide similar completion to the shell's default.
2025-08-10 04:10:46 +00:00
Joaquín Triñanes
a50147c23c docs: fix nested list rendering as top level
While the generated markdown is correct, it was being rendered as a
single list. This might be caused by the `mdx_breakless_lists` plugin
because the issue doesn't happen when the plugin isn't used (that is,
when the list actually has linebreaks above it).
2025-08-10 04:10:35 +00:00
Evan Martin
60a6e9421b cli: make diff --stat show byte counts for binary files
Fixes #6865.
2025-08-09 21:36:04 +00:00
Ilya Grigoriev
3d91d6e21b clippy: auto-fixes of clippy::implicit-clone with latest nightly 2025-08-09 03:44:26 +00:00
Emily
5aa7b4cf7e tests: compute the schema defaults in Rust rather than using jq(1)
This is a simple computation over the JSON structure of the schema,
so it doesn’t need pulling in another programming language and a
dependency on an external C program to interpret it.
2025-08-08 16:19:30 +00:00
Emily
311299bab5 tests: use jsonschema directly instead of taplo(1)
This removes an external tool dependency, skips the complexities
of subprocessing, and avoids having to poke a hole in the macOS
Nix sandbox because of `reqwest` trying to read the system’s TLS
configuration.

Note that despite the `Cargo.lock` getting bigger, this is actually a
net reduction of dependencies, as Taplo is written in Rust and pulls
in not only `jsonschema` but much more besides.
2025-08-08 16:19:30 +00:00
Ivan Petkov
dc5056ac91 cli: git clone: support --fetch-tags 2025-08-08 15:44:22 +00:00
Ivan Petkov
144e2c9c63 cli: git remote add: support --fetch-tags 2025-08-08 15:44:22 +00:00
Ivan Petkov
bf974d6911 git: support specifying tag fetch behavior when adding a remote 2025-08-08 15:44:22 +00:00
Austin Seipp
afb1c1446d git: add git.colocate to colocate repos by default
Most users colocate all of their repositories or none of them. A config
option is more convenient in that situation.

There are also plans to make colocated repos the default. This change
paves the way to flip the default easily.

Closes #2507.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2025-08-08 07:08:46 +00:00
Yuya Nishihara
8435ebaa9c cli: file show: add templating support
The primary use case is to insert header/separator when printing multiple file
entries.

"jj file show" accepts the same template argument as "jj file list", and file
content is not included in the template. This is basically the same as the
relation between "jj show" and "jj log".

Closes #7181
2025-08-07 14:52:02 +00:00
Clément
7efb529add rebase: improve error messages when rebasing a change onto itself
The `-r` flag triggered a warning different from the `-s` one, while
being more explicit ("Cannot rebase 0000000 onto descendant 0000000" ->
"Cannot rebase 0000000 onto itself")
2025-08-07 08:37:31 +00:00
Martin von Zweigbergk
c4fefdb03f cli: add debug commands for printing commits, operations, etc.
This should be useful when debugging people's repos. For example, I've
sometimes wondered how many sides the top-level tree conflict has.

I made the new command support operations and views too, mostly for
consistency. That makes `jj debug operation` quite redundant. However,
that command is a bit higher-level and may still be useful. I don't
see much reason to delete it.
2025-08-06 15:02:23 +00:00
Martin von Zweigbergk
3a7ce87f44 rewrite: make duplicate_commits() async 2025-08-06 03:12:05 +00:00
Martin von Zweigbergk
073a1dea74 rewrite: make CommitRewriter::rebase() async 2025-08-06 03:12:05 +00:00
Martin von Zweigbergk
82d7182ef7 repo: take async callback to transform_descendants()
Maybe we can make `transform_descendants()` transform siblings
concurrently later.
2025-08-06 03:12:05 +00:00
Stephen Jennings
3ad854f975 fix: add $root variable that can be used in commands
On Windows, spawning a child process finds the command relative to the
parent's working directory. If a command is specified as
`["path/inside/repo/tool.exe"]`, then tool won't be found if `jj fix` is
run from a subdirectory of the workspace.

There doesn't seem to be a good way to change this behavior, nor does it
seem easy to convert `program` into an absolute path because
`["tool.exe"]` could refer either to a file on the PATH or a file
committed at the root of the repository.

So, we add a new variable `$root` that can be used in this situation.
Workspace-relative tools on Windows should be defined using this
variable:

```toml
# Tools on the PATH
command = ["tool.exe"]

# Workspace-relative tools
command = ["$root/tool.exe"]
command = ["$root/nested/dir/tool.exe"]
```

On Unix, the command is found relative to the working directory of the
child process, so this isn't an issue.

Fixes #7144
2025-08-05 14:37:04 +00:00
Daniel Luz
436e8bbbdd cli: restore: adjust error message for --revision
We've had a few occurrences of people asking for `jj restore -r`,
as an analogous to `jj squash -r`, when the error message should already
be telling them to try `--changes-in`. This suggests that the message
is not being read, perhaps because it's too long, and the suggestions
get lost in the noise. This is an attempt to improve its readability.

- Reduce the error part of the message to its essence
- Label the hints that are presented as such
- Remove mention of `--into` for brevity, as it doesn't seem to be a
  common interpretation of `-r`
2025-08-04 23:46:56 +00:00
Yuya Nishihara
13a2bbe1b8 graph: add GraphEdge::is_<edge_type>() for convenience 2025-08-04 11:20:49 +00:00
Scott Taylor
c5b0b0b68f revset: insert HeadsRange in Ancestors for nested range/filter
This allows evaluating ancestors/ranges involving filters significantly
faster. For instance, naively evaluating `::mine()` requires reading
every commit in the repo to check `mine()` on each commit, then finding
the ancestors of that set. This optimization rewrites `::mine()` to
`::heads(mine())`, since `heads(mine())` can be evaluated more
efficiently by only reading commits until the first successful match.

If someone is unaware of how revsets are implemented, this case can come
up pretty easily, such as by including `~mine()` in `immutable_heads()`
to make other people's commits immutable. In my local `jj` repo, this
optimization reduces the runtime of `jj log` with `~mine()` in
`immutable_heads()` from about 800ms down to about 50ms.

Benchmark results on Git repo:

```
::(v1.0.0..v2.40.0)     55.5% faster
author(peff)..          96.8% faster
```
2025-08-02 01:40:23 +00:00
Yuya Nishihara
abd7f43507 templater: add commit.files() function to list existing files
I think this can be useful in CLI tests. I noticed there are lots of "jj file
list" calls in https://github.com/jj-vcs/jj/pull/6141 which could be combined
with "jj log" outputs.
2025-08-02 01:30:29 +00:00
Yuya Nishihara
53f85e84e5 index: reimplement stats() to not depend on CompositeCommitIndex abstraction
This will help extend stats() for changed-paths index. Since there are no
non-test callers who need to calculate stats of mutable index, it should be good
to move the implementation to DefaultReadonlyIndex.
2025-08-01 01:12:32 +00:00
Yuya Nishihara
c45bce99e8 cli: op diff: show content diffs from first predecessor only
This is technically wrong because multiple predecessors should be considered
integrated into the rewritten commit, but I don't have a good idea to mitigate
the "squashed" diff problem. In "op diff", content diffs from the first
predecessor is practically useful.

Closes #7090
2025-08-01 01:11:41 +00:00
phoebe
c9aa05de7b ssh-signing: add revocation-list option 2025-07-29 12:46:36 +00:00
Martin von Zweigbergk
377642004f cli: print warning about git clean -fdx when creating colocated repo
We hear every now and then from users who have run `git clean -fdx`
and accidentally delete their repo. Let's at least warn users about it
when the create a colocated repo.

We could perhaps allow the `.jj/` directory to be inside a `.git/`
directory like Sapling does, but that seems a little ugly and it's a
larger change.
2025-07-28 17:18:49 +00:00
Austin Seipp
ba24140f1d cli, lib: move to Rust 2024 language edition
This applies a `cargo fmt` and fixes clippy lints to keep the build
properly working.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2025-07-28 17:05:41 +00:00
Austin Seipp
5595bef26c cli: add unsafe bodies for cleanup_guard code
In Rust 2024, a function declaration marked `unsafe` does NOT implicitly
make the body unsafe. All these unsafe functions also need to be wrapped
in safe blocks now, too.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2025-07-28 17:05:41 +00:00
Pablo Brasero
585a7426f5 everything: ensure consistent spelling of "behavior" 2025-07-28 16:19:31 +00:00
Scott Taylor
e9eb3a0142 git: write empty blob when setting intent to add
Fixes #7062.
2025-07-27 15:13:02 +00:00
adamnemecek
8a26df2897 cli lib: make use of Self consistent
Mostly done via `cargo clippy --fix -- -A clippy::all -W clippy::use_self`. Added a rule to clippy rules.
2025-07-27 00:12:02 +00:00
Martin von Zweigbergk
a054ca9c92 diff: disallow diff of range with incoming merge edges
We could allow merge edges coming into the range of commits but it's
probably a rare use case and it's a bit complicated to implement while
also preserving the parent order. Simply disallowing such cases for
now is better than producing incorrect results.
2025-07-26 18:32:20 +00:00
Martin von Zweigbergk
3423543094 cli: demonstrate bug in jj diff -r with merge into chain 2025-07-26 18:32:20 +00:00
Martin von Zweigbergk
48ac6178ab rewrite: make merge_commit_trees() async
Just another step towards making our code base async.  This
unfortunately results in more `block_on()` calls than we had before.
2025-07-25 17:58:18 +00:00
Martin von Zweigbergk
8022a49d9b merged_tree: make resolve() and merge() async 2025-07-25 17:58:18 +00:00
Yuya Nishihara
451189a5c0 cli: remove remaining users of glob crate
Closes #6919
2025-07-25 08:22:35 +00:00
Yuya Nishihara
182daa1dfa str_util: switch to globset
Since we already have globset in transitive dependencies, this change helps
reduce the amount of dependencies. Another reason is that globset provides a
function to convert glob to regex. This is nice because we use globs to match
against strings or internal repository paths instead of platform-native paths.

The GlobPattern wrapper is boxed because globset::Glob type is relatively big.
2025-07-25 08:22:35 +00:00
Martin von Zweigbergk
191369f06f merged_tree: make merge() take all args by value
This avoids unnecessary cloning. Most of the callers don't need copies
of the trees anyway.
2025-07-24 21:28:40 +00:00
Jade Lovelace
1acd2a04f8 str_util: rename "matches" to "is_match"
This makes it clear that it doesn't give a list of matches.
2025-07-24 04:57:58 +00:00
Jade Lovelace
800b5f8e39 template_builder: stop eating non-TemplateError error sources in tests
I was under the impression that the error sources were not possible to
actually *see* so I was disinclined to use with_source as I couldn't
confirm it worked in my tests, but it turns out that was because of an
unexpectedly incomplete printer in the testing code! (.origin() does not
include third party error origins)
2025-07-23 15:32:11 +00:00
Yuya Nishihara
1471655c83 config: fix migration rule for core.watchman.register-snapshot-trigger
rename_value() isn't supposed to move an entire table.
2025-07-23 13:01:29 +00:00