Skip to content

Commit

Permalink
rebase-i-p: if todo was reordered use HEAD as the rewritten parent
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stephen Haberman authored and Junio C Hamano committed Oct 16, 2008
1 parent d80d6bc commit 80fe82e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions git-rebase--interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,15 @@ pick_one_preserving_merges () {
if test -f "$REWRITTEN"/$p
then
new_p=$(cat "$REWRITTEN"/$p)

# If the todo reordered commits, and our parent is marked for
# rewriting, but hasn't been gotten to yet, assume the user meant to
# drop it on top of the current HEAD
if test -z "$new_p"
then
new_p=$(git rev-parse HEAD)
fi

test $p != $new_p && fast_forward=f
case "$new_parents" in
*$new_p*)
Expand Down
4 changes: 2 additions & 2 deletions t/t3411-rebase-preserve-around-merges.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ test_expect_success 'setup' '
# \ /
# -- C1 --
#
test_expect_failure 'squash F1 into D1' '
test_expect_success 'squash F1 into D1' '
FAKE_LINES="1 squash 3 2" git rebase -i -p B1 &&
test "$(git rev-parse HEAD^2)" = "$(git rev-parse branch)" &&
test "$(git rev-parse HEAD~2)" = "$(git rev-parse B1)" &&
Expand All @@ -99,7 +99,7 @@ test_expect_failure 'squash F1 into D1' '
#
# And rebase G1..M1 onto E2

test_expect_failure 'rebase two levels of merge' '
test_expect_success 'rebase two levels of merge' '
git checkout -b branch2 A1 &&
touch g &&
git add g &&
Expand Down

0 comments on commit 80fe82e

Please sign in to comment.