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

Re: amend warnings with no changes staged

From
Jeff King <peff@peff.net>
Date
Aug 8, 2019, 09:46 UTC
Message-ID
<20190808094607.GB12257@sigill.intra.peff.net>
In-Reply-To
<xmqqblx2jeh2.fsf@gitster-ct.c.googlers.com>
On Tue, Aug 06, 2019 at 12:11:53PM -0700, Junio C Hamano wrote:
Show 24 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> >   git commit -m 'buggy commit'
> >   echo fix >>file.c
> >   git commit --amend ;# oops, should have been "-a"
> >   git push
> >
> > But perhaps that gets to the heart of the matter. Could we perhaps be
> > providing a more detailed summary of what happened for an --amend? I.e.,
> > to summarize _both_ sets of changes (and if one set is empty, say so)?
> > ...
> > judgement about whether it's an error, since it may well be that you
> > were simply rewording the commit message).
> 
> Perhaps "git range-diff HEAD@{1}...HEAD" being an empty is a sign
> that either the user intentionally or accidentally did not do
> anything other than "touch"ing the commit.
> 
> "git commit --amend --[no-]range-diff" that shows what you changed
> with the amending may be an interesting possibility; I am not yet
> ready to seriously encourage anybody to explore it, though, because
> "git diff HEAD@{1}" is much easier to see what code got changed, but
> one (and probably only) downside is that it does not cover the
> change in the log message.
I hadn't even thought of range-diff.

Showing the commit message diff would be a big improvement. A range-diff would also show an update to the author (e.g., if you used --reset-author).

We don't really need the full power of range diff, though. After all, we know there are exactly two patches to compare, so we don't care about it trying to figure out which ones correlate (and it might even be a bad thing for it to decide that two entries don't match). So I think we'd probably want our own custom thing.

-Peff
Previous: Junio C Hamano
Message 13 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.