Re: git log --name-only improvement: show old file name in rename
- From
- Ed 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.