Skip to content

Commit dbedf97

Browse files
spearcegitster
authored andcommitted
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>
1 parent c5b09fe commit dbedf97

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

git-rebase--interactive.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,22 +289,22 @@ do_next () {
289289
output git reset --soft HEAD^
290290
pick_one -n $sha1 || failed=t
291291
echo "$author_script" > "$DOTEST"/author-script
292-
case $failed in
293-
f)
292+
if test $failed = f
293+
then
294294
# This is like --amend, but with a different message
295295
eval "$author_script"
296296
GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \
297297
GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" \
298298
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
302303
cp "$MSG" "$GIT_DIR"/MERGE_MSG
303304
warn
304305
warn "Could not apply $sha1... $rest"
305306
die_with_patch $sha1 ""
306-
;;
307-
esac
307+
fi
308308
;;
309309
*)
310310
warn "Unknown command: $command $sha1 $rest"
@@ -372,7 +372,8 @@ do
372372
test ! -f "$DOTEST"/amend || git reset --soft HEAD^
373373
} &&
374374
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."
376377

377378
require_clean_work_tree
378379
do_rest

0 commit comments

Comments
 (0)