Skip to content

Commit ea2408b

Browse files
committed
Merge branch 'dp/maint-rebase-fix' into maint
* dp/maint-rebase-fix: git-rebase--interactive: auto amend only edited commit git-rebase-interactive: do not squash commits on abort
2 parents 2ba3d5d + c14c3c8 commit ea2408b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

git-rebase--interactive.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ do_next () {
284284
pick_one $sha1 ||
285285
die_with_patch $sha1 "Could not apply $sha1... $rest"
286286
make_patch $sha1
287-
: > "$DOTEST"/amend
287+
git rev-parse --verify HEAD > "$DOTEST"/amend
288288
warn "Stopped at $sha1... $rest"
289289
warn "You can amend the commit now, with"
290290
warn
@@ -427,14 +427,22 @@ do
427427
else
428428
. "$DOTEST"/author-script ||
429429
die "Cannot find the author identity"
430+
amend=
430431
if test -f "$DOTEST"/amend
431432
then
433+
amend=$(git rev-parse --verify HEAD)
434+
test "$amend" = $(cat "$DOTEST"/amend) ||
435+
die "\
436+
You have uncommitted changes in your working tree. Please, commit them
437+
first and then run 'git rebase --continue' again."
432438
git reset --soft HEAD^ ||
433439
die "Cannot rewind the HEAD"
434440
fi
435441
export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE &&
436-
git commit --no-verify -F "$DOTEST"/message -e ||
437-
die "Could not commit staged changes."
442+
git commit --no-verify -F "$DOTEST"/message -e || {
443+
test -n "$amend" && git reset --soft $amend
444+
die "Could not commit staged changes."
445+
}
438446
fi
439447

440448
require_clean_work_tree

0 commit comments

Comments
 (0)