summaryrefslogtreecommitdiff
path: root/git-rebase--interactive.sh
diff options
context:
space:
mode:
authorAndrew Wong <andrew.kw.w@gmail.com>2011-11-30 10:52:51 -0500
committerJunio C Hamano <gitster@pobox.com>2011-11-30 11:30:53 -0800
commit0becb3e4b94f19358f66ec2f4bbbf89904251bf5 (patch)
tree649429598473654373c7d224ef6e3f106a3a23f0 /git-rebase--interactive.sh
parent1e501a7c47ad5ada53d3b1acfb9f131f76e969ec (diff)
downloadgit-0becb3e4b94f19358f66ec2f4bbbf89904251bf5.tar.gz
rebase -i: interrupt rebase when "commit --amend" failed during "reword"aw/rebase-i-stop-on-failure-to-amend
"commit --amend" could fail in cases like the user empties the commit message, or pre-commit failed. When it fails, rebase should be interrupted and alert the user, rather than ignoring the error and continue on rebasing. This also gives users a way to gracefully interrupt a "reword" if they decided they actually want to do an "edit", or even "rebase --abort". Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-rebase--interactive.sh')
-rw-r--r--git-rebase--interactive.sh36
1 files changed, 23 insertions, 13 deletions
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 94f36c254c..863597c619 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -143,6 +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"
@@ -395,7 +410,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)
@@ -404,19 +425,8 @@ do_next () {
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