Commit graph

4446 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
34a1f86862 merge: include conflict labels when describing non-file conflicts
This should make it easier to resolve these conflicts using
`jj restore --from <commit>`.
2025-12-23 04:11:09 +00:00
Scott Taylor
5fd1b2fd5b rewrite: add conflict labels for squashed commits
An example of squashing `ysrnknol` into `rtsqusxu`:

```
<<<<<<< conflict 1 of 1
+++++++ rtsqusxu 2768b0b9 "A" (squash destination)
updated in destination
%%%%%%% diff from: vpxusssl 38d49363 "B" (parents of squashed commit)
\\\\\\\        to: ysrnknol 7a20f389 "C" (squashed commit)
-base
+squashed
>>>>>>> conflict 1 of 1 ends
```

Or with only partial changes selected:

```
<<<<<<< conflict 1 of 1
+++++++ rtsqusxu 2768b0b9 "A" (squash destination)
updated in destination
%%%%%%% diff from: vpxusssl 38d49363 "B" (parents of squashed commit)
\\\\\\\        to: selected changes for squash (from ysrnknol 7a20f389 "C")
-base
+selected changes
>>>>>>> conflict 1 of 1 ends
```
2025-12-23 00:59:32 +00:00
Scott Taylor
225bbe4835 rewrite: add conflict label methods for CommitWithSelection 2025-12-23 00:59:32 +00:00
Scott Taylor
5c7d0b0f55 merge: add Diff::invert method 2025-12-23 00:59:32 +00:00
Scott Taylor
4adbdd9d76 merge: add Merge::from_diffs constructor 2025-12-23 00:59:32 +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
144ba766b1 rewrite: add conflict labels for rebased commits
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
An example of rebasing `ysrnknol` onto `rtsqusxu`:

```
<<<<<<< conflict 1 of 1
%%%%%%% diff from: vpxusssl 38d49363 "base" (parents of rebased commit)
\\\\\\\        to: rtsqusxu 2768b0b9 "left" (rebase destination)
-base
+left
+++++++ ysrnknol 7a20f389 "right" (rebased commit)
right
>>>>>>> conflict 1 of 1 ends
```
2025-12-20 04:03:57 +00:00
Scott Taylor
04a91217f5 rewrite: add conflict labels when merging commit trees
An example with parents `rtsqusxu` and `ysrnknol`:

