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, 05:21 UTC
Message-ID
<alpine.LFD.0.9999.0712202110350.21557@woody.linux-foundation.org>
In-Reply-To
<alpine.LFD.0.9999.0712202054350.21557@woody.linux-foundation.org>
On Thu, 20 Dec 2007, Linus Torvalds wrote:
> 
> Not that it matters in real life, since nobody uses -U0, and "git blame" 
> won't care. But let's get it right anyway ;)
.. and here's a test-case to see the *impact* of this whole issue:
	yes | head -1000 > a
	yes | head -2000 > b
	git diff -U0 a b | grep @@
	diff -U0 a b | grep @@
and notice the differences.

Both will add a thousand lines of "y", but the "git diff" will add it at a different point, ie git says:

	@@ -488,0 +489,1000 @@ y
while a non-tail-optimizing diff will say
	@@ -1000,0 +1001,1000 @@
which may be a bit more obvious.

Both answers are *correct*, though. The particular choice of "insert at line 489, after line 488" is a bit odd, but is because we don't actually search to exactly the beginning of where the differences started, we search in blocks of 1kB and then we go forward to the next newline.

(We could also go to exactly where the differences started, and if the previous character was a newline or the beginning of the file, we'd not move forward at all, and then we'd get a more "logical" diff of inserting at the beginning).

Considering that the answer is correct, and this only happens for insane cases anyway, I don't really think anybody cares, but it's an interesting case nonetheless.

			Linus
Previous: Linus TorvaldsNext: Linus Torvalds
Message 7 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.