Commit graph

4385 commits

Author SHA1 Message Date
Yuya Nishihara
a2a5ccf772 working_copy: propagate I/O-related errors 2025-08-27 00:58:24 +00:00
Yuya Nishihara
2d8ca26f15 working_copy: leverage CheckoutState::save() to create initial state file
With this patch, init() would no longer panic when the checkout state already
existed. This should be okay because the caller always create new workspace
directory.
2025-08-27 00:58:24 +00:00
Christian Hufnagel
75f8a0e730 cli touch: add flag for changing author date 2025-08-26 19:02:31 +00:00
Ian Wrzesinski
9d67c47a0c working_copy: Break out CheckoutState load and save functions 2025-08-25 22:40:48 +00:00
Ivan Petkov
72fde508c6 lib: support negative refspecs on git remotes 2025-08-25 15:55:18 +00:00
Ivan Petkov
98ce815699 lib: add representation for a negative git refspec 2025-08-25 15:55:18 +00:00
Ivan Petkov
27d4c80c50 lib: require caller to provide an expanded list of refspecs to fetch 2025-08-25 15:55:18 +00:00
Ivan Petkov
e0ca7c653d lib: refactor git fetch ahead of future updates 2025-08-25 15:55:18 +00:00
Ian Wrzesinski
5f8dd79e8b working_copy: Move TreeState struct definition closer to impl block 2025-08-25 07:01:09 +00:00
Graham Christensen
1b150d12bd test: use a fifo in test_local_working_copy to avoid too-long unix domain sockets on macOS 2025-08-23 13:48:25 +00:00
Graham Christensen
297c434c93 ci: Skip the GPG tests if they cannot pass on macOS 2025-08-23 13:48:25 +00:00
Yuya Nishihara
1b33da4df2 config: remove workaround for implicit inline table insertion
This reverts commit 31d12c9245. The problem should
be fixed by upstream:

> Implicitly treat Tables inside of a Value as an InlineTable, rather than
> skipping them
https://github.com/toml-rs/toml/blob/main/crates/toml_edit/CHANGELOG.md#0230---2025-07-08
2025-08-23 03:46:11 +00:00
Yuya Nishihara
7e80eb4dfa cargo: bump toml_edit to 0.23.3
Also updated deprecated ImDocument references to Document.
2025-08-23 03:46:11 +00:00
Yuya Nishihara
cd673311d0 index: remove forwarding function of CompositeIndex::evaluate_revset()
Since Index is now implemented for CompositeIndex instead of &CompositeIndex,
these two functions have exactly the same signature. We no longer need a
specialized implementation to correct lifetime of the return value.
2025-08-22 00:29:32 +00:00
Yuya Nishihara
425b719045 templater: add CommitEvolutionEntry type
I don't have a strong feeling whether we should add "entry.commit() -> Commit"
method or forward method calls to the Commit object, but this patch implements
the former because:

 a. evolution_entry.diff() should return inter diff, whereas commit.diff()
    doesn't.
 b. auto-labeling works if self.commit() is an explicit method call.
 c. the implementation and documentation can be simple.

Tests will be added by the next patch.
2025-08-21 13:35:21 +00:00
Yuya Nishihara
fe7013b3dc commit: make is_empty() and parent_tree() query index first
This makes "jj log" in merge-heavy repos fast.
2025-08-21 09:38:38 +00:00
Yuya Nishihara
631bf709ec index: add generic interface to query changed paths in commit
Commit::is_empty() and ::parent_tree() will query index first to avoid merging
parent trees.

iirc, the Google backend has an index of changed paths, so I made the added
function return Result although the default index will never fail. I also
considered adding matcher argument, but I don't have any use case right now. I
think the Matcher API would be too abstract to construct a database query. Maybe
we should use Revset/FilesetExpression types for that purpose.
2025-08-21 09:38:38 +00:00
George Christou
7562064739 fileset: simplify glob character detection 2025-08-21 09:29:08 +00:00
Martin von Zweigbergk
2e8d23739d rewrite: make merge_commit_trees_no_resolve_without_repo() non-recursive
We ran into the following error when upgrading to the latest unstable
rustc at Google when compiling our internal commit backend:

```
overflow evaluating the requirement `impl futures::Future<Output = Result<jj_lib::tree::Tree, jj_lib::backend::BackendError>>: Sized`
```

