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

[PATCH v2] don't allow 'commit --amend' during rebase conflict resolution

From
Dmitry Potapov <dpotapov@gmail.com>
Date
Jun 26, 2008, 13:33 UTC
Message-ID
<20080626133358.GG5737@dpotapov.dyndns.org>
In-Reply-To
<20080626121303.GF8610@mit.edu>

Running 'commit --amend' during git rebase is almost certainly a mistake, which causes that two consequent patches are squashed together. Moreover, the commit message of the second commit is silently lost. It is almost certainly not what the user expects. In that very unlikely case when you really want to combine two patches during rebase conflict resolution, you can do that using "git reset --soft HEAD^" followed by "git commit". ---

On Thu, Jun 26, 2008 at 08:13:03AM -0400, Theodore Tso wrote:
> 
> In fact, we do this already for git-merge.  Why not just do the same
> thing in the middle of a merge conflict with git-rebase?

Thank you for suggestion. I have corrected my patch to so the same as we do in the case of git-merge conflict. MERGE_MSG is already removed on successful commit, so the patch is very simple now.

 builtin-commit.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index e3ad38b..6d1d955 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -725,6 +725,10 @@ static int parse_and_validate_options(int argc, const char *argv[],
 		die("You have nothing to amend.");
 	if (amend && in_merge)
 		die("You are in the middle of a merge -- cannot amend.");
+	/* no MERGE_HEAD but MERGE_MSG means a conflict during rebase */
+	if (amend && !access(git_path("MERGE_MSG"), F_OK))
+		die("You are in the middle of a rebase conflict -- "
+			"cannot amend.");
 
 	if (use_message)
 		f++;
-- 
1.5.6.60.gbc566
Previous: Theodore Tso
Message 7 of 7 in “git rebase interactive: usability issue”
  1. Dmitry PotapovJun 25, 2008
  2. Johannes SchindelinJun 26, 2008
  3. Junio C HamanoJun 26, 2008
  4. Avery PennarunJun 26, 2008
  5. Dmitry PotapovJun 26, 2008
  6. Theodore TsoJun 26, 2008
  7. don't allow 'commit --amend' during rebase conflict resolutionDmitry Potapov, Jun 26, 2008

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.