@matheusbsbs / matheus-bagliano / commits / 34454e858d
Fork 0

rebase -p -i: handle "no changes" gracefully

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>

Johannes Schindelin committed Dec 17, 2007 at 21:01 UTC 34454e858d2a648b0a6ce56acd9def84bd2a8712
2 files changed +12 -1
git-rebase--interactive.sh
+6 -1
@@ -322,7 +322,12 @@ do_next () {
322 test -f "$DOTEST"/current-commit &&
323 current_commit=$(cat "$DOTEST"/current-commit) &&
324 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
331 else
332 NEWHEAD=$(git rev-parse HEAD)
333 fi &&
t/t3404-rebase-interactive.sh
+6
@@ -184,6 +184,12 @@ test_expect_success 'retain authorship when squashing' '
184 git show HEAD | grep "^Author: Twerp Snog"
185 '
186
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 +
193 test_expect_success 'preserve merges with -p' '
194 git checkout -b to-be-preserved master^ &&
195 : > unrelated-file &&