3179 Commits

Author SHA1 Message Date
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
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
Evan Mesterhazy
3ab5f1d197 cli split: Refactor and move tree selection to a function
This change moves the code for prompting the user to select changes for the
first commit to a helper function. There are no functional changes.

Resulting from the discussion in https://github.com/jj-vcs/jj/pull/5828
we are planning to add several new flags (-B, -A, and -d) to jj split.

Since this may change how the user selects changes (i.e. they may select
changes to remove from the target commit, rather than what stays in the target
commit), I want to move the selection logic to a function to make the main
split function more readable.
2025-03-06 14:38:29 +00:00
Evan Mesterhazy
707680be22 rewrite: Rename CommitToSquash to CommitWithSelection
Removing "Squash" from the name will allow this type to be used in split as
well without it being confusing.
2025-03-06 14:38:29 +00:00
George Christou
b7f7d923bd config: rename core.watchman.register_snapshot_trigger 2025-03-06 08:42:35 +00:00
Ilya Grigoriev
c36bfafb6a clippy: replace allow directives with expect or delete them when possible
Also resolves one TODO made possible by the new MSRV

Most of this was done by enabling the lint forbidding `allow` directives
using `cargo cranky`, running `cargo cranky --workspace
--all-featuers --fix`, and fixing up the result.
2025-03-06 07:24:28 +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
Yuya Nishihara
b0e9bdffc0 settings: load signing parameters early, propagate config error
Typo in signing.behavior shouldn't be ignored.

The idea is the same as [user] and [operation] tables. It's easier if all
parameters needed to create a commit is parsed by UserSettings constructor.
Another option is to make repo.start_transaction() fail on config error.
2025-03-05 10:02:42 +00:00
Yuya Nishihara
7e8dba8d94 op_store: validate operation/view id length to detect corruption earlier
After system crash, file contents are often truncated or filled with zeros. If
a file was truncated to empty, it can be decoded successfully and we'll get
cryptic "is a directory" error because of an empty view ID. We should instead
report data corruption with the ID of the corrupted file.

#4423
2025-03-03 01:18:34 +00:00
Yuya Nishihara
2eb6a0198b op_store: remove redundant DecodeError type
It should be equivalent to OpStoreError::ReadObject. Perhaps, we couldn't use
ReadObject before because the source error type wasn't dyn Error.
2025-03-03 01:18:34 +00:00
Yuya Nishihara
6261d576da git: use gix::ObjectId::from_bytes_or_panic() consistently 2025-03-02 02:19:00 +00:00
pylbrecht
7bf4148169 commit_builder: split set_sign_key()
Clearing a sign key would require calling `set_sign_key(None)`, which
makes the API slightly awkward.

Instead, we introduce `clear_sign_key()` and make `set_sign_key()` only
accept a `String`. This makes clearing the sign key explicit.

Co-Authored-By: Yuya Nishihara <yuya@tcha.org>
2025-02-28 07:52:57 +00:00
Yuya Nishihara
72b24d18e3 revset: box RevsetParseErrorKind to keep error type small
RevsetParseErrorKind has variants containing 3 String fields, which ends up 80
bytes.
2025-02-28 07:27:40 +00:00
Yuya Nishihara
0b56863aed revset: export low-level parse_program() function
This is useful to check if an input text can be parsed as a revset expression.
2025-02-28 07:27:40 +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
Yuya Nishihara
ae8e6e8e8e view: port remote_bookmark accessors to RemoteRefSymbol 2025-02-26 03:17:45 +00:00
Yuya Nishihara
4b06274785 view: make remote bookmark iterators yield RemoteRefSymbol instead of tuple
This also changes formatting of remote symbol to use revset compatible form.
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
821f6b0f8b revset: externalize RemoteSymbol variant by using RemoteRefSymbol types
A struct with named fields should be more readable than unnamed arguments pair.
2025-02-26 03:17:45 +00:00
Yuya Nishihara
201603f48f refs: add RemoteRefSymbol { name, remote } types
I'm going to fix some CLI outputs to print remote symbols in revset syntax, and
it's easier if the view API took/returned type that represents a ref name.

.as_ref() and .to_owned() are implemented as non-trait methods because
RemoteRefSymbol can't be a true reference type. I think it's similar to
Option::as_ref(). I couldn't find any std examples of non-trait .to_owned(),
though.
2025-02-26 03:17:45 +00:00
Baltasar Dinis
653cc6c1c9 lib: move git_backend tests to gitoxide
This forces some code duplication to avoid depending on the testutils.
2025-02-24 21:02:29 +00:00
Yuya Nishihara
37bfc64cf2 working_copy: do not update watchman clock if untracked files exist
This means that watchman is partially disabled until the user cleans up
untracked files. This isn't nice, but should be better than hiding untracked
files forever.

Fixes #5728
Fixes #5602
2025-02-24 08:22:21 +00:00
Yuya Nishihara
d9b762b8ec lib: internalize testutils::new_temp_dir() for unit tests
This fixes real dependency cycle that would expose slightly different versions
of jj_lib types to unit tests, one from super::* and another from testutils::*.