It seems to be some limitation of rustc related to recursion and async
functions but we don't know what exactly it means.

This patch works around that by making the async part of
`merge_commit_trees_no_resolve_without_repo()` non-recursive. There is
still a recursive part, but it's no longer async. The recursive part
now finds all the commit IDs involved. Then we do the lookup of them
afterwards.

We may want to make the remaining recursive part non-recursive as well
so don't run out of stack on a long braid of criss-cross merges, but
that can come later.
2025-08-20 13:58:10 +00:00
Martin von Zweigbergk
353be90e3d rewrite: add test of recursive criss-cross merge resolution
We didn't seem to have a test case of the recursive merge
implementation (no tests failed when I changed it to always use the
first ancestor instead of being recursive).
2025-08-20 13:58:10 +00:00
George Christou
44ab63867d fileset: add case-insensitive glob patterns
Add support for case-insensitive glob patterns in filesets, similar to the
existing glob-i: patterns in revsets.

Resolves #5945
2025-08-20 10:51:51 +00:00
Ian Wrzesinski
2768441d80 working_copy: Factor out new_state function
This constructor is just large enough to be worth extracting.
2025-08-18 10:52:12 +00:00
Ivan Petkov
1df3c5d3b7 lib/git: support temporarily fetching all tags as part of a fetch
By default `git clone` will fetch all tags on a remote (unless
`--no-tags` is specified). Eventually we'll want to support the same
behavior, though since we first configure a remote and then fetch, we'll
need to configure the remote with the correct *general* tag fetching
behavior, but still perform the first fetch with all tags included.
2025-08-17 15:48:36 +00:00
Remo Senekowitsch
36ee36ce78 op: undo: rename to revert
This paves the way for the semantics of `jj undo` and `jj op revert` to
evolve independently. `jj op revert` is going to stay the low-level
command to apply the inverse of any operation. The new name is
consistent with `jj revert`, which applies the inverse of a commit.

`jj undo` on the other hand is planned to become a higher-level command,
which is more similar to, say, Ctrl+Z in typical GUI applications.
Running `jj undo` repeatedly will revert progressively older operations,
allowing the user to walk backwards in time. At the same time, `jj undo`
will lose the abilitly to revert arbitrary operations, to keep its
semantics simple and intuitive.

Related feature request "jj undo ergonomics":
https://github.com/jj-vcs/jj/issues/3700
2025-08-15 21:31:15 +00:00
Yuya Nishihara
2391764ab7 revset: integrate change-path index
The current implementation does linear search, which I think is good assuming
the size of the changed paths set is usually small. The next costly part of "jj
log PATH" is commit.empty() template on merge commits (#5411). We'll need a
public API to query changed-path index to optimize it.
2025-08-15 11:46:49 +00:00
Yuya Nishihara
8999e08d2e index: add function to build changed-path index at certain operation 2025-08-15 11:46:49 +00:00
Gaëtan Lehmann
db0e43608d lib: rename mut_repo() to repo_mut() in the rewriter
to be consistent with repo_mut() in the transaction.
2025-08-15 09:15:35 +00:00
Martin von Zweigbergk
05a74963cd protos: rename op_store to simple_op_store
Similar to the previous commit, `op_store` is specific to
`SimpleOpStore`, so its name should match that.
2025-08-14 14:15:17 +00:00
Martin von Zweigbergk
e13a8649f3 protos: rename working_copy to local_working_copy
The `working_copy` proto is specific to `LocalWorkingCopy`, so I think
it should match that name.
2025-08-14 14:15:17 +00:00
Yuya Nishihara
ad14c7bcc0 index: concatenate changed-path index on merge_in()
The logic is different from MutableCommitIndexSegment::merge_in() because we
need to deduplicate changed-path entries based on the commit entries.
2025-08-14 08:44:55 +00:00
Yuya Nishihara
a2155dcc95 index: squash changed-path segments before saving
The logic is the same as MutableCommitIndexSegment.
2025-08-14 08:44:55 +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
1255eb6143 working_copy: Remove expect(dead_code) by adding underscore to field name 2025-08-14 05:29:12 +00:00
Martin von Zweigbergk
823f4fccb4 PathError: rename error field to source
`source` seems to be the more idiomatic name for the error source.
2025-08-13 17:45:52 +00:00
Kaiyi Li
f8eeed2b67 eol conversion: treat files with lone CRs as binary
When checking whether a file is binary, we check if the file exists a CR
character that isn't followed by a LF character. If so, we consider this
file as binary and don't apply EOL conversion unconditionally.

