diff --git a/git-branchless-lib/src/core/rewrite/plan.rs b/git-branchless-lib/src/core/rewrite/plan.rs index f030180c1..f40f86cc6 100644 --- a/git-branchless-lib/src/core/rewrite/plan.rs +++ b/git-branchless-lib/src/core/rewrite/plan.rs @@ -154,7 +154,6 @@ impl ToString for RebaseCommand { .iter() .map(|oid| format!("fixup {oid}")) .collect::>(); - let mut cleanups = vec![]; // Since 0ca8681, the intermediate commits created as each // fixup is applied are left behind in the smartlog. This @@ -177,14 +176,14 @@ impl ToString for RebaseCommand { // We have to add some additional steps to make sure the // smartlog and commit metadata are left as the user // expects. - if pick_oid != original_commit_oid { + let cleanups = if pick_oid != original_commit_oid { // See above comment related to 0ca8681 picks.insert( 1, "exec git branchless hook-skip-upstream-applied-commit $(git rev-parse HEAD)".to_string() ); - cleanups = vec![ + vec![ // Hide the final squashed commit "exec git branchless hook-skip-upstream-applied-commit $(git rev-parse HEAD)".to_string(), @@ -196,8 +195,14 @@ impl ToString for RebaseCommand { // Finally, register the new final commit as the // rewritten version of original_commit_oid format!("exec git branchless hook-skip-upstream-applied-commit {original_commit_oid} $(git rev-parse HEAD)") - ]; - } + ] + } else { + vec![ + // HACK force move branches that used to point at original_commit_oid to new HEAD + // FIXME Yuck! The for loop works by word, not by line; will not work for branches w/ spaces ... is that a thing? + format!("exec for BRANCH in $(git branch --points-at {original_commit_oid}); do git branch --force \"$BRANCH\" HEAD; done"), + ] + }; picks .iter() diff --git a/git-branchless/tests/test_move.rs b/git-branchless/tests/test_move.rs index 18d3c9916..3e4ce9f76 100644 --- a/git-branchless/tests/test_move.rs +++ b/git-branchless/tests/test_move.rs @@ -5726,7 +5726,7 @@ fn test_move_fixup_multiple_disconnected_into_ancestor() -> eyre::Result<()> { "-x", &format!("{}+{}", test3_oid, test5_oid), "-d", - &test1_oid.to_string(), + "test", ], // Use the same mocked system time as the destination commit to coax // the commit hashs to match their in-mem counterparts. @@ -5740,7 +5740,7 @@ fn test_move_fixup_multiple_disconnected_into_ancestor() -> eyre::Result<()> { insta::assert_snapshot!(stdout, @r###" O f777ecc (master) create initial.txt | - o 38caaaf create test.txt + o 38caaaf (test) create test.txt | o 6783c86 update 2 test.txt | @@ -5750,7 +5750,7 @@ fn test_move_fixup_multiple_disconnected_into_ancestor() -> eyre::Result<()> { "###); // diff for "create test.txt" - let diff = git.get_trimmed_diff("test.txt", "38caaaf")?; + let diff = git.get_trimmed_diff("test.txt", "test")?; insta::assert_snapshot!(diff, @r###" @@ -0,0 +1,8 @@ +# Section A