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

Re: Use a *real* built-in diff generator

From
DLDavide Libenzi <davidel@xmailserver.org>
Date
Mar 26, 2006, 05:33 UTC
Message-ID
<Pine.LNX.4.64.0603252130190.12437@alien.or.mcafeemobile.com>
In-Reply-To
<Pine.LNX.4.64.0603251040190.15714@g5.osdl.org>
On Sat, 25 Mar 2006, Linus Torvalds wrote:
Show 23 quoted lines
> Btw, git-apply does it, and it's actually quite simple: the code to handle
> the "\ No newline" case is literally just this:
>
>                /*
>                 * "plen" is how much of the line we should use for
>                 * the actual patch data. Normally we just remove the
>                 * first character on the line, but if the line is
>                 * followed by "\ No newline", then we also remove the
>                 * last one (which is the newline, of course).
>                 */
>                plen = len-1;
>                if (len < size && patch[len] == '\\')
>                        plen--;
>
> if we just remove the last '\n' on a line, if the _next_ line starts with
> a '\\' (so the git-apply code actually depends on knowing that the patch
> text is dense, and that it's also padded out so that you can look one byte
> past the end of the diff and it won't be a '\\').
>
> I don't know how well that fits into xpatch (I never looked at the patch
> side, since I already had my own ;), but my point being that handling this
> special case _can_ be very simple if the data structures are just set up
> for it.

Yeah, should be a pretty trivial fix in the xpatch parsing code. Thanks for remembering me the missing-eol issue, that fell forgotten somewhere in my todo list :D

- Davide
Previous: Linus TorvaldsNext: Junio C Hamano
Message 18 of 22 in “Use a *real* built-in diff generator”
  1. Linus TorvaldsMar 25, 2006
  2. Junio C HamanoMar 25, 2006
  3. Junio C HamanoMar 25, 2006
  4. Linus TorvaldsMar 25, 2006
  5. Davide LibenziMar 25, 2006
  6. Marco CostalbaMar 25, 2006
  7. Alex RiesenMar 25, 2006
  8. Linus TorvaldsMar 25, 2006
  9. Morten WelinderMar 25, 2006
  10. Linus TorvaldsMar 25, 2006
  11. Linus TorvaldsMar 25, 2006
  12. Davide LibenziMar 25, 2006
  13. Linus TorvaldsMar 25, 2006
  14. Davide LibenziMar 26, 2006
  15. Ralf BaechleMar 26, 2006
  16. Petr BaudisMar 26, 2006
  17. Linus TorvaldsMar 25, 2006
  18. Davide LibenziMar 26, 2006
  19. Junio C HamanoMar 25, 2006
  20. Junio C HamanoMar 25, 2006
  21. Linus TorvaldsMar 25, 2006
  22. Linus TorvaldsMar 25, 2006

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.