This commit is related to #7010.
2025-08-12 18:00:10 +00:00
Ilya Grigoriev
9aeed9a39d clippy: run autofix to use Self more often
For some reason, running `cargo update` makes clippy notice these can
be replaced with `Self`. I put this commit first, though, since it is
helpful regardless of the update.

This is the result of the following command after the `cargo update`
from the next commit (even though the refactor is valid regardless of
the `cargo update`).

```
cargo +nightly clippy  --workspace --all-targets --all-features --fix
```
2025-08-12 09:47:39 +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
Yuya Nishihara
132d74a234 index: read/write changed-path index segments 2025-08-11 11:50:39 +00:00
Yuya Nishihara
3902d88b3e index: migrate operation link file to protobuf
I'm going to add changed-path index, and the operation link file will store a
list of segment files and a starting commit position. Suppose the link file is
small, we wouldn't need our own serialization format.

This patch adds new directory for proto-based operation link files. We could
reuse the existing directory, but that would make debugging a bit harder.
2025-08-11 11:50:39 +00:00
Yuya Nishihara
3f0126191d index: don't use persist_content_addressed_temp_file() to write operation link
A link file isn't addressed by its content but by the associated operation id.
There's no guarantee that the stored content never changes.
2025-08-11 11:50:39 +00:00
Ilya Grigoriev
3d91d6e21b clippy: auto-fixes of clippy::implicit-clone with latest nightly 2025-08-09 03:44:26 +00:00
Ivan Petkov
bf974d6911 git: support specifying tag fetch behavior when adding a remote 2025-08-08 15:44:22 +00:00
Ivan Petkov
c3574f99f1 lib/git: treat tagOpt as a standard option
In a future commit we'll add support for controlling a git remote's tag
fetch behavior, which may result in a `tagOpt = --[no-]tags` entry in
the remote configuration.

Doing this change here means we will avoid incorrectly flagging remote
configurations as unsupported.
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
36134a5f96 index: ensure that bit set panics on integer underflow
We'll get out-of-bounds read error later, but the panic message would be a bit
difficult to reason about.
2025-08-07 14:46:08 +00:00
Yuya Nishihara
331bd4e859 revset_graph: fix out-of-bounds bit set lookup in remove_transitive_edges()
The problem was spotted by Martin. Since we've made remove_transitive_edges()
omit "missing" edges from the set of nodes to visit at ad7c42e04b
"revset_graph: ignore missing edges thoroughly in remove_transitive_edges()", we
should also skip them in the input set.

This patch updates all test cases to run at bit-set boundary to detect other
potential issues.
2025-08-07 14:46:08 +00:00
Yuya Nishihara
1edcd79af7 index: add data structure for changed-path index
This patch implements data format, serialization, and deserialization. Actual
indexing functions and disk I/O will be added later.

The data format is simple. It's basically a sorted table of paths + pointers to
the table entries per commit. Git employs Bloom filter for this purpose, but I
don't think we need a probabilistic data structure. The size of the serialized
index segments isn't big compared to the commit index segments, and the lookup
performance seems good. It's also important that we don't need to merge parent
trees when a path matches the indexed changed paths.

With git repo (77410 commits):
- changed-path segment file size: ~1.1MB
- jj log --ignore-working-copy README.md: ~0.2sec wall

Indexing takes minutes. That's not surprising because we have to merge parent
trees to get diffs.

#4674
2025-08-07 02:04:23 +00:00
Nigthknight
ad5a4b3172 copy-tracking: fix path tracking for nested directories with equal names
The problem was that the calculation of the suffix was overlapping into
the the prefix for nested directories with the same name. We skipped the
prefix to avoid this issue.

Issue: #6853

Co-authored-by: Tobias Markus <tobias@miglix.eu>
2025-08-06 06:14:57 +00:00
Martin von Zweigbergk
3a7ce87f44 rewrite: make duplicate_commits() async 2025-08-06 03:12:05 +00:00