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

Re: git full diff output issues..

From
Linus Torvalds <torvalds@osdl.org>
Date
May 26, 2005, 20:33 UTC
Message-ID
<Pine.LNX.4.58.0505261316250.2307@ppc970.osdl.org>
In-Reply-To
<Pine.LNX.4.60.0505262036500.16829@hermes-1.csi.cam.ac.uk>
On Thu, 26 May 2005, Anton Altaparmakov wrote:
Show 7 quoted lines
> 
> Given that git already has the metadata lines in the diff ("old mode", 
> "deleted file mode", etc) why not simply add another metadata line "name" 
> and what follows that is the name until an end of line character (or a NUL 
> if you want file names with embedded new lines).  You can then only emit 
> the "name" metadata line when no actual diff is present and hence the name 
> is uncertain.
Yes, that would work. 

However, I ended up just validating the name parsing by making sure that when I parse the "git --diff" line, I only take the name if I can see it being the same for both the old and the new. IOW, if I see

	diff --git a/hi b/hello
then I won't take it, but if I see
	diff --git hi there/I am/being difficult   oopsie dir/I am/being difficult

then I get "I am/being difficult" by virtue of checking the two names against each other.

This means, btw, that the "git --diff" format must _not_ do
	diff --git a/file /dev/null
	deleted file mode 100644

because in that case I don't trust the filename enough. Of course, this all only happens when deleting empty files, if the file had any contents, then I will see the unambiguos filename on the '---' line, and again be happy.

IOW, git-apply is being pretty anal about things, but it looks like that works out well.

			Linus
Previous: Anton AltaparmakovNext: Junio C Hamano
Message 6 of 13 in “git full diff output issues..”
  1. Linus TorvaldsMay 26, 2005
  2. Linus TorvaldsMay 26, 2005
  3. Junio C HamanoMay 26, 2005
  4. Junio C HamanoMay 26, 2005
  5. Anton AltaparmakovMay 26, 2005
  6. Linus TorvaldsMay 26, 2005
  7. Junio C HamanoMay 26, 2005
  8. Linus TorvaldsMay 26, 2005
  9. Junio C HamanoMay 26, 2005
  10. Junio C HamanoJun 5, 2005
  11. Linus TorvaldsJun 5, 2005
  12. Chris WedgwoodMay 26, 2005
  13. Linus TorvaldsMay 26, 2005

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.