Re: git log --name-only improvement: show old file name in rename
- From
- Nathan Faulkner <natedogith1@gmail.com>
- Date
- May 16, 2024, 23:13 UTC
- Message-ID
- <c239ab15-4d48-4328-8bd5-8e2d77163e03@gmail.com>
- In-Reply-To
- <BL0PR11MB34608AE271344D508676D17A9D9C0@BL0PR11MB3460.namprd11.prod.outlook.com>
The documentation for --name-only says "Show only names of changed files." I would interpret this to mean "output the names of all files that changed", not "output the names of all files that changed, unless git detected it as renamed". --no-renames makes it behave as expected, but having to specify it isn't obvious. A warning in the documentation could help, but --no-renames should probably be included by default when --name-only is specified.
I ran into an issue today with code that expected git diff --name-only to output all changed files. A file was created and an unrelated file was deleted in the same commit, but they happened to be similar enough that git detected it as rename, and thus git diff --name-only indicated only one file changed when two files were actually changed.