The testutils dependency can be removed by splitting lib/tests to a separate
crate.
2025-02-20 13:01:30 +00:00
Yuya Nishihara
59ca16705e revset: add parsing function that rejects expression other than symbol name 2025-02-20 08:05:20 +00:00
Baltasar Dinis
6d26580a97 git: remove --bare flag from git commands
This causes some issues (e.g., #5700) and is not actively needed.
2025-02-19 15:48:08 +00:00
Baltasar Dinis
31afda99d4 git: pass --no-write-fetch-head to git
This makes the fetch invisible to other people.
2025-02-19 05:19:07 +00:00
Baltasar Dinis
64ea8bee47 git: reject remotes with forward slashes
Although this behaviour is accepted by git, it's a degenerate case.
Especially because we implicitely rely on being able to parse out the
remote from the refname (i.e., `refs/remotes/<remote>/<branch>`).

Branches can have forward slashes, but if remotes can also have them,
parsing the refname becomes ambiguous, and a pain. Especially because it
would be totally legal to have a branch "c" on remote "a/b" and a branch
"b" on remote "a".

Fixes #5731
2025-02-18 07:10:01 +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
Martin von Zweigbergk
a89bcf23ea cli_util: make update_working_copy() return all-zero stats instead of None
When updating the working copy results in no changes, we currently
return `None` from `cli_util::update_working_copy()`. However, a no-op
update is still an update, so I think it makes more sense to always
return a `CheckoutStats`. We already skip printing stats if they're
zero.
2025-02-17 18:59:56 +00:00
Yuya Nishihara
4ed0e1330a op_store: propagate initialization error 2025-02-17 12:58:57 +00:00
Yuya Nishihara
caaa2ab201 op_heads_store: propagate initialization error 2025-02-17 12:58:57 +00:00
Yuya Nishihara
33d61180a5 repo: plumbing to propagate error from backend initializer/loader functions 2025-02-17 12:58:57 +00:00
maan2003
ec6f8278fd signing: allow specifying sign behavior 2025-02-16 05:56:52 +00:00
Yuya Nishihara
5def466ac1 index, op_store: write temporary files in destination directory
This should be safer, and should be okay since we ignore invalid file names when
scanning the store directories.

Fixes #5712
2025-02-16 01:48:10 +00:00
Yuya Nishihara
be77d03bca op_store: extract functions that return views/operations dir paths 2025-02-16 01:48:10 +00:00
Yuya Nishihara
89fb97be88 op_store: refactor SimpleOpStore::init() to use self.path for initialization
I'm going to add helper functions that return these directory paths.
2025-02-16 01:48:10 +00:00
Philip Metzger
4a47a4fc1d commit: Add commit.is_hidden(repo)
Also simplify the `hidden()` revset with it.
2025-02-14 16:24:01 +00:00
Martin von Zweigbergk
5e896b22fe repo: make commit visible when pointing bookmark to it
This was discussed in the Discord a while ago, and this is the logical and consistent
conclusion. Implementing it as such makes it consistent with both `jj edit` and `jj new`
which make hidden commits such as predecessors visible.

This actually was Martins work, I just added the tests.

Co-Authored-by: martinvonz <martinvonz@google.com>
2025-02-14 16:24:01 +00:00
Samuel Tardieu
148e4235fd git: box gix::Repository large instances
`gix::Repository` instances are larger than 1KB on 64-bit machines. This
makes Clippy warn about an unbalance between variants of `GitFetchImpl`:
the `Git2` variant requires 8 bytes, while the `Subprocess` variant
requires 1128 bytes.

Boxing the `gix::Repository` makes `GitFetchImpl` instances smaller, as
well as the other structs embedding them such as `GitFetch`.
2025-02-13 08:10:02 +00:00
Yuya Nishihara
a1fe2dc95e git: trim trailing space in sideband messages received from git subprocess
Since git CLI appends "        " to sideband messages to overwrite the previous
line, we need to undo that. Our GitSidebandProgressMessageWriter expects
original sideband messages.
2025-02-12 01:25:53 +00:00
Emily
77f54a267e git: enable subprocessing by default
Given the previously‐stated intention of making this default
for the 0.27 release, prepare for that decision ahead of time by
enabling subprocessing by default on trunk. This will help surface
any regressions and workflow incompatibilities and therefore give
us more information to decide whether to keep or revert this commit,
without inconveniencing any users who haven’t already opted in to
the bleeding edge.

Please feel free to revert without hesitation if any major issues
arise; this is not intended as a strong commitment to enable this
option for the next stable release if it turns out to not be ready. In
that case, it’s better that we learn that early on in the cycle,
rather than having to revert at the last minute or, worse, cutting
a stable release that we later find contains a serious regression.
2025-02-10 22:10:22 +00:00
Jacob Hayes
6aefb58ed8
sign: Support ~/ path expansion for allowed-signers
Fixes #5625
2025-02-10 16:50:39 +07:00
Evan Mesterhazy
aee05b9ea0 repo: Use thiserror #[from] with EditCommitError::RewriteRootCommit
See the discussion in #5623. This prevents future accidents if member variables
are added to RewriteRootCommit which need to be propagated to EditCommitError
during conversion.
2025-02-10 04:23:04 +00:00
Evan Mesterhazy
4422e8cea6 cli: Fix single-character string constant used as pattern clippy warning
For further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_pattern

Apparently this got moved to "pedantic" in 1.80, but I ran clippy 1.79 and saw
it. Seems harmless to fix though.

#cleanup
2025-02-09 13:23:41 -05:00
Evan Mesterhazy
6d6f2c6dec repo: Change name for unused closure argument
The previous name violated the "snake case" convention for variable names. I
suspect the intention was to use `RewriteRootCommit` as a type declaration, not
the argument name. Since the argument isn't used, we can use an underscore as
the name and leave the type declaration.

#cleanup
2025-02-08 15:25:44 +00:00
avmikhailov
a16555f9af index: Return Result from heads
there are many ways to implement `heads` for your custom backend:
one involves calling `self.evaluate_revset` with a proper revset. 
However, it can return an error, but `heads` does not allow it.

In our implementation of the index backend we do exactly the above 
and we ended up with several unwraps which we are trying to avoid 
as it could potentially crash our prod jobs.

P.S. The same logic applies to many methods in this trait, but I am doing one at a time.
2025-02-07 13:45:47 +01:00