apply --cached --whitespace=fix now failing on items added with "add -N"
- From
- Patrick Higgins <phiggins@google.com>
- Date
- Jun 22, 2015, 14:29 UTC
- Message-ID
- <CACfKtTAvH7FH2AkC5hUNFEQ620gF401SNYaULLy62iE8S55-7A@mail.gmail.com>
I like to use git to remove trailing whitespace from my files. I use the following ~/.gitconfig to make this convenient:
[alias]
wsadd = "!sh -c 'git diff -- \"$@\" | git apply --cached
--whitespace=fix;\
git checkout -- ${1-.} \"$@\"' -"The wsadd alias doesn't work with new files, so I have to use "git add -N" on them first. As of a week or two ago, the "apply --cached" step now fails with the following, assuming a new file named bar containing "foo " has been added with "add -N":
$ git diff -- "$@" | git apply --cached --whitespace=fix <stdin>:7: trailing whitespace. foo error: bar: already exists in index
The final "git checkout" at the end of wsadd truncates my file. I've changed the ";" to a "&&" to fix the truncation.
Were there any recent changes to "git apply" that might have caused this?
$ git --version git version 2.4.3.573.g4eafbef $ uname -a Linux <redacted> 3.13.0-53-generic #89-Ubuntu SMP Wed May 20 10:34:39 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux