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

Re: Regression in patch add?

From
Junio C Hamano <gitster@pobox.com>
Date
May 11, 2018, 02:47 UTC
Message-ID
<xmqqzi16hpr4.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<e8aedc6b-5b3e-cfb2-be9d-971bfd9adde8@talktalk.net>
Phillip Wood <phillip.wood@talktalk.net> writes:
> Yes, I think it probably makes sense to do that. Originally I didn't
> count empty lines as context lines in case the user accidentally added
> some empty lines at the end of the hunk but if 'git apply' does then I
> think 'git add -p' should as well

I am not sure if "adding to the tail" should be tolerated, but in any case, newer GNU diff can show an empty unaffected line as an empty line (unlike traditional unified context format in which such a line is expressed as a line with a lone SP on it), which is allowed as "implementation defined" by POSIX.1 [*1*]. Modern "git apply" knows about this.

If "add -p" parses a patch, it should learn to do so, too.
[Reference]
*1* http://pubs.opengroup.org/onlinepubs/9699919799/utilities/diff.html
Show 14 quoted lines
>
>> Meanwhile, I can easily configure my editor not to do this for `*.diff` files.
>> 
>> Thanks for your help, Phillip and Martin!
>
> Thanks for posting an example so we could test it, it makes it much
> easier to track the problem down
>
> Best Wishes
>
> Phillip
>
>> Mahmoud, does this also explain your problem as per your original post?
>> 
Previous: Phillip WoodNext: Phillip Wood
Message 12 of 22 in “Regression in patch add?”
  1. mqudsi@neosmart.netApr 15, 2018
  2. Martin ÅgrenApr 15, 2018
  3. Phillip WoodApr 16, 2018
  4. Phillip WoodApr 16, 2018
  5. Oliver Joseph AshMay 10, 2018
  6. Martin ÅgrenMay 10, 2018
  7. Oliver Joseph AshMay 10, 2018
  8. Martin ÅgrenMay 10, 2018
  9. Phillip WoodMay 10, 2018
  10. Oliver Joseph AshMay 10, 2018
  11. Phillip WoodMay 10, 2018
  12. Junio C HamanoMay 11, 2018
  13. Phillip WoodMay 11, 2018
  14. Oliver Joseph AshMay 10, 2018
  15. add -p: fix counting empty context lines in edited patchesPhillip Wood, Jun 1, 2018
  16. Jacob KellerJun 1, 2018
  17. Eric SunshineJun 1, 2018
  18. Phillip WoodJun 4, 2018
  19. Eric SunshineJun 4, 2018
  20. add -p: fix counting empty context lines in edited patchesPhillip Wood, Jun 11, 2018
  21. Jeff FelchnerJul 11, 2018
  22. Junio C HamanoJul 11, 2018

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.