3762 Commits

Author SHA1 Message Date
Yuya Nishihara
be4cb847fa repo: unblock loading of simple backend
This removes warning about unused SimpleBackend on non-dev build. Since
Workspace::init_simple() isn't feature-gated, it doesn't make sense to disable
the backend loading.
2025-03-18 05:37:12 +00:00
Baltasar Dinis
837eee90be git: add more targetted debug logging for subprocess code
In recent bugs, it's been really hard to triage the behaviour from the
existing debug logs.

In particular, there have been situations where the `git` command is not
enough to triage, because the bug stems from a particular
environment/config issue. Moreover, these bugs are either transient, and
as such hard to replicate, or they only manifest when spawning `git`
from `jj` (and as such re-running the `git` command does not yield
useful information).

In those cases, seeing what the subprocessing code is seeing becomes
very much useful. This commit adds some debug logging to help with this
problem, by logging some parts of the `git(1)` output and the config.
2025-03-18 03:27:05 +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
Emily
8f51e749d0 git: inline open_git_repo
The fetch and push code are the only remaining users of this, so
let’s not encourage adding any more.
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
Caleb White
07d392ccf2 config: only load toml files in a directory
This helps avoid loading errors should the JJ_CONFIG
environment variable be set to a directory that
contains other file types.
2025-03-15 23:36:39 +00:00
Baltasar Dinis
1c5585f912 git: add error for inadequate git version
When using old git versions, some of the options we use
(namely, --no-write-fetch-head #5933), we want to report that the error
comes from the outdated git, instead of cryptically failing.

Closes #5933
2025-03-15 14:32:24 +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
d79b93707c config: minor cleanup around new path/source template handling
Cow<str> provides .into_owned(). I don't care much about .to_string() vs
.to_owned(), but it was originally .to_owned(), so reverted the change.
2025-03-15 01:51:47 +00:00
Baltasar Dinis
4e5260dad2 git: detect remote refusal of a push
When we push a ref to a git remote, we use --force-with-lease
Our understanding was that this could fail iff the expected location of
the ref on the remote was not that of the local tracking ref

However, if the ref is from a protected branch (e.g., main) it will be
rejected by the remote for a different reason.

This commit solves this, by detecting this difference.
2025-03-14 08:09:37 +00:00
Baltasar Dinis
bb75612d00 git: small fixes to git-push parsing
Mainly, the reason is not separated by a tab, but rather a space
Additionally, the test output was made more realistic
2025-03-14 08:09:37 +00:00
Baltasar Dinis
6c95f6192f git: refactor git push output 2025-03-14 08:09:37 +00:00
Caleb White
67e17d5474 cli: config list: show origin of config values
Adds a `templates.config.list` config option to control whether the
detailed list is shown or not.

The `builtin_config_list_detailed` template adds the config origin to
the end of the line for each config value in the list. Options coming
from files will show the file path.
2025-03-13 23:59:45 +00:00
Caleb White
7e944f0d11 cli: config {edit,set,unset}: prompt when multiple files exist
This allows the user to select a particular file when using multiple
configs. In the event that a prompt cannot be displayed, the first
file will be automatically selected.
2025-03-13 03:51:52 +00:00
Joachim Desroches
67ffbfa14f cli: annotate: do not panic on reaching initial commit.
As described in #5909, in the case where jj was initialized in a
shallowly cloned repository which was then unshallow'd, jj does not
import the fetched commits that were outside the shallow boundary.

However, it does import the ones after the boundary, which after
unshallowing do not contain the changes made before the boundary.

Therefore, when running annotate in such a case, jj would panic because
it does not find the commit from which a line originates. This sets the
empty commit as carrying the blame for that line.
2025-03-12 13:45:57 +00:00
Ilya Grigoriev
270924ddaa lib: new diff_named_commit_ids helper 2025-03-12 03:41:27 +00:00
Ilya Grigoriev
ca46ce1d3a view: store working copies in BTreeMap
This is analogous to how bookmarks are stored and simplifies the
following commit.
2025-03-12 03:41:27 +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
Yuya Nishihara
907b20162f git: extract function that parses git ref to remote symbol
The old parse_git_ref() function and RefName type will be removed.
2025-03-12 02:20:00 +00:00
Yuya Nishihara
d37a5b1b74 fileset, revset: settle on optionally-quoted pattern syntax
Suppose revsets and filesets are primarily used in command shell, it would be
annoying if quoting is required in addition to the shell quoting. We might also
want to relax the revset parser to allow bare * in glob string.

Closes #2101
2025-03-11 08:35:27 +00:00
Emily
f862d89143 git: port Git state clean‐up from git2 2025-03-11 03:09:13 +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
Emily
b2d63189b9 git: use try_collect 2025-03-10 21:22:42 +00:00
demize
c3cc3de818 git: clean up remove_remote_git_config_sections 2025-03-10 15:08:38 +00:00
demize
cf696ce1b6 git: update gitoxide repository options
This fixes tests in --release and provides safer
defaults.
2025-03-10 15:08:38 +00:00
Emily
ad35f865ed git_backend: remove obsolete libgit2 workaround 2025-03-10 15:07:46 +00:00
Martin von Zweigbergk
5f8654ef68 revset: remove unused lifetime parameter from RevsetIteratorExt
It became unused in 75605e36.
2025-03-10 07:49:59 +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
Yuya Nishihara
cc1b716d39 git: plumbing to report unimportable refs, warn non-utf-8 names
Tests will be added by the next patch. It's not important to report non-utf-8
refs, but this patch implements it as doing that was easy.
2025-03-10 02:04:33 +00:00
Emily
8297938feb git: port remote management to gix 2025-03-09 21:17:10 +00:00
Emily
09f6cafa2b git: add remote management tests 2025-03-09 21:17:10 +00:00
Emily
c25aa6e417 git: abstract git2 in remote management API
This is more consistent with other similar APIs and minimizes churn
in the test code as we move these to `gix`.
2025-03-09 21:17:10 +00:00
Martin von Zweigbergk
95aac580b0 rewrite: fix a Clippy lint 2025-03-08 20:45:39 +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
Yuya Nishihara
df3c15a030 revset: remove support for multiple files() arguments
Since there are no revset functions that require at least N arguments, the
error message test is moved to test_templater.rs.
2025-03-08 00:54:28 +00:00
Yuya Nishihara
d9615800ec revset: replace use of deprecated file() alias in tests 2025-03-08 00:54:28 +00:00
Yuya Nishihara
bf54158fa2 revset: remove deprecated singular aliases 2025-03-08 00:54:28 +00:00
Yuya Nishihara
54868877d6 revset, templater: remove deprecated "branches" aliases 2025-03-08 00:54:28 +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
Yuya Nishihara
dfb10cab9b git: reject reserved remote name early in fetch() function
I'm going to make git::import_refs() not fail because of a real remote named
"git", but fetching from such remote should be an error.
2025-03-07 03:03:45 +00:00
Yuya Nishihara
b2fd1a002e git: extract helper to check unsupported remote name 2025-03-07 03:03:45 +00:00
Yuya Nishihara
99bc2d2f7d git: consolidate when to check unsupported remote name on push
It's odd that "foo/bar" is tested earlier in push_branches() whereas "git" is
rejected by push_updates(). Suppose push_updates() is a low-level function to
push arbitrary refs without updating jj's repo view, it's probably okay to allow
unsupported remote name here.
2025-03-07 03:03:45 +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