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

Re: Linux 2.6.24-rc6

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Dec 21, 2007, 04:58 UTC
Message-ID
<alpine.LFD.0.9999.0712202054350.21557@woody.linux-foundation.org>
In-Reply-To
<alpine.LFD.0.9999.0712202009290.21557@woody.linux-foundation.org>
On Thu, 20 Dec 2007, Linus Torvalds wrote:
>
> And here's the git patch to avoid this optimization when there is 
> context.

Actually, the code to finding one '\n' is still needed to avoid the (pathological) case of getting a "\No newline", so scrap that one which was too aggressive, and use this (simpler) one instead.

Not that it matters in real life, since nobody uses -U0, and "git blame" won't care. But let's get it right anyway ;)

This whole function has had more bugs than it has lines.
		Linus
---
 xdiff-interface.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/xdiff-interface.c b/xdiff-interface.c
index 9ee877c..711029e 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -115,15 +115,18 @@ static void trim_common_tail(mmfile_t *a, mmfile_t *b, long ctx)
 	char *bp = b->ptr + b->size;
 	long smaller = (a->size < b->size) ? a->size : b->size;
 
+	if (ctx)
+		return;
+
 	while (blk + trimmed <= smaller && !memcmp(ap - blk, bp - blk, blk)) {
 		trimmed += blk;
 		ap -= blk;
 		bp -= blk;
 	}
 
-	while (recovered < trimmed && 0 <= ctx)
+	while (recovered < trimmed)
 		if (ap[recovered++] == '\n')
-			ctx--;
+			break;
 	a->size -= (trimmed - recovered);
 	b->size -= (trimmed - recovered);
 }
Previous: Kyle McMartinNext: Linus Torvalds
Message 6 of 9 in “Re: Linux 2.6.24-rc6”
  1. Linus TorvaldsDec 21, 2007
  2. Kyle McMartinDec 21, 2007
  3. Linus TorvaldsDec 21, 2007
  4. Linus TorvaldsDec 21, 2007
  5. Kyle McMartinDec 21, 2007
  6. Linus TorvaldsDec 21, 2007
  7. Linus TorvaldsDec 21, 2007
  8. Linus TorvaldsDec 21, 2007
  9. Junio C HamanoDec 21, 2007

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.