```
<<<<<<< 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
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
Martin von Zweigbergk
3767857a45 revset_engine: move match_lines() onto StringPattern for reuse 2025-12-18 06:31:37 +00:00
Yuya Nishihara
412326eebb repo_path: use stringified paths when formatting copied path
Since String provides more convenient functions for searching/splitting than
OsString, it should be simpler to convert relative PathBuf to String first. The
tricky part is "right-to-left" version of .split_inclusive("/"), but the
original code wasn't readable either.

"if !paths.is_changed()" is removed since the formatting function can now handle
unchanged paths.
2025-12-18 06:28:01 +00:00
Yuya Nishihara
79cefebb68 repo_path: use Diff<T> to specify copied source/target paths
copied_path.to_diff() returns Option<Diff<T>> because it seemed silly to compare
before/after paths when the caller knows the entry isn't copied/renamed.
2025-12-18 06:28:01 +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
Yuya Nishihara
e0a725736d cli: add debug command that dumps stats of stacked table
This is pretty low level, but we can at least know which extras table files are
active. The --key-size parameter doesn't matter so long as it is smaller than
the actual key size, but we might add sanity check later.
2025-12-17 10:38:11 +00:00
Scott Taylor
40637b294a default_index: sort resolve_change_id_prefix() by descending position
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-16 14:27: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
b9317da0f8 cli: enable glob string matching globally
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
The goal of this change is to unify defaults of string patterns in revsets and
command arguments. Glob is a good default because it's largely the same as exact
matching, and we can easily express substring patterns with globs.

The hint for "jj git fetch -b<glob>" is deleted since exact:<glob> is now
required in order to trigger the error.

This patch also updates help of clone/fetch --branch patterns. Glob and operator
support in refspecs is limited.
2025-12-15 04:27:32 +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
Shaoxuan (Max) Yuan
36d1a2a72d colocation: use gix for toggling core.bare config
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
Instead of forking a git process, use `gix` to toggle `core.bare` config.

The original `git -C <repo_root>/.jj/repo/store/git config repo.bare
<true|false>` fails when the user has `safe.bareRepository` config set to
'explicit'. A typical failure looks like this:

	% jj git colocation disable
	Error: Failed to set core.bare to true in Git config.
	Caused by: Git config failed: fatal: not in a git directory

.git is moved to .jj/repo/store/git as a bare repo, and if we run git directly:
	
	% git -C .jj/repo/store/git config repo.bare true
	fatal: not in a git directory

	% git -C .jj/repo/store/git status
	fatal: cannot use bare repository
	<repo_root>/.jj/repo/store/git (safe.bareRepository is 'explicit')

Use `gix` to avoid forking git and being interferred by git's configs.
2025-12-13 04:28:31 +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
2f0b0c68e5 git: use gix::ObjectId types in peeling function
We'll reuse resolve_git_ref_to_commit_id() to fix export functions.
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
504455f18a merge: add Diff::zip method
Also adds tests for other methods since they were missing tests.
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
Yuya Nishihara
5ee0b16c7c lock: don't emit "locked" message on retry 2025-12-12 01:39:30 +00:00
msta
cd92391a7e debug: Print a message with when grabbing a FileLock
This should help to find the root cause of #8240
2025-12-11 21:52:02 +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
ec6756ecbb git: use "let else" in other export 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-11 00:50:29 +00:00
Yuya Nishihara
4adba194c0 git: attempt to create new ref first when exporting refs
Since there should be no existing ref in Git, it's better to try creating a ref
first.
2025-12-11 00:50:29 +00:00
Yuya Nishihara
24c1197aaf git: use try_find_reference() and propagate error when exporting refs
I also renamed git_repo_ref to git_ref because there aren't any other "git_ref"
variables.
2025-12-11 00:50:29 +00:00
Yuya Nishihara
678b871a48 git: extract create/move functions from update_git_ref()
move_git_ref() will be a bit more complicated to fix handling of existing
annotated tags. A tag ref may point to an annotated tag object.
2025-12-11 00:50:29 +00:00
Yuya Nishihara
68022cc9ec str_util: remove deprecated StringPattern::parse() function
All parsing functions but for "kind:name@remote" syntax have been migrated to
revset parser, and the remote pattern parser uses from_str_kind().
2025-12-11 00:48:56 +00:00
Yuya Nishihara
f4fd9a0c1b str_util: compile glob to regex only when needed
Since we no longer have pattern.is_match(), the regex doesn't have to be
preconstructed.
2025-12-11 00:48:56 +00:00
Yuya Nishihara
93d7c38404 str_util: remove is_match*() from StringPattern
All callers have been migrated to StringMatcher.
2025-12-11 00:48:56 +00:00
Yuya Nishihara
9620b00d95 revset, templater: deprecate git_head() and git_refs() functions
While these two are stored in view objects, we intentionally ignore them when
undoing. This means that these fields don't have to be tracked by
view/operation. I think we can move them away to GitBackend-specific data.

We could provide git_head()/git_refs() that load data from GitBackend, but I
don't think these template/revset functions are useful. I've never used them
except for the git_head() template function, and its use case was to see whether
the repository is colocated or not.
2025-12-10 14:26:47 +00:00
Yuya Nishihara
6ec1c8e7d5 settings: parse auto-track-bookmarks as string matcher expressions
The settings field is now wrapped in Option because [remotes.<name>] may have
multiple fields, and some of them can be omitted.
2025-12-10 11:23:58 +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
Yuya Nishihara
4bfbee018e settings: add type alias for remote_settings() return value 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
Yuya Nishihara
3890c28493 merge: implement IntoIterator for references of Merge<T>
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 seemed odd that owned values can be looped over with "for", but borrowed
values can't.
2025-12-09 23:28:23 +00:00