@matheusbsbs / matheus-bagliano / commits / dbedf9729b
Fork 0

Catch and handle git-commit failures in git-rebase --interactive

If git-commit fails for any reason then git-rebase needs to stop and not plow through the rest of the series. Its unlikely that a future git-commit will succeed if the current attempt failed. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Shawn O. Pearce committed Dec 19, 2007 at 01:45 UTC dbedf9729bd349c7667630d50728214ed531f74d
1 file changed +9 -8
git-rebase--interactive.sh
+9 -8
@@ -289,22 +289,22 @@ do_next () {
289 output git reset --soft HEAD^
290 pick_one -n $sha1 || failed=t
291 echo "$author_script" > "$DOTEST"/author-script
292 - case $failed in
293 - f)
292 + if test $failed = f
293 + then
294 # This is like --amend, but with a different message
295 eval "$author_script"
296 GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \
297 GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" \
298 GIT_AUTHOR_DATE="$GIT_AUTHOR_DATE" \
299 - $USE_OUTPUT git commit --no-verify -F "$MSG" $EDIT_COMMIT
300 - ;;
301 - t)
299 + $USE_OUTPUT git commit --no-verify -F "$MSG" $EDIT_COMMIT || failed=t
300 + fi
301 + if test $failed = t
302 + then
303 cp "$MSG" "$GIT_DIR"/MERGE_MSG
304 warn
305 warn "Could not apply $sha1... $rest"
306 die_with_patch $sha1 ""
306 - ;;
307 - esac
307 + fi
308 ;;
309 *)
310 warn "Unknown command: $command $sha1 $rest"
@@ -372,7 +372,8 @@ do
372 test ! -f "$DOTEST"/amend || git reset --soft HEAD^
373 } &&
374 export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE &&
375 - git commit --no-verify -F "$DOTEST"/message -e
375 + git commit --no-verify -F "$DOTEST"/message -e ||
376 + die "Could not commit staged changes."
377
378 require_clean_work_tree
379 do_rest