Merge branch 'jc/apply-binary-p0' into maint-1.7.11
authorJunio C Hamano <gitster@pobox.com>
Wed, 12 Sep 2012 21:00:52 +0000 (14:00 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Sep 2012 21:00:53 +0000 (14:00 -0700)
"git apply -p0" did not parse pathnames on "diff --git" line
correctly. This caused patches that had pathnames in no other
places to be mistakenly rejected (most notably, binary patch that
does not rename nor change mode). Textual patches, renames or mode
changes have preimage and postimage pathnames in different places in
a form that can be parsed unambiguously and did not suffer from this
problem.

* jc/apply-binary-p0:
apply: compute patch->def_name correctly under -p0

1  2 
builtin/apply.c
t/t4103-apply-binary.sh
diff --cc builtin/apply.c
Simple merge
index 99627bc6d69f17a8dce0ad318764e32cd9d9f507,1b420e3b5fc2a7130d2b10bcd5660670b9d780c8..b1b906b1bb58ad9f96ee8f6146a2d49ec999e3f2
@@@ -8,30 -8,28 +8,28 @@@ test_description='git apply handling bi
  '
  . ./test-lib.sh
  
- # setup
- cat >file1 <<EOF
- A quick brown fox jumps over the lazy dog.
- A tiny little penguin runs around in circles.
- There is a flag with Linux written on it.
- A slow black-and-white panda just sits there,
- munching on his bamboo.
- EOF
- cat file1 >file2
- cat file1 >file4
- test_expect_success 'setup' "
+ test_expect_success 'setup' '
+       cat >file1 <<-\EOF &&
+       A quick brown fox jumps over the lazy dog.
+       A tiny little penguin runs around in circles.
+       There is a flag with Linux written on it.
+       A slow black-and-white panda just sits there,
+       munching on his bamboo.
+       EOF
+       cat file1 >file2 &&
+       cat file1 >file4 &&
        git update-index --add --remove file1 file2 file4 &&
-       git commit -m 'Initial Version' 2>/dev/null &&
+       git commit -m "Initial Version" 2>/dev/null &&
  
        git checkout -b binary &&
-       "$PERL_PATH" -pe 'y/x/\000/' <file1 >file3 &&
 -      perl -pe "y/x/\000/" <file1 >file3 &&
++      "$PERL_PATH" -pe "y/x/\000/" <file1 >file3 &&
        cat file3 >file4 &&
        git add file2 &&
-       "$PERL_PATH" -pe 'y/\000/v/' <file3 >file1 &&
 -      perl -pe "y/\000/v/" <file3 >file1 &&
++      "$PERL_PATH" -pe "y/\000/v/" <file3 >file1 &&
        rm -f file2 &&
        git update-index --add --remove file1 file2 file3 file4 &&
-       git commit -m 'Second Version' &&
+       git commit -m "Second Version" &&
  
        git diff-tree -p master binary >B.diff &&
        git diff-tree -p -C master binary >C.diff &&