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>
Junio C Hamano committed
Dec 30, 2007 at 12:51 UTC
ab11903225270be7001b8c92f6ac4e165eaf4ecf
1 file changed
+19
-10
git-rebase--interactive.sh
+19
-10
@@ -365,17 +365,26 @@ do
365
366
test -d "$DOTEST" || die "No interactive rebase running"
367
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 --
376
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 ||
388
die "Could not commit staged changes."
389
fi
390