rebase -p -i: handle "no changes" gracefully
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>
Mon, 17 Dec 2007 21:01:25 +0000 (21:01 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 18 Dec 2007 04:49:18 +0000 (20:49 -0800)
Since commit 376ccb8cbb453343998e734d8a1ce79f57a4e092 (rebase -i: style
fixes and minor cleanups), unchanged SHA-1s are no longer mapped via
$REWRITTEN.  But the updating phase was not prepared for the old head
not being rewritten.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-rebase--interactive.sh
t/t3404-rebase-interactive.sh

index f83e00fe8fec63d5c58f375ec49ee8bf865f1344..cd7e43faeb7a946da51e47821b8e2adff7472a8f 100755 (executable)
@@ -322,7 +322,12 @@ do_next () {
                test -f "$DOTEST"/current-commit &&
                        current_commit=$(cat "$DOTEST"/current-commit) &&
                        git rev-parse HEAD > "$REWRITTEN"/$current_commit
-               NEWHEAD=$(cat "$REWRITTEN"/$OLDHEAD)
+               if test -f "$REWRITTEN"/$OLDHEAD
+               then
+                       NEWHEAD=$(cat "$REWRITTEN"/$OLDHEAD)
+               else
+                       NEWHEAD=$OLDHEAD
+               fi
        else
                NEWHEAD=$(git rev-parse HEAD)
        fi &&
index 907c7f9f6bccb0ddcf4d9862467a938369a07519..74a7eb30f84baf2f381c2af7a6c21225bfcd2b08 100755 (executable)
@@ -184,6 +184,12 @@ test_expect_success 'retain authorship when squashing' '
        git show HEAD | grep "^Author: Twerp Snog"
 '
 
+test_expect_success '-p handles "no changes" gracefully' '
+       HEAD=$(git rev-parse HEAD) &&
+       git rebase -i -p HEAD^ &&
+       test $HEAD = $(git rev-parse HEAD)
+'
+
 test_expect_success 'preserve merges with -p' '
        git checkout -b to-be-preserved master^ &&
        : > unrelated-file &&