Commit graph

1370 commits

Author SHA1 Message Date
Yuya Nishihara
402bbeae6d cargo: bump gix to v0.76.0
Some checks failed
binaries / Build binary artifacts (push) Has been cancelled
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CommitRef now stores raw author/committer headers and parses them when needed.
Since parsing errors would have been detected at .try_to_commit_ref(), this
patch makes new decode errors propagate as before.

Fixes #8350, #8214
2025-12-23 05:31:49 +00:00
Scott Taylor
2ce2a445b0 conflicts: show "noeol" state separately for each side of a diff
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Now that we can put the "from" and "to" sides on separate lines, we can
use the normal "(no terminating newline)" comment on each side
separately. This should also be more clear, since previously the
"(no terminating newline)" comment could possibly be confused for
"(removes terminating newline)".

Before:

```
<<<<<<< conflict 1 of 1
+++++++ rtsqusxu 2768b0b9 "commit A" (no terminating newline)
grapefruit
%%%%%%% diff from: vpxusssl 38d49363 "merge base"
\\\\\\\        to: ysrnknol 7a20f389 "commit B" (adds terminating newline)
-grape
+grape
>>>>>>> conflict 1 of 1 ends
```

After:

```
<<<<<<< conflict 1 of 1
+++++++ rtsqusxu 2768b0b9 "commit A" (no terminating newline)
grapefruit
%%%%%%% diff from: vpxusssl 38d49363 "merge base" (no terminating newline)
\\\\\\\        to: ysrnknol 7a20f389 "commit B"
-grape
+grape
>>>>>>> conflict 1 of 1 ends
```
2025-12-20 17:43:41 +00:00
Scott Taylor
242e2f8ccb conflicts: materialize conflict labels if present
Since conflict labels are generally going to be long, this introduces a
new "note" conflict marker (`\\\\\\\`), which can be used to split the
"diff" conflict marker (`%%%%%%%`) across two lines:

```
<<<<<<< conflict 1 of 1
%%%%%%% diff from: vpxusssl 38d49363 "description of base"
\\\\\\\        to: rtsqusxu 2768b0b9 "description of left"
-base
+left
+++++++ ysrnknol 7a20f389 "description of right"
right
>>>>>>> conflict 1 of 1 ends
```
2025-12-20 04:03:57 +00:00
Scott Taylor
ba73442b2a conflicts: update conflict marker format
Conflict labels will generally start with lowercase change IDs, so
making all of the text lowercase makes it more consistent. I also
removed the "contents of" text, since conflict labels will already be
long enough, and this text doesn't add anything. Similarly, I removed
the "(conflict 1 of 1)" note from the Git conflict markers since Git
doesn't include this information, and including it would result in extra
long lines once we add conflict labels.
2025-12-20 04:03:57 +00:00
Thomas Castiglione
66d04235c6 watchman: don't start a new tokio runtime if there already is one
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
LockedWorkingCopy::snapshot() is already async, so this is just a matter of changing TreeState::snapshot() and making the runtime conditional
2025-12-17 17:31:07 +00:00
Yuya Nishihara
3f6c2c1e2e stacked_table: add gc() function to prune unreachable table segments
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
This is an easy part of Git extra table GC. The implementation is quite similar
to SimpleOpStore::gc(). Since we don't delete unreachable "commit" entries from
the table segments, this wouldn't improve runtime performance. Directory lookup
might get slightly faster thanks to fewer file entries, though.

#12, #8312
2025-12-17 10:38:11 +00:00
Scott Taylor
1fb5a9656b command_error: use offset in hint for divergent changes
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
It's usually going to be easier for a user to run the same command again
but with a change offset appended, so I think these are more helpful
than commit IDs.
2025-12-16 02:02:31 +00:00
Scott Taylor
5df15f60c6 revset: parse change IDs with offset like xyz/2 2025-12-16 02:02:31 +00:00
Scott Taylor
7fd50edc65 index: add ResolvedChangeTargets to return all commits with change ID
I'm going to add a way to select a specific commit from the set of
commits with a given change ID. We could sort these by committer
timestamp or something else, but index position is convenient because it
doesn't require reading the commits. The exact order isn't too
important, but giving newer commits lower offset numbers is nice because
newer commits are used more frequently.
2025-12-16 02:02:31 +00:00
Yuya Nishihara
97375fa041 revset: enable glob string matching by default
Follows up c93682f2 "revset: parameterize default string pattern kind, add
config knob".
2025-12-15 04:27:32 +00:00
Yuya Nishihara
fa142f7c3e git: peel old tags when exporting refs
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
move_git_ref() has to do .reference() twice because we don't know oid of the old
tag object. Other than that, the change is straightforward.
2025-12-12 10:00:38 +00:00
Yuya Nishihara
0efe1e838c tests: include annotated tags, creation, deletion in git::export_refs() test
git::export_refs() fails to update annotated tags right now.
2025-12-12 10:00:38 +00:00
Scott Taylor
9b9bdd009d conflicts: propagate conflict labels down to materialization functions
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
2025-12-12 04:29:59 +00:00
Scott Taylor
78bfda9d1b local_working_copy: re-materialize conflicts if labels changed 2025-12-12 04:29:59 +00:00
Scott Taylor
34c471af3f merged_tree: add conflicts_matching() method 2025-12-12 04:29:59 +00:00
xtqqczze
7c89dc3d23 refactor: remove non-binding let
Follow-up https://github.com/jj-vcs/jj/pull/8271
2025-12-11 19:16:16 +00:00
xtqqczze
82865b61e6 rustc_lint: enable let_underscore_drop lint
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#let-underscore-drop
2025-12-11 13:52:14 +00:00
Scott Taylor
4861b88a06 tests: use assert_tree_eq! in more places
I think this is simpler and it should give better error messages.
2025-12-11 13:00:31 +00:00
Yuya Nishihara
b19c4207f5 git: extract GitImportOptions, remove remote settings from GitSettings
The auto-tracking-bookmarks settings will be parsed as string matcher
expressions. Since it isn't trivial to parse string expressions, the [remotes]
table should be loaded only when needed.

New GitImportOptions type has no from_settings() constructor. That's mainly
because parsing function can potentially emit warnings, and these warnings will
have to be printed.
2025-12-10 11:23:58 +00:00
Lukas Krejci
c24c035041 cli,lib: add suport for the push URL in git remote add 2025-12-10 09:15:06 +00:00
Lukas Krejci
f434b9f11e cli,lib: add support for git remote set-url (--fetch|--push) 2025-12-10 09:15:06 +00:00
Scott Taylor
b2f6836357 git_backend: store conflict labels in commit header
Conflict labels are stored in a separate header for backwards
compatibility.
2025-12-09 14:23:43 +00:00
Scott Taylor
2e18f59bc9 backend: add conflict labels to Commit 2025-12-09 14:23:43 +00:00
Scott Taylor
88f8fbadfc merged_tree: allow passing labels to MergedTree::merge
The old method is renamed to `MergedTree::merge_unlabeled` to make it
easy to find unmigrated callers. The goal is that almost all callers
will eventually use `MergedTree::merge` to add labels, unless the
resulting tree is never visible to the user.
2025-12-09 14:23:43 +00:00
Scott Taylor
2e6cb9af4c merged_tree: retain conflict labels in MergedTree::resolve
To implement simplification of conflict labels, I decided to add more
functions such as `zip` and `unzip` to `Merge`. I think these functions
could be useful in other situations so I thought this was a nice
solution, but an alternative solution could be to make
`get_simplified_mapping` and `apply_simplified_mapping` public and
manually apply the same mapping to both merges.
2025-12-09 14:23:43 +00:00
Scott Taylor
d4668bf3fc merged_tree: add conflict labels to MergedTree 2025-12-09 14:23:43 +00:00
Yuya Nishihara
27441156ac tests: reduce use of auto-tracking in test_git.rs
We should enable non-default options only when they matter.
2025-12-08 23:55:52 +00:00
Kaiyi Li
eb1f72a0c9 file_util: fix broken symlink on Windows
... due to using incorrect separators.

Fix #8185.
2025-12-05 03:43:34 +00:00
Ian Wrzesinski
b8cfd972ed lib/tests: Add basic executable bit tests on Unix 2025-12-04 17:32:40 +00:00
Yuya Nishihara
36143b093e git: add native support for negative fetch patterns
The default patterns are still saved to and loaded from .git/config. Maybe we
can add default fetch patterns to jj's configuration, but I'm not sure whether
we should deprecate .git/config fallback.
2025-12-03 08:12:58 +00:00
Yuya Nishihara
8615362689 git: compile both positive/negative branch patterns to StringMatcher
I also renamed "branch" to "bookmark" because we call refs as "bookmark"s where
the matcher is used.
2025-12-03 07:32:25 +00:00
Yuya Nishihara
1d897341cc git: parse negative refspecs to branch patterns
We'll need negative patterns to exclude them when importing remote refs from Git
repository.
2025-12-03 07:32:25 +00:00
Matt Stark
668a034e08 working-copy: Ensure sub-repos are not tracked.
If a submodule was created in a commit C on a remote repo, switching from any
commit after C to any commit before C (eg. `jj new C-`) will result in jj
starting to track the files introduced in the submodule.

This issue has popped up very frequently for chromium developers, who
get issues when attempting to check out an older version of chromium.

Fixes #4349
2025-12-02 23:20:34 +00:00
Mitchell Skaggs
2af8bf94a3 testutils: add check for strict UTF-8 filesystems
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
`test_init_load_non_utf8_path` and
`test_init_additional_workspace_non_utf8_path` now early-return on
strict UTF-8 filesystems because there's no way to report a test as
"skipped" at runtime.

Closes https://github.com/jj-vcs/jj/issues/8118
2025-11-27 00:36:39 +00:00
Lander Brandt
7e42895b59 lib: substantially reduce syscalls when attempting to create dirs
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
After filing https://github.com/jj-vcs/jj/issues/7685 I ran some perf traces to try to understand just what was taking so long during these slow operations. The changes in this PR reduces clone time for my large repo from about 10 minutes to 4m30s.

You can see my thought process in the comments of the above task but to summarize:

During checkout we check files/directories being created to ensure that we are not attempting to write to a reserved directory (`.jj/`, `.git/`). `same_file::is_same_file()` is an expensive check that invokes _at least 4_ syscalls when called in a naive manner (`open()` and `close()` for each path -- plus possibly more for getting file info? I haven't counted).

There are a few optimization gaps here that are causing significant slowdowns. The following checklist reflects what I've optimized in this PR, and what still remains:

- [x] `create_parent_dirs` will be called for each file/directory and for each parent dir in a path **try to create it and check if the dir is an illegal name via `reject_reserved_existing_path()`**. There is no caching of directories which have already been created.
- [ ] `reject_reserved_existing` calls `same_file::is_same_file()` in a loop for all reserved names, but the path which _has maybe been created_ isn't going to change, so its handle could be cached.
- [ ] `can_create_new_file` attempts to create the file then just uses the result as an indicator of whether or not the file is created. However, since we _have a `File`_ that `File` can be directly converted to a `same_file::Handle` and avoid a syscall that currently occurs when converting the `Path` to a `same_file::Handle`.
- [ ] `can_create_new_file` deletes the file immediately after. There's probably an opportunity here to **not** delete the file and re-use it for file write operations.
- [ ] Say we have 1000 files in `foo/`. For each file that's written, `reject_reserved_existing` is going to make at least `RESERVED_DIR_NAMES.len() * 1000` syscalls constructing `foo/{reserved_dir_name}` paths, testing their existence, etc. Maybe `jj` might create this dir? But I don't think that should ever happen -- so why not cache the handle **if** it's created and use a lookup table in `reject_reserved_existing` to only conduct these types of checks if the handle is resolved? Or alternatively cache that the file _does not_ exist after the first check.

Here are some perf traces of running a `jj git clone` of my large repo before:

Release: https://share.firefox.dev/4oiSTBw
Debug: https://share.firefox.dev/4qmJBX1

And after:

Release: https://share.firefox.dev/4nK66mH
Debug: https://share.firefox.dev/470W1ed
2025-11-26 02:30:31 +00:00
Yuya Nishihara
c93682f218 revset: parameterize default string pattern kind, add config knob
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Glob patterns will be enabled by default globally. Since this will be a big
breaking change in revsets, this patch adds a config knob to turn the new
default on/off.
2025-11-24 01:39:32 +00:00
Yuya Nishihara
3b37ed102e tests: specify string pattern prefix, use subject(glob:_) accordingly
Deprecation warnings will be emitted for default "substring:" patterns. This
change will suppress them. Since "glob:" will be the new default, I made these
tests use "glob:" when both "exact:" and "glob:" work.

Tests for the revset filter functions aren't updated.
2025-11-24 01:39:32 +00:00
Yuya Nishihara
4d296a7f9f str_util: map glob pattern with no meta character to exact pattern
Suppose the default is changed to "glob:", literal strings would be parsed by
glob() function. It's still better to treat trivial strings as "exact" patterns.

str_util::is_glob_char() includes backslash unconditionally because we enable
backslash escapes in string patterns.
2025-11-24 01:39:32 +00:00
Yuya Nishihara
a7a4ed033a git: move GitSettings out of settings module
This type wouldn't be needed if the "git" feature is disabled.
2025-11-21 15:04:09 +00:00
Remo Senekowitsch
e4d45dda34 tests: replace auto-local-bookmark with auto-track-bookmarks
This paves the way to deprecate `git.auto-local-bookmark` without
adding lots of deprecation warnings to test output snapshots.

The behavior of some tests is slightly changed, because
auto-track-bookmarks also tracks bookmarks that were created locally.
I think it just shows up in output snapshots as absent-tracked
bookmarks, without affecting what the test is about.
2025-11-21 05:15:55 +00:00
Scott Taylor
da1921ead5 testutils: dump_tree: print contents of conflicted trees
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Previously, `assert_tree_eq!` would give a confusing panic message if
one of the trees had a conflict.
2025-11-09 17:48:25 +00:00
Scott Taylor
5aa71d59a9 lib: replace MergedTreeId with MergedTree and Merge<TreeId>
After the previous commit, `MergedTree` and `MergedTreeId` are almost
identical, with the only difference being that `MergedTree` is attached
to a `Store` instance. `MergedTreeId` is also equivalent to
`Merge<TreeId>`, since it is just a wrapper around it.

In the future, `MergedTree` might contain additional metadata like
conflict labels. Therefore, I replaced `MergedTreeId` with `MergedTree`
wherever I think it would be required to pass this additional metadata,
or where the additional methods provided by `MergedTree` would be
useful. In any remaining places, I replaced it with `Merge<TreeId>`.

I also renamed some of the `tree_id()` methods to `tree_ids()` for
consistency, since now they return a merge of individual tree IDs
instead of a single "merged tree ID". Similarly, `MergedTree` no longer
has an `id()` method, since tree IDs won't fully identify a `MergedTree`
once it contains additional metadata.
2025-11-08 14:06:58 +00:00
Scott Taylor
79fc20e856 merged_tree: use Merge<TreeId> instead of Merge<Tree>
Currently, creating a `MergedTree` requires reading all of its root
trees from the store. However, this is often not actually required. For
instance, if the only reason to read the trees is to call
`MergedTree::merge`, and the merge is trivial, then there was no need to
read the trees. Changing `MergedTree` to only require a `Merge<TreeId>`
instead of a `Merge<Tree>` will make it possible to avoid reading trees
unnecessarily in these cases.

One benefit of this approach is that `Commit::tree` no longer requires
reading from the store, so it can be made synchronous and infallible,
which simplifies a lot of code.
2025-11-08 14:06:58 +00:00
Scott Taylor
f08e50a21f conflicts: add "diff-experimental" conflict marker style
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
#7917
2025-11-05 00:00:58 +00:00
Martin von Zweigbergk
b409aa3189 colocation: rename from "colocated repo" to "colocated workspace"
Colocation is about sharing the working copy between jj and git. It's
less important where the repo is stored. I therefore think we should
not call it "colocated repo". I considered renaming it to "colocated
working copy" but that sounded awkward in many places because we often
talk about the whole workspace (repo + working copy), so "In colocated
workspaces with a very large number of branches or other refs" sounds
better than "In colocated working copies with a very large number of
branches or other refs".

Once we support colocate workspaces in non-main Git worktrees, I think
this rename will be even more relevant because then all those
workspaces share the same repo but only some of them may be colocated.
2025-11-03 16:53:26 +00:00
Yuya Nishihara
d6b5530513 revset: do not ignore "git" remote if user pattern is specified
Since we can now express the default pattern as `remote=~exact:"git"`, we can
unblock queries matching the "git" remote.
2025-10-31 00:37:50 +00:00
Yuya Nishihara
626e5b29a6 revset: parameterize special "git" remote that is ignored by default
The default remote parameter of remote_bookmarks() will be derived from this
parameter. It doesn't make sense to exclude @git bookmarks if the backend isn't
Git. It's also nice that parsing tests don't depend on the feature flag.
2025-10-31 00:37:50 +00:00
Yuya Nishihara
f7256f611c revset: parse string patterns into StringExpression
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
A typical use case is to query bookmarked revisions ignoring auto-generated
bookmarks. `bookmarks() ~ bookmarks(x)` doesn't work because a revision may have
multiple bookmarks. It's also nice that we can document the default of
`remote_bookmarks()` as `remote_bookmarks(remote=~exact:"git")`.

Closes #7665
2025-10-29 23:59:58 +00:00
Yuya Nishihara
843b45b7cb str_util: rename StringPattern::everything() to all()
I'm going to add AST type for compound string match expressions, and this type
will be similar to Revset/FilesetExpression which implement all().
2025-10-29 11:19:42 +00:00
Brian Schroeder
7810926c35 index: make Index::is_ancestor fallible
This is part of a series of changes to make most methods on index traits
(i.e. `ChangeIdIndex`, `MutableIndex`, `ReadonlyIndex`, `Index`)
fallible. This will enable networked implementations of these traits,
which may produce I/O errors during operation. See #7825 for more
information.

- Introduced a few more instances of the existing anti-pattern, `TODO:
  indexing error shouldn't be a "BackendError"`. We're tracking this
  known issue in #7849.
- Converted `MutableRepo::merge_view` to return a `RepoLoaderError`
  instead of a `BackendError`. The only caller, `MutableRepo::merge`,
  already returns a `RepoLoaderError`.
- Added three "`fallible_`" iterator helpers to reduce the amount of
  noise at `is_ancestor` call sites due to the method now being
  fallible. Using these helpers seem to produce code that's a little
  more readable than using `process_results` from itertools. One
  consideration in this trade-off is that these helpers do not
  themselves return iterators: if we find that we need more support for
  fallible combinators mid-"chain" of iterator combinators, we might
  either want to use `process_results` only in those cases, or switch to
  use of `process_results` across the board (in lieu of these new
  helpers).
2025-10-28 13:47:44 +00:00