diff options
-rwxr-xr-x | git-rebase--interactive.sh | 7 | ||||
-rwxr-xr-x | t/t3404-rebase-interactive.sh | 6 |
2 files changed, 12 insertions, 1 deletions
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index f83e00fe8f..cd7e43faeb 100755 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -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 && diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 907c7f9f6b..74a7eb30f8 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -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 && |