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

Re: apply --cached --whitespace=fix now failing on items added with "add -N"

From
Duy Nguyen <pclouds@gmail.com>
Date
Jun 22, 2015, 14:45 UTC
Message-ID
<CACsJy8BBxWme=y6jF_O74Jz37qPy=Sqf4w0cg-QLYzpxM5iwVw@mail.gmail.com>
In-Reply-To
<CACfKtTAvH7FH2AkC5hUNFEQ620gF401SNYaULLy62iE8S55-7A@mail.gmail.com>
On Mon, Jun 22, 2015 at 9:29 PM, Patrick Higgins <phiggins@google.com> wrote:
Show 22 quoted lines
> 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?

Probably fallout from this one, merged to 'master' about 5 weeks ago. I'll have a look at it tomorrow unless somebody does it first

d95d728 (diff-lib.c: adjust position of i-t-a entries in diff - 2015-03-16)
-- 
Duy
Previous: Patrick HigginsNext: Junio C Hamano
Message 2 of 28 in “apply --cached --whitespace=fix now failing on items added with "add -N"”
  1. Patrick HigginsJun 22, 2015
  2. Duy NguyenJun 22, 2015
  3. Junio C HamanoJun 22, 2015
  4. apply: fix adding new files on i-t-a entriesNguyễn Thái Ngọc Duy, Jun 23, 2015
  5. Junio C HamanoJun 23, 2015
  6. Junio C HamanoJun 23, 2015
  7. Junio C HamanoJun 24, 2015
  8. Duy NguyenJun 24, 2015
  9. Junio C HamanoJun 24, 2015
  10. Duy NguyenJun 25, 2015
  11. Junio C HamanoJun 25, 2015
  12. 0/8 Resurrect "diff-lib.c: adjust position of i-t-a entries in diff"Nguyễn Thái Ngọc Duy, Aug 22, 2015
  13. 1/8 blame: remove obsolete commentNguyễn Thái Ngọc Duy, Aug 22, 2015
  14. 2/8 Add and use convenient macro ce_intent_to_add()Nguyễn Thái Ngọc Duy, Aug 22, 2015
  15. 3/8 apply: fix adding new files on i-t-a entriesNguyễn Thái Ngọc Duy, Aug 22, 2015
  16. Junio C HamanoAug 25, 2015
  17. 4/8 apply: make sure check_preimage() does not leave empty file on errorNguyễn Thái Ngọc Duy, Aug 22, 2015
  18. Junio C HamanoAug 25, 2015
  19. 5/8 checkout(-index): do not checkout i-t-a entriesNguyễn Thái Ngọc Duy, Aug 22, 2015
  20. Junio C HamanoAug 25, 2015
  21. Duy NguyenNov 29, 2015
  22. Junio C HamanoNov 30, 2015
  23. 6/8 grep: make it clear i-t-a entries are ignoredNguyễn Thái Ngọc Duy, Aug 22, 2015
  24. 7/8 diff.h: extend "flags" field to 64 bits because we're out of bitsNguyễn Thái Ngọc Duy, Aug 22, 2015
  25. Junio C HamanoAug 25, 2015
  26. Duy NguyenAug 31, 2015
  27. Junio C HamanoAug 25, 2015
  28. Junio C HamanoAug 25, 2015

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.