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