From: Junio C Hamano Date: Wed, 28 Dec 2011 19:32:34 +0000 (-0800) Subject: Merge branch 'aw/rebase-i-stop-on-failure-to-amend' into maint X-Git-Tag: v1.7.8.2~20 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/d9d73b37f34e2e366357b99a6ac74a09681b0ab8?hp=-c Merge branch 'aw/rebase-i-stop-on-failure-to-amend' into maint * aw/rebase-i-stop-on-failure-to-amend: rebase -i: interrupt rebase when "commit --amend" failed during "reword" --- d9d73b37f34e2e366357b99a6ac74a09681b0ab8 diff --combined git-rebase--interactive.sh index 804001bb4e,863597c619..5812222eb9 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@@ -143,6 -143,21 +143,21 @@@ die_with_patch () die "$2" } + exit_with_patch () { + echo "$1" > "$state_dir"/stopped-sha + make_patch $1 + git rev-parse --verify HEAD > "$amend" + warn "You can amend the commit now, with" + warn + warn " git commit --amend" + warn + warn "Once you are satisfied with your changes, run" + warn + warn " git rebase --continue" + warn + exit $2 + } + die_abort () { rm -rf "$state_dir" die "$1" @@@ -161,19 -176,6 +176,19 @@@ do_with_author () ) } +git_sequence_editor () { + if test -z "$GIT_SEQUENCE_EDITOR" + then + GIT_SEQUENCE_EDITOR="$(git config sequence.editor)" + if [ -z "$GIT_SEQUENCE_EDITOR" ] + then + GIT_SEQUENCE_EDITOR="$(git var GIT_EDITOR)" || return $? + fi + fi + + eval "$GIT_SEQUENCE_EDITOR" '"$@"' +} + pick_one () { ff=--ff case "$1" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac @@@ -408,7 -410,13 +423,13 @@@ do_next () mark_action_done pick_one $sha1 || die_with_patch $sha1 "Could not apply $sha1... $rest" - git commit --amend --no-post-rewrite + git commit --amend --no-post-rewrite || { + warn "Could not amend commit after successfully picking $sha1... $rest" + warn "This is most likely due to an empty commit message, or the pre-commit hook" + warn "failed. If the pre-commit hook failed, you may need to resolve the issue before" + warn "you are able to reword the commit." + exit_with_patch $sha1 1 + } record_in_rewritten $sha1 ;; edit|e) @@@ -417,19 -425,8 +438,8 @@@ mark_action_done pick_one $sha1 || die_with_patch $sha1 "Could not apply $sha1... $rest" - echo "$sha1" > "$state_dir"/stopped-sha - make_patch $sha1 - git rev-parse --verify HEAD > "$amend" warn "Stopped at $sha1... $rest" - warn "You can amend the commit now, with" - warn - warn " git commit --amend" - warn - warn "Once you are satisfied with your changes, run" - warn - warn " git rebase --continue" - warn - exit 0 + exit_with_patch $sha1 0 ;; squash|s|fixup|f) case "$command" in @@@ -845,7 -842,7 +855,7 @@@ has_action "$todo" | die_abort "Nothing to do" cp "$todo" "$todo".backup -git_editor "$todo" || +git_sequence_editor "$todo" || die_abort "Could not execute editor" has_action "$todo" ||