Skip to content

Commit ab11903

Browse files
committed
git-rebase -i: clean-up error check codepath.
After replaying a single change, the code performed a number of checks, but some of them were for sanity checking, failures from which should make the command abort, and others were checks to see if it should make a new commit object. Stringing them together with "&&" was wrong. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 8ad1065 commit ab11903

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

git-rebase--interactive.sh

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -365,17 +365,26 @@ do
365365

366366
test -d "$DOTEST" || die "No interactive rebase running"
367367

368-
# commit if necessary
369-
git rev-parse --verify HEAD > /dev/null &&
370-
git update-index --refresh &&
371-
git diff-files --quiet &&
372-
! git diff-index --cached --quiet HEAD -- &&
373-
. "$DOTEST"/author-script && {
374-
test ! -f "$DOTEST"/amend || git reset --soft HEAD^
375-
} &&
376-
export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE &&
377-
if ! git commit --no-verify -F "$DOTEST"/message -e
368+
# Sanity check
369+
git rev-parse --verify HEAD >/dev/null ||
370+
die "Cannot read HEAD"
371+
git update-index --refresh && git diff-files --quiet ||
372+
die "Working tree is dirty"
373+
374+
# do we have anything to commit?
375+
if git diff-index --cached --quiet HEAD --
378376
then
377+
: Nothing to commit -- skip this
378+
else
379+
. "$DOTEST"/author-script ||
380+
die "Cannot find the author identity"
381+
if test -f "$DOTEST"/amend
382+
then
383+
git reset --soft HEAD^ ||
384+
die "Cannot rewind the HEAD"
385+
fi
386+
export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE &&
387+
git commit --no-verify -F "$DOTEST"/message -e ||
379388
die "Could not commit staged changes."
380389
fi
381390

0 commit comments

Comments
 (0)