@@ -143,6 +143,21 @@ die_with_patch () {
143143 die " $2 "
144144}
145145
146+ exit_with_patch () {
147+ echo " $1 " > " $state_dir " /stopped-sha
148+ make_patch $1
149+ git rev-parse --verify HEAD > " $amend "
150+ warn " You can amend the commit now, with"
151+ warn
152+ warn " git commit --amend"
153+ warn
154+ warn " Once you are satisfied with your changes, run"
155+ warn
156+ warn " git rebase --continue"
157+ warn
158+ exit $2
159+ }
160+
146161die_abort () {
147162 rm -rf " $state_dir "
148163 die " $1 "
@@ -408,7 +423,13 @@ do_next () {
408423 mark_action_done
409424 pick_one $sha1 ||
410425 die_with_patch $sha1 " Could not apply $sha1 ... $rest "
411- git commit --amend --no-post-rewrite
426+ git commit --amend --no-post-rewrite || {
427+ warn " Could not amend commit after successfully picking $sha1 ... $rest "
428+ warn " This is most likely due to an empty commit message, or the pre-commit hook"
429+ warn " failed. If the pre-commit hook failed, you may need to resolve the issue before"
430+ warn " you are able to reword the commit."
431+ exit_with_patch $sha1 1
432+ }
412433 record_in_rewritten $sha1
413434 ;;
414435 edit|e)
@@ -417,19 +438,8 @@ do_next () {
417438 mark_action_done
418439 pick_one $sha1 ||
419440 die_with_patch $sha1 " Could not apply $sha1 ... $rest "
420- echo " $sha1 " > " $state_dir " /stopped-sha
421- make_patch $sha1
422- git rev-parse --verify HEAD > " $amend "
423441 warn " Stopped at $sha1 ... $rest "
424- warn " You can amend the commit now, with"
425- warn
426- warn " git commit --amend"
427- warn
428- warn " Once you are satisfied with your changes, run"
429- warn
430- warn " git rebase --continue"
431- warn
432- exit 0
442+ exit_with_patch $sha1 0
433443 ;;
434444 squash|s|fixup|f)
435445 case " $command " in
0 commit comments