@@ -493,25 +493,28 @@ do_next () {
493493 author_script_content=$( get_author_ident_from_commit HEAD)
494494 echo " $author_script_content " > " $author_script "
495495 eval " $author_script_content "
496- output git reset --soft HEAD^
497- pick_one -n $sha1 || die_failed_squash $sha1 " $rest "
496+ if ! pick_one -n $sha1
497+ then
498+ git rev-parse --verify HEAD > " $amend "
499+ die_failed_squash $sha1 " $rest "
500+ fi
498501 case " $( peek_next_command) " in
499502 squash|s|fixup|f)
500503 # This is an intermediate commit; its message will only be
501504 # used in case of trouble. So use the long version:
502- do_with_author output git commit --no-verify -F " $squash_msg " ||
505+ do_with_author output git commit --amend -- no-verify -F " $squash_msg " ||
503506 die_failed_squash $sha1 " $rest "
504507 ;;
505508 * )
506509 # This is the final command of this squash/fixup group
507510 if test -f " $fixup_msg "
508511 then
509- do_with_author git commit --no-verify -F " $fixup_msg " ||
512+ do_with_author git commit --amend -- no-verify -F " $fixup_msg " ||
510513 die_failed_squash $sha1 " $rest "
511514 else
512515 cp " $squash_msg " " $GIT_DIR " /SQUASH_MSG || exit
513516 rm -f " $GIT_DIR " /MERGE_MSG
514- do_with_author git commit --no-verify -e ||
517+ do_with_author git commit --amend -- no-verify -F " $GIT_DIR " /SQUASH_MSG -e ||
515518 die_failed_squash $sha1 " $rest "
516519 fi
517520 rm -f " $squash_msg " " $fixup_msg "
@@ -748,21 +751,19 @@ In both case, once you're done, continue with:
748751 fi
749752 . " $author_script " ||
750753 die " Error trying to find the author identity to amend commit"
751- current_head=
752754 if test -f " $amend "
753755 then
754756 current_head=$( git rev-parse --verify HEAD)
755757 test " $current_head " = $( cat " $amend " ) ||
756758 die " \
757759You have uncommitted changes in your working tree. Please, commit them
758760first and then run 'git rebase --continue' again."
759- git reset --soft HEAD^ ||
760- die " Cannot rewind the HEAD"
761+ do_with_author git commit --amend --no-verify -F " $msg " -e ||
762+ die " Could not commit staged changes."
763+ else
764+ do_with_author git commit --no-verify -F " $msg " -e ||
765+ die " Could not commit staged changes."
761766 fi
762- do_with_author git commit --no-verify -F " $msg " -e || {
763- test -n " $current_head " && git reset --soft $current_head
764- die " Could not commit staged changes."
765- }
766767 fi
767768
768769 record_in_rewritten " $( cat " $state_dir " /stopped-sha) "
0 commit comments