1146 Commits

Author SHA1 Message Date
Yuya Nishihara
3f5f872204 view: rename workspace "id" to "name"
This matches the current implementation.
2025-03-31 03:39:29 +00:00
Yuya Nishihara
e66c545438 view: replace WorkspaceId by string-like newtypes
I think this makes more sense because WorkspaceId is currently a human-readable
name. In error/status messages, workspace names are now printed in revset
syntax.

New WorkspaceId types do not implement Default. It would be weird if string-like
type had non-empty Default::default(). The DEFAULT constant is provided instead.
2025-03-31 03:39:29 +00:00
Yuya Nishihara
f87db58617 view: rename RemoteRefState::Tracking to Tracked
In jj's model, a local bookmark "tracks" remote bookmarks. It's wrong to call
a remote bookmark state as "tracking".
2025-03-31 01:41:31 +00:00
Yuya Nishihara
e4982a9c33 git: report HEAD export failure as warning
It's safe to commit transaction even if HEAD couldn't be updated due to
concurrent changes.

Closes #6098
2025-03-30 01:46:00 +00:00
Yuya Nishihara
cd1ee943e6 git: split GitResetHeadError, add UpdateHeadRef variant
This helps handle "HEAD" export failure differently. At this point, the set of
error variants look distinct enough to split the error types.
2025-03-30 01:46:00 +00:00
Yuya Nishihara
c33be3839d git: remove redundant error context messages, rename variants
Wrapped errors are usually displayed after "Failed to import refs ...", etc., so
the context is obvious. I also removed "Internal"/"Error" for consistency.
2025-03-30 01:46:00 +00:00
Yuya Nishihara
d6be4a598e git: use GitRefName newtypes in push functions 2025-03-28 01:29:30 +00:00
Yuya Nishihara
fb8e45d6f9 view: introduce GitRefName newtypes
We don't reuse the RefName type here because fully-qualified Git ref name
shouldn't be considered a local ref name in jj.
2025-03-28 01:29:30 +00:00
Yuya Nishihara
bcf3d5869b revset: add optional local variables to RevsetParseContext 2025-03-27 13:23:58 +00:00
Yuya Nishihara
ffad6fe96f revset: extract internal context struct from RevsetParseContext
This allows callers to mutate RevsetParseContext if needed.

RevsetParseContext was changed to an opaque struct at 4e0abf06317f "revset: make
RevsetParseContext opaque." I think the intent there was to hide implementation
details from revset extension functions. This is now achieved by opaque
LoweringContext.

Another reason of this change is that aliases_map is no longer needed when
transforming AST to UserRevsetExpression.
2025-03-26 13:03:41 +00:00
Yuya Nishihara
3656a62bf5 git: use RemoteName newtype in remote management functions 2025-03-26 13:03:37 +00:00
Yuya Nishihara
4ff2827d00 git: use RemoteName/RefName newtypes in fetch functions 2025-03-26 13:03:37 +00:00
Yuya Nishihara
02722eae54 view: port bookmark/tag name types to RefName/RemoteName
I tried to minimize this patch, but it seemed rather complicated than porting
most callers all at once. Remote management functions in git.rs are unchanged.
They'll be ported separately.

With this change, many non-template bookmark/remote name outputs should be
rendered in revset syntax.
2025-03-26 11:07:06 +00:00
Yuya Nishihara
cc8a80c548 ref_name: move RemoteRefSymbol types from refs module 2025-03-26 11:07:06 +00:00
Baltasar Dinis
8ae80523e4 git: forward rejection reason on push
We've been finding that a lot of bug reports on `jj git push` come from
sub-standard error reporting on the reasons the failure happens.

It can come from a number of places:
 - hook failure
 - remote branch protection
 - git config

This commit forwards the reason as explained by the ouptut of git push
to help users figure out what is happening.
2025-03-26 04:46:38 +00:00
Baltasar Dinis
89bb1c4e71 git: refactor push ref error reporting
We need to report more complicated errors on push.
Firstly, we can have a mix of unexpected ref locations and remote
rejections. We should report both at the same time.

Second, git gives us a reason for why a push failed.
For this to work, it's relevant to refactor the current error reporting
path to allow us to inject this information.
2025-03-26 04:46:38 +00:00
Scott Taylor
301f14e856 git_backend: don't allow single tree in jj:trees header
It is important for this case to be an error, because otherwise it would
be possible to construct a non-conflicted commit which appears to have a
different tree when viewed using `jj` than when viewed using Git. This
could potentially be used to hide malicious code in commits in such a
way that on GitHub, the code would appear normal, but it would become
malicious when cloned using `jj`.

