3633 Commits

Author SHA1 Message Date
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
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
Baltasar Dinis
0c446c9069 git: skip running pre-push hooks when subprocessing to match git2 behaviour 2025-02-06 22:43:06 +00:00
Yuya Nishihara
6574f12173 local_working_copy: scan directory entries excluded by auto-track pattern
Since we need to scan directory entries recursively in order to detect new
untracked paths, it doesn't make sense to reuse the .gitignore code path.

This change means all untracked file paths are listed in "jj status" even if
the whole directory is untracked. It might be a bit verbose, but should be
okay. Directories like node_modules should be excluded by .gitignore, not by
auto-track pattern.

Fixes #5389
2025-02-06 18:04:57 +09:00
Yuya Nishihara
1faea485ca git: enable sideband progress on subprocess push
The parsing function is adjusted in case stderr contained unparsed progress
messages.
2025-02-06 01:05:48 +00:00
Yuya Nishihara
e091172b63 git: force git subprocess to not localize error messages
Since we parse error messages, we need to disable translation at all.
2025-02-05 16:20:13 +09:00
Yuya Nishihara
e85a5c44cd rewrite: move description handling from squash_commits() to caller
This allows caller to reborrow tx.repo() to render description template. It
also matches the documented behavior.
2025-02-04 06:05:58 +00:00
Yuya Nishihara
7898eb9f82 git: split function that queries remote default branch, call only when needed
With git.subprocess = true, it's more important to skip unneeded remote
operations. Each remote command may involve user intervention if authentication
requires manual step.

This change also means that the remote connection is no longer reused in git2
impl. I think the added cost is acceptable. The git2 impl will hopefully be
removed soon, and the remote branch name is needed only when cloning new repo.
2025-02-03 03:43:11 +00:00
Yuya Nishihara
241b8873ba revset: escape symbols in "did you mean" hint
The hint should include expressions that can be copied to -r argument.
2025-02-03 01:31:04 +00:00
Yuya Nishihara
fc7ac4c0bf revset: extract helper that formats remote symbol
I'll add a few more callers.
2025-02-03 01:31:04 +00:00
Yuya Nishihara
5be25bc8cf parser: use backtick to quote name or expression in error message
I don't have any preference about quoting styles, but it looks weird if an
escaped symbol is surrounded by double quotes.
2025-02-03 01:31:04 +00:00
Yuya Nishihara
7e55dd2294 git: check remote existence without using git2::Repository 2025-02-01 11:04:38 +00:00
Yuya Nishihara
bba6f15dfe git: initialize subprocess context without using git2::Repository 2025-02-01 11:04:38 +00:00
Yuya Nishihara
d4023d873d git: instantiate GitSubprocessContext by push_updates() for consistency 2025-02-01 11:04:38 +00:00
Yuya Nishihara
8cad3ac95a git: extract GitFetchImpl that holds implementation-specific objects
This could be a trait object, but we only need a single fetch() function per
implementation.
2025-02-01 11:04:38 +00:00
Yuya Nishihara
6e3c7fcf2d git: extract inner fetch functions out of GitFetch struct
I'm going to add enum that holds either git2::Repository or subprocess context.
"&mut self" will be useless there.
2025-02-01 11:04:38 +00:00
Yuya Nishihara
658cd3e0fd git: resolve git2::Repository internally in GitFetch::new()
git2::Repository will be removed from the subprocess code path.
2025-02-01 11:04:38 +00:00
Yuya Nishihara
9bf29accc2 git: resolve git2::Repository internally in push_updates()
git2::Repository will be removed from the subprocess code path.
2025-02-01 11:04:38 +00:00
Yuya Nishihara
27e7672a3b git: store bad pattern object in GitFetchError::InvalidBranchPattern
This helps add From<GitFetchError> impl.
2025-02-01 11:04:38 +00:00
Yuya Nishihara
67bb2809ed git: test that local progress is emitted through callback 2025-02-01 03:30:39 +00:00
Baltasar Dinis
b35d503bf7 git: show fetch progress with git.subprocess = true 2025-02-01 01:46:31 +00:00
Scott Taylor
66808e5dc1 conflicts: use clearer wording for missing newline comment
The current comment uses `[noeol]`, which can be difficult to
understand. In this commit, the brackets are changed to parentheses to
make it clear that there is no semantic meaning to the comment, and the
wording is changed to be more clear to the user.
2025-01-31 23:38:42 +00:00
Scott Taylor
0b719332aa conflicts: don't mark missing newline in Git-style conflicts
Git doesn't show this information in their "diff3" style either, and it
looks a bit strange having two different bracketed sections of text next
to each other, so I think it would be better to remove it.
2025-01-31 23:38:42 +00:00
Martin von Zweigbergk
4ac970fcc5 cleanup: prefer MutableRepo::repo() over repo_mut()
When we don't need a mutable reference, we should be using `repo()`.
2025-01-31 18:03:01 +00:00