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

Re: git log --name-only improvement: show old file name in rename

From
EAEd Avis <ed.avis@qmaw.com>
Date
Jun 15, 2020, 07:36 UTC
Message-ID
<BL0PR11MB34608AE271344D508676D17A9D9C0@BL0PR11MB3460.namprd11.prod.outlook.com>
In-Reply-To
<xmqqh7vg2p4p.fsf@gitster.c.googlers.com>

Thanks all for your replies to this.  I hoped that --name-only could show when a filename was removed, as well as when it was added.  If you delete a file in one commit then add it with a new name in the next, both filenames appear in the log.  If these happen in a single commit, only one does.  And in fact it's not predictable whether you will get one filename or two: it depends on rename detection.  Sometimes if a file is changed and moved to a new name, git log --name-only will show only the new name in the log, but at other times, if git doesn't detect it as a rename, both filenames appear.  This feels more like an implementation detail than a deliberate choice.

I accept that scripts may rely on the current behaviour, though I would be surprised to find a script that depended on *not* seeing the old filename printed.

Anyway, if it shouldn't change, or if it cannot change because of backwards compatibility, the manual page could be improved:
           --name-only
           Show only names of changed or added files.
           If a file is removed, its name is also printed, unless this is detected
           as a rename, in which case only the new name is printed.
That would be enough to direct users towards something more suitable like --compact-summary.
Previous: Junio C HamanoNext: Nathan Faulkner
Message 5 of 9 in “git log --name-only improvement: show old file name in rename”
  1. Ed AvisJun 11, 2020
  2. Junio C HamanoJun 11, 2020
  3. Philip OakleyJun 12, 2020
  4. Junio C HamanoJun 12, 2020
  5. Ed AvisJun 15, 2020
  6. Nathan FaulknerMay 16, 2024
  7. Re*: git log --name-only improvement: show old file name in renameJunio C Hamano, May 17, 2024
  8. Nathan FaulknerMay 18, 2024
  9. Junio C HamanoMay 18, 2024

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.