From: Davide Libenzi Date: Sun, 26 Mar 2006 05:33:36 GMT Subject: Re: Use a *real* built-in diff generator Message-ID: In-Reply-To: On Sat, 25 Mar 2006, Linus Torvalds wrote: > 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