Prior to f7b14beacc678a9b351ae65224df43a96aa26392, if a commit had a
`jj:trees` header with only a single tree, it would result in a panic of
"root tree should have been initialized to a legacy id". This commit
restores the error behavior by adding an explicit check for this case.
2025-03-25 12:42:39 +00:00
Scott Taylor
c96d7856a7 git_backend: add test for jj:trees with one tree
This demonstrates an issue which will be fixed by the next commit.
2025-03-25 12:42:39 +00:00
Yuya Nishihara
5ee1dbbd22 git: wrap list of failed exports in struct
I have no immediate plan, but I think we can make "jj git export" show exported
refs. The FailedRefExport type is replaced with a plain tuple since we have a
named type wrapping (symbol, reason) pairs now.
2025-03-24 01:18:24 +00:00
Yuya Nishihara
8ed9c36377 git: in import_refs(), use sorted vec as map of bookmarks/tags
For consistency with export_refs().

changed_git_refs doesn't have to be sorted, but the sorting cost wouldn't matter
in practice.
2025-03-23 01:32:29 +00:00
Yuya Nishihara
b6419ca790 git: in import_refs(), split known remote bookmarks/tags maps
It's simpler, and more consistent with export_refs().
2025-03-23 01:32:29 +00:00
Yuya Nishihara
7d59d0564e git: use translated remote symbols in export_refs()
I also made to_git_ref_name() stricter as it seemed odd that empty tag name and
remote name were allowed.
2025-03-23 01:32:29 +00:00
Caleb White
680c41c30f signing: add gpgsm backend
The adds support for PKCS#12 certificates through the `gpgsm` backend.

Closes #5856
2025-03-20 17:01:39 +00:00
Ilya Grigoriev
341ddc9148 ci: make sure tests fail in CI if gpg or taplo binaries are not found
Fixes #5696
2025-03-18 02:18:08 +00:00
Yuya Nishihara
c63d8d945e tests: do not mark SSH private key as executable
It doesn't matter, but the intent here should be "chmod go-rwx".
2025-03-18 01:24:47 +00:00
Philip Metzger
f8ab8a0e72 lib: rename the LocalBackend to SimpleBackend
This makes it clear to source code readers, that it isn't the _native backend_ the project
talks about in the Roadmap.
2025-03-17 17:17:11 +00:00
Yuya Nishihara
ec6c5235d5 annotate: report root commit id if no origin found within range
Suppose we add "jj file annotate" option to specify the search domain or depth,
the root commit within the range can be displayed as the boundary commit. "git
blame" for example displays boundary commits with ^ prefix.

This follows up 85e0a8b0687e "annotate: add option to not search all ancestors
of starting commit."
2025-03-17 10:57:33 +00:00
David Rieber
7e1901fefa jj fix: Refactor jj fix CLI, move some logic to lib to make it usable in other tools (e.g. in servers).
* The lib part should not deal with tools, or tool config, or running stuff in subprocesses. That stays in the CLI.
* Adds a fix_files function. This is the entry point.
* Adds a FileFixer trait with a single method to process a set of files. This is a high-level plugin point.
* Adds a ParallelFileFixer which implements the FileFixer trait and invokes a function to fix one file a time, in parallel.
* The CLI uses ParallelFileFixer.

The FileFixer trait allows environments (other than jj CLI) to plug in their own implementation; for example, a server could implement a FileFixer that sends RPCs to a "formatting service".
2025-03-16 17:59:22 +00:00
Emily
a56b78bdb6 git: make git2 support optional
This helps us prepare for removing the functionality down the line and
makes things easier for people building or packaging their own Jujutsu.
2025-03-16 06:07:28 +00:00
Caleb White
a4ef8b3e4d sign: gpg: automatically use user email as signing key
If a signing key is not configured, the user's email will be
used as the signing key. This aligns with `git`'s behavior
and allows the users to not specify the key in their configs
given that they have a key associated with their email.
2025-03-16 02:19:51 +00:00
Ilya Grigoriev
acaedc3382 cleanup: enable unused_trait_names clippy lint and run clippy --fix 2025-03-16 00:35:56 +00:00
Martin von Zweigbergk
162e455390 tree: delete unused code for merging legacy trees
This code has been unused since 8e6e04b92.

I also deleted the associated tests. I considered porting them to
`MergedTree` but it looks like we have good coverage of these cases in
the existing `MergedTree` tests combined with the low-level `Merge`
tests.
2025-03-15 05:18:43 +00:00
Yuya Nishihara
e054a291b1 git: use translated remote symbols in import_refs()
This removes the special case for RefName::LocalBranch(_), which can be
processed as a remote bookmark.

