From 7093d5d359fb3649be0d12a975f26d5607ad8f61 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Mon, 29 Apr 2024 08:56:51 -0700 Subject: [PATCH] squash: don't use unchanged source commit as predecessor --- cli/src/commands/squash.rs | 6 +++++- cli/tests/test_squash_command.rs | 15 ++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/cli/src/commands/squash.rs b/cli/src/commands/squash.rs index 2128dc6c1..94656aae9 100644 --- a/cli/src/commands/squash.rs +++ b/cli/src/commands/squash.rs @@ -297,7 +297,11 @@ from the source will be moved into the destination. } }; let mut predecessors = vec![destination.id().clone()]; - predecessors.extend(sources.iter().map(|source| source.id().clone())); + predecessors.extend( + source_commits + .iter() + .map(|source| source.commit.id().clone()), + ); tx.mut_repo() .rewrite_commit(settings, &rewritten_destination) .set_tree_id(destination_tree.id().clone()) diff --git a/cli/tests/test_squash_command.rs b/cli/tests/test_squash_command.rs index ea4eb71d9..871939c6d 100644 --- a/cli/tests/test_squash_command.rs +++ b/cli/tests/test_squash_command.rs @@ -910,16 +910,13 @@ fn test_squash_from_multiple_partial_no_op() { r#"separate(" ", commit_id.short(), description)"#, ], ); - // TODO: Commit c should not be a predecessor insta::assert_snapshot!(stdout, @r###" - @ 9227d0d780fa d - ├─┬─╮ - ◉ │ │ 09441f0a6266 d - ◉ │ │ cba0f0aa472b d - ◉ │ 285201979c90 b - ◉ │ 81187418277d b - ◉ 5ad3ca4090a7 c - ◉ 7cfbaf71a279 c + @ 9227d0d780fa d + ├─╮ + ◉ │ 09441f0a6266 d + ◉ │ cba0f0aa472b d + ◉ 285201979c90 b + ◉ 81187418277d b "###); // If no source commits match the paths, then the whole operation is a no-op