git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] rebase -i: interrupt rebase when "commit --amend" failed

From
Andrew Wong <andrew.kw.w@gmail.com>
Date
Jul 25, 2011, 03:38 UTC
Message-ID
<1311565113-5022-3-git-send-email-andrew.kw.w@gmail.com>
In-Reply-To
<1311565113-5022-1-git-send-email-andrew.kw.w@gmail.com>

"commit --amend" could fail if the user empties the commit message. Although this is not a real error, it seems to make more sense to interrupt the rebasing, rather than ignoring the error and continue on rebasing. This 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>
---
 git-rebase--interactive.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index df9f7e9..7055ef4 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -397,7 +397,8 @@ do_next () {
 		mark_action_done
 		pick_one $sha1 ||
 			die_with_patch $sha1 "Could not apply $sha1... $rest"
-		git commit $commit_verbose_flag --amend --no-post-rewrite
+		git commit $commit_verbose_flag --amend --no-post-rewrite ||
+			die_with_patch $sha1 "Cannot amend commit after successfully picking $sha1... $rest"
 		record_in_rewritten $sha1
 		;;
 	edit|e)
-- 
1.7.2.2
Previous: Andrew WongNext: Sverre Rabbelier
Message 3 of 4 in “rebase -i: Some nice-to-have behaviors for "reword"”
  1. 0/2 rebase -i: Some nice-to-have behaviors for "reword"Andrew Wong, Jul 25, 2011
  2. 1/2 rebase -i: run "commit --amend" with verbose if rebase was called with -vAndrew Wong, Jul 25, 2011
  3. 2/2 rebase -i: interrupt rebase when "commit --amend" failedAndrew Wong, Jul 25, 2011
  4. Sverre RabbelierJul 30, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.