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

[PATCH] Fix amending of a commit with an empty message

From
Alex Riesen <raa.lkml@gmail.com>
Date
Feb 21, 2008, 20:38 UTC
Message-ID
<20080221203802.GB20143@steel.home>
In-Reply-To
<20080221203506.GA20143@steel.home>

This change probably does even more than that: it allows amending of anything, even of a commit which does not change anything.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---
Alex Riesen, Thu, Feb 21, 2008 21:35:06 +0100:
Show 9 quoted lines
> Junio C Hamano, Thu, Feb 21, 2008 21:23:10 +0100:
> > Alex Riesen <raa.lkml@gmail.com> writes:
> > >
> > > Well, it fails... In current master
> > 
> > Then please mark it with test_expect_failure.
> 
> That's because I expect it to be fixed (in the next mail)
> 

In this one. I am a bit unsure regarding the change (it looks a little too strong), even though it passes the test suite.

 builtin-commit.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index 065e1f7..ab3fd7b 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -520,6 +520,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
 
 		if (get_sha1(parent, sha1))
 			commitable = !!active_nr;
+		else if (amend)
+			commitable = 1;
 		else {
 			init_revisions(&rev, "");
 			rev.abbrev = 0;
-- 
1.5.4.2.204.g6d0ab
Previous: Alex RiesenNext: Junio C Hamano
Message 4 of 8 in “A test for commit --amend allowing changing of a very empty commit message”
  1. A test for commit --amend allowing changing of a very empty commit messageAlex Riesen, Feb 21, 2008
  2. Junio C HamanoFeb 21, 2008
  3. Alex RiesenFeb 21, 2008
  4. Fix amending of a commit with an empty messageAlex Riesen, Feb 21, 2008
  5. Junio C HamanoFeb 21, 2008
  6. Alex RiesenFeb 21, 2008
  7. Junio C HamanoFeb 21, 2008
  8. Johannes SchindelinFeb 21, 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.