3762 Commits

Author SHA1 Message Date
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
Baltasar Dinis
09d92e8278 cli/tests: port test_git_fetch to gitoxide 2025-03-05 05:39:19 +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
Baltasar Dinis
c2a92fce37 cli/tests: port test_git_remotes to gitoxide 2025-03-05 05:39:19 +00:00
Jonathan Tan
507e4b033d lib/testutils/Cargo.toml: remove unused gix feature
The gix feature "blocking-network-client" was configured in cd6141693
(cli/tests: add gitoxide helpers, 2025-02-03) most likely because
we needed to clone using gix in tests, but 071e724c1 (cli/tests:
move test_git_colocated_fetch_deleted_or_moved_bookmark to gitoxide,
2025-02-25) changed the test to clone by subprocessing out to system git
(not by using gitoxide, as a cursory read of the commit description may
indicate), meaning that we no longer need that feature.

Therefore, remove that feature.
2025-03-04 20:39:20 +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
Baltasar Dinis
071e724c1c cli/tests: move test_git_colocated_fetch_deleted_or_moved_bookmark to gitoxide 2025-03-01 09:54:31 +00:00
Baltasar Dinis
05479df69e cli/tests: move most of the test_git_colocated tests to gitoxide 2025-03-01 09:54:31 +00:00
Yuya Nishihara
63f874376c tests: make git::IndexManager::new() preserve the staged changes
It's odd that IndexManager::new(repo) creates a new empty index ignoring the
current state. The callers appear not to depend on this behavior.
2025-02-28 11:19:46 +00:00
Yuya Nishihara
2586ec5b75 tests: remove unused field from git::IndexManager 2025-02-28 11:19:46 +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
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
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
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
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
683ee9287e tests: move gitoxide test helpers to testutils
These helpers are going to be needed to port the git2 code in the lib
tests to gitoxide. Since the cli tests already depend on testutils, this
helps with avoiding duplicating the code
2025-02-20 06:13: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