Subject: Filenames and prefixes in extended diffs

From: Andreas Gruenbacher <[email-masked]>
Date: Wed, 13 Jan 2010 17:13:05 +0100

I'm having a problem filename prefixes in git's extended diffs for patches 
which rename or copy files: those patches include the old and new filenames in 
"rename from", "rename to", "copy from", and "copy to" headers, e.g.,

	$ git show -M
	diff --git a/f b/g
	similarity index 87%
	rename from f
	rename to g
	index f00c965..3bb459b 100644
	--- a/f
	+++ b/g
	@@ -8,3 +8,4 @@
	 8
	 9
	 10
	+11

Unlike the filenames in the "diff --git", "---", and "+++" headers, the 
"rename from", "rename to", "copy from", and "copy to" filenames do not 
include prefixes.

Now when applying a patch, GNU patch's -p option determines the number of 
pathname components to strip off from filenames.  This obviously can't work 
consistently for the prefixed and prefix-less headers.

Can git be changed to include prefixes in all filenames?

The only alternative I see is to ignore the filenames in the rename/copy 
headers and rely only on the "diff --git" line.  (The "---" and "+++" headers 
are not guaranteed to exist.)  What's worse, as already discussed here, the 
"diff --git" line uses space as a separator between filenames yet it doesn't 
quote spaces in filenames.  When being forced to ignore rename/copy headers, 
this defect would make things much worse.

Any ideas?

Thanks,
Andreas