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

Re: amend warnings with no changes staged

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Aug 6, 2019, 16:32 UTC
Message-ID
<b12f58f6-663a-bd0f-5854-d7ff0b83848b@gmail.com>
In-Reply-To
<xmqqh86vkl0j.fsf@gitster-ct.c.googlers.com>
On 06/08/2019 04:53, Junio C Hamano wrote:
Show 29 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
> 
>> Jonathan Nieder <jrnieder@gmail.com> writes:
>>
>>>>> Some non-judgemental descriptive output like
>>>>>
>>>>> 	$ git commit --amend --no-edit
>>>>> 	No changes.
>>>>> 	$
>>>>>
>>>>> would address this case, without bothering people who are doing it
>>>>> intentionally.  So I think there's room for a simple improvement here.
>>>>
>>>> I do that to refresh the committer timestamp.
>>>
>>> I do, too.  The proposal is, paraphrasing,
>>>
>>> 	$ git commit --amend --no-edit
>>> 	Ah, I see that you want me to refresh the committer timestamp.
>>> 	Done, as requested.
>>> 	$
>>
>> Ah, OK then.  I somehow misread "No changes." as an error message.
> 
> Well, on second thought, I think "fatal: no changes" that exits with
> non-zero, with "--force" as an escape hatch for those who want to
> refresh the committer timestamp, would probably be more in line with
> the expectation Lukas had when this thread was started, and I further
> suspect that it might be a bit more end-user friendly.

I agree that this would be the must user friendly way of doing it. I think refreshing the timestamp is probably a niche use of '--amend' (out of interest what the the motivation for doing that?) although it does seem to popular with the other contributors to this thread. We could always have a transition period with an opt-in config variable. I find the current behavior quite annoying when I've forgotten to stage anything as there is no indication the the commit's content is unchanged. I've been using a wrapper script that errors out if there are no new changes staged with --amend --no-edit and found it very helpful (as is a proper --reword option rather than having to give --amend --only)

Best Wishes
Phillip
Show 13 quoted lines
> 
> It is a backward incompatible behaviour, but I suspect that if I
> were inventing "commit --amend" today, unlike 8588452c ("git-commit
> --amend: allow empty commit.", 2006-03-04), I probably would design
> it that way.  After all, failing and stopping is always a safer
> option than going ahead with or without a report.
> 
> I am not sure which one between "go ahead anyway but report" and
> "fail by default but allow forcing" I would prefer more.  At least
> not yet.  But I won't rule the latter out at this point.
> 
> Thanks.
> 
Previous: Junio C HamanoNext: Jeff King
Message 10 of 13 in “amend warnings with no changes staged”
  1. Lukas GrossAug 6, 2019
  2. Jonathan NiederAug 6, 2019
  3. Lukas GrossAug 6, 2019
  4. Jonathan NiederAug 6, 2019
  5. Jonathan NiederAug 6, 2019
  6. Junio C HamanoAug 6, 2019
  7. Jonathan NiederAug 6, 2019
  8. Junio C HamanoAug 6, 2019
  9. Junio C HamanoAug 6, 2019
  10. Phillip WoodAug 6, 2019
  11. Jeff KingAug 6, 2019
  12. Junio C HamanoAug 6, 2019
  13. Jeff KingAug 8, 2019

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.