"jj git import" now prints local bookmarks and tags with @git suffix. I think
this is more correct since these refs are imported from the backing Git
repository.
2025-03-12 02:20:00 +00:00
Yuya Nishihara
540ae1b697 git: pass remote (kind, symbol) parameters to git_ref_filter()
I'll reimplement import/export internals to be based off the translated remote
symbols.
2025-03-12 02:20:00 +00:00
Emily
fe9e71b90e git: remove .gitmodules parsing code
This is redundant with `gix`’s native API and not used by anything
but a hidden debugging command.
2025-03-11 02:37:13 +00:00
Yuya Nishihara
c0066083ad git: make import of refs/remotes/git/* non-error, warn failed refs instead
I'm going to reimplement git_ref_filter to process translated remote bookmark
names, and "git" remote will mean the local Git-tracking remote there. The
reserved remote name is checked prior to filtering because refs in that remote
cannot be represented as remote symbols.

I originally implemented the error handling the other way because we didn't
have a machinery to report partial import failure. Now we have stats, it's
easy to report skipped ref names.
2025-03-10 02:04:33 +00:00
Emily
09f6cafa2b git: add remote management tests 2025-03-09 21:17:10 +00:00
Yuya Nishihara
a27d925565 cleanup: switch to use<'_> capturing syntax
This patch fixes `'a: 'b, 'a` lifetime constraints, adds use<>, use<'_>, etc.
where the default would differ between editions. Redundant '_ is also removed.

https://doc.rust-lang.org/stable/edition-guide/rust-2024/rpit-lifetime-capture.html#edition-specific-rules-when-no-use-bound-is-present
2025-03-08 01:16:56 +00:00
Evan Mesterhazy
0edf23eb16 lib rewrite: Add a test for CommitWithSelection
This is in preparation for adding a new function that inverts the selection.
2025-03-08 00:11:29 +00:00
Ilya Grigoriev
5eae2d92a0 tests: run insta --force-update-snapshots
This is a replacement for #5558.

Thanks to @yuja 's https://github.com/mitsuhiko/insta/pull/722, this is
now easy to generate.
2025-03-06 21:35:08 +00:00
Ilya Grigoriev
1ede79c483 MSRV: Update to 1.84 and run clippy --fix, cargo fmt
The CI seems to correctly use rustc 1.84.1 (and not 1.84.0) with this.

For reference, we last updated the MSRV to 1.76 in 5b517b5. According to
https://releases.rs/docs/1.76.0/, this was when it barely became stable.

`flake.nix` seems to be using a nightly toolchain now, so it seems there
is no need to update the version there.

The more precise clippy command used was:

cargo clippy --workspace --all-targets --fix
2025-03-06 07:24:28 +00:00
Baltasar Dinis
876262a41b cli/tests: have clone helper take in a remote name
This is relevant for the git_fetch tests
2025-03-05 05:39:19 +00:00
Yuya Nishihara
6c597d962d git: on reset_head(), check if the actual HEAD points to known location
This will probably mitigate problems of concurrent updates. If two concurrent
processes tried to import + reset HEAD, one of them should fail.

Closes #3754
2025-02-28 05:45:29 +00:00
Baltasar Dinis
e9e127c233 lib/tests: move remaining git test to gitoxide 2025-02-28 03:58:46 +00:00
Yuya Nishihara
ae8e6e8e8e view: port remote_bookmark accessors to RemoteRefSymbol 2025-02-26 03:17:45 +00:00
Yuya Nishihara
6c71f3cbf2 git: use RemoteRefSymbolBuf to represent RefName::RemoteBranch variant
This also changes the formatting to use revset compatible form.
2025-02-26 03:17:45 +00:00
Yuya Nishihara
5fbd4f26f6 tests: accept duplicated snapshots in test_resolve_symbol_change_id()
I didn't notice this function had #[test_case(..)].
2025-02-23 02:13:57 +00:00
Baltasar Dinis
837250277e lib/tests: port lib tests to gitoxide
As per #5548, this moves the majority of the tests in lib/test over to
gitoxide
2025-02-21 18:41:30 +00:00
Yuya Nishihara
1d3558ff96 tests: rewrite change ID resolution test to not rely on git::import_refs()
It should be simpler to assign change IDs explicitly. Maybe we didn't have
.set_change_id() before?
2025-02-21 06:30:38 +00:00
Martin von Zweigbergk
52c1a55bbf local_working_copy: short-circuit update when tree is unchanged
When updating to the same tree, we can skip the actual update and skip
writing the tree-state file.
2025-02-17 18:59:56 +00:00