@matheusbsbs / matheus-bagliano / commits / 80fe82e4eb
Fork 0

rebase-i-p: if todo was reordered use HEAD as the rewritten parent

This seems like the best guess we can make until git sequencer marks are available. That being said, within the context of re-ordering a commit before its parent in todo, I think applying it on top of the current commit seems like a reasonable assumption of what the user intended. Signed-off-by: Stephen Haberman <stephen@exigencecorp.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stephen Haberman committed Oct 15, 2008 at 02:44 UTC 80fe82e4eb365773ba6518c4539c9235ea9a8b2e
2 files changed +11 -2
git-rebase--interactive.sh
+9
@@ -194,6 +194,15 @@ pick_one_preserving_merges () {
194 if test -f "$REWRITTEN"/$p
195 then
196 new_p=$(cat "$REWRITTEN"/$p)
197 +
198 + # If the todo reordered commits, and our parent is marked for
199 + # rewriting, but hasn't been gotten to yet, assume the user meant to
200 + # drop it on top of the current HEAD
201 + if test -z "$new_p"
202 + then
203 + new_p=$(git rev-parse HEAD)
204 + fi
205 +
206 test $p != $new_p && fast_forward=f
207 case "$new_parents" in
208 *$new_p*)
t/t3411-rebase-preserve-around-merges.sh
+2 -2
@@ -80,7 +80,7 @@ test_expect_success 'setup' '
80 # \ /
81 # -- C1 --
82 #
83 -test_expect_failure 'squash F1 into D1' '
83 +test_expect_success 'squash F1 into D1' '
84 FAKE_LINES="1 squash 3 2" git rebase -i -p B1 &&
85 test "$(git rev-parse HEAD^2)" = "$(git rev-parse branch)" &&
86 test "$(git rev-parse HEAD~2)" = "$(git rev-parse B1)" &&
@@ -99,7 +99,7 @@ test_expect_failure 'squash F1 into D1' '
99 #
100 # And rebase G1..M1 onto E2
101
102 -test_expect_failure 'rebase two levels of merge' '
102 +test_expect_success 'rebase two levels of merge' '
103 git checkout -b branch2 A1 &&
104 touch g &&
105 git add g &&