Skip to content

Commit 34454e8

Browse files
dschogitster
authored andcommitted
rebase -p -i: handle "no changes" gracefully
Since commit 376ccb8 (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>
1 parent 77680ca commit 34454e8

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

git-rebase--interactive.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,12 @@ do_next () {
322322
test -f "$DOTEST"/current-commit &&
323323
current_commit=$(cat "$DOTEST"/current-commit) &&
324324
git rev-parse HEAD > "$REWRITTEN"/$current_commit
325-
NEWHEAD=$(cat "$REWRITTEN"/$OLDHEAD)
325+
if test -f "$REWRITTEN"/$OLDHEAD
326+
then
327+
NEWHEAD=$(cat "$REWRITTEN"/$OLDHEAD)
328+
else
329+
NEWHEAD=$OLDHEAD
330+
fi
326331
else
327332
NEWHEAD=$(git rev-parse HEAD)
328333
fi &&

t/t3404-rebase-interactive.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@ test_expect_success 'retain authorship when squashing' '
184184
git show HEAD | grep "^Author: Twerp Snog"
185185
'
186186

187+
test_expect_success '-p handles "no changes" gracefully' '
188+
HEAD=$(git rev-parse HEAD) &&
189+
git rebase -i -p HEAD^ &&
190+
test $HEAD = $(git rev-parse HEAD)
191+
'
192+
187193
test_expect_success 'preserve merges with -p' '
188194
git checkout -b to-be-preserved master^ &&
189195
: > unrelated-file &&

0 commit comments

Comments
 (0)