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

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

From
Linus Torvalds <torvalds@osdl.org>
Date
Mar 25, 2006, 21:06 UTC
Message-ID
<Pine.LNX.4.64.0603251256330.15714@g5.osdl.org>
In-Reply-To
<7vslp6uvn1.fsf@assigned-by-dhcp.cox.net>
On Sat, 25 Mar 2006, Junio C Hamano wrote:
> 
> This is a replacement for my previous one, which reduces the
> changes to the testsuite.

Btw, your comment about the GNU diff @@-line simplification made me look at that again.

git-apply used to believe that a simplified line (ie with a single value) meant "x,x". While it seems that it really means "x,1".

Now, at worst, this would probably mean that some patches would get rejected (rather than mis-applied), so I think we've just never hit it. Also, with the default 3-line context I think that it simply _cannot_ be hit (since the only way that the result or source would have only one line in the resulting is it was the first line).

But if the "x" shorthand really means "x,1" (and I think you're right - using "-U 1" I can get that kind of shorthand) then apply.c should be fixed as follows (actual patch: removal of two characters).

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
diff --git a/apply.c b/apply.c
index 2da225a..e80cd15 100644
--- a/apply.c
+++ b/apply.c
@@ -693,7 +693,7 @@ static int parse_range(const char *line,
 	line += digits;
 	len -= digits;
 
-	*p2 = *p1;
+	*p2 = 1;
 	if (*line == ',') {
 		digits = parse_num(line+1, p2);
 		if (!digits)
Previous: Linus Torvalds
Message 22 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.