forked from mirrors/jj
cli: don't create a new working-copy commit for already immutable commits
This commit is contained in:
parent
e333620613
commit
c42a941916
3 changed files with 9 additions and 6 deletions
|
@ -1476,9 +1476,15 @@ See https://martinvonz.github.io/jj/latest/working-copy/#stale-working-copy \
|
|||
tx.mut_repo().view().wc_commit_ids().clone().iter().sorted()
|
||||
//sorting otherwise non deterministic order (bad for tests)
|
||||
{
|
||||
// Create a new working-copy commit in the workspace if the working copy became
|
||||
// immutable (but not if it already was)
|
||||
if self
|
||||
.check_repo_rewritable(tx.repo(), [wc_commit_id])
|
||||
.is_err()
|
||||
&& tx.base_repo().index().has_id(wc_commit_id)
|
||||
&& !self
|
||||
.check_repo_rewritable(tx.base_repo().as_ref(), [wc_commit_id])
|
||||
.is_err()
|
||||
{
|
||||
let wc_commit = tx.repo().store().get_commit(wc_commit_id)?;
|
||||
tx.mut_repo()
|
||||
|
|
|
@ -138,9 +138,6 @@ fn test_git_private_commits_are_not_checked_if_immutable() {
|
|||
insta::assert_snapshot!(stderr, @r###"
|
||||
Branch changes to push to origin:
|
||||
Move forward branch main from 7eb97bf230ad to aa3058ff8663
|
||||
Warning: The working-copy commit in workspace 'default' became immutable, so a new commit has been created on top of it.
|
||||
Working copy now at: yostqsxw dce4a15c (empty) (no description set)
|
||||
Parent commit : yqosqzyt aa3058ff main | (empty) private 1
|
||||
"###);
|
||||
}
|
||||
|
||||
|
|
|
@ -125,11 +125,11 @@ fn test_immutable_heads_set_to_working_copy() {
|
|||
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init"]);
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["branch", "create", "main"]);
|
||||
test_env.add_config(r#"revset-aliases."immutable_heads()" = "@""#);
|
||||
// No new commit since it was already immutable
|
||||
let (_, stderr) = test_env.jj_cmd_ok(test_env.env_root(), &["new", "-m=a"]);
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
Warning: The working-copy commit in workspace 'default' became immutable, so a new commit has been created on top of it.
|
||||
Working copy now at: pmmvwywv 7278b2d8 (empty) (no description set)
|
||||
Parent commit : kkmpptxz a713ef56 (empty) a
|
||||
Working copy now at: kkmpptxz a713ef56 (empty) a
|
||||
Parent commit : qpvuntsm e0360db1 main | (no description set)
|
||||
"###);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue