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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 21, 2008, 22:01 UTC
Message-ID
<7v8x1et1dj.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20080221213204.GC20143@steel.home>
Alex Riesen <raa.lkml@gmail.com> writes:
Show 10 quoted lines
>> Having said that, here is a quiz.  When the user says "git
>> commit --amend", what are the valid reasons not to allow it,
>> other than:
>> 
>>  - the index is unmerged.
>>  - the branch is yet to be born.
>
> There are no tree changes in the commit to be amended.
> And if there is a strong wish to do just the amendment,
> there is always --allow-empty.

If the original commit had some changes, but the final tree, after hacking, experimenting and fixing, ended up in the same shape as the parent's, the user might rather want to "reset HEAD^" away the commit than amending now-empty commit. Erroring out when --allow-empty is not given (like we currently do) would be sensible in such a case.

However, if the original commit was made with --allow-empty, it might have been done for a reason, and I was not sure if forcing the user to say --allow-empty while amending (like we currently do) was such a good idea. The user previously may have created that empty (in content changes) commit to piss in the snow, or perhaps the empty commit is due to foreign SCM import, and the user may be trying to improve the log message that is attached to it. The user might even be an automated script in the case of foreign SCM import, but admittedly, it could choose to always say --allow-empty.

That was the motivation behind that quiz.
Previous: Alex RiesenNext: Johannes Schindelin
Message 7 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.