3 # Copyright (c) 2005 Junio C Hamano
6 test_description='git apply handling binary patches
14 A quick brown fox jumps over the lazy dog.
15 A tiny little penguin runs around in circles.
16 There is a flag with Linux written on it.
17 A slow black-and-white panda just sits there,
18 munching on his bamboo.
23 test_expect_success 'setup' "
24 git update-index --add --remove file1 file2 file4 &&
25 git commit -m 'Initial Version' 2>/dev/null &&
27 git checkout -b binary &&
28 perl -pe 'y/x/\000/' <file1 >file3 &&
31 perl -pe 'y/\000/v/' <file3 >file1 &&
33 git update-index --add --remove file1 file2 file3 file4 &&
34 git commit -m 'Second Version' &&
36 git diff-tree -p master binary >B.diff &&
37 git diff-tree -p -C master binary >C.diff &&
39 git diff-tree -p --binary master binary >BF.diff &&
40 git diff-tree -p --binary -C master binary >CF.diff &&
42 git diff-tree -p --full-index master binary >B-index.diff &&
43 git diff-tree -p -C --full-index master binary >C-index.diff &&
45 git init other-repo &&
47 git fetch .. master &&
48 git reset --hard FETCH_HEAD
52 test_expect_success 'stat binary diff -- should not fail.' \
54 git apply --stat --summary B.diff'
56 test_expect_success 'stat binary diff (copy) -- should not fail.' \
58 git apply --stat --summary C.diff'
60 test_expect_success 'check binary diff -- should fail.' \
61 'git checkout master &&
62 test_must_fail git apply --check B.diff'
64 test_expect_success 'check binary diff (copy) -- should fail.' \
65 'git checkout master &&
66 test_must_fail git apply --check C.diff'
69 'check incomplete binary diff with replacement -- should fail.' '
70 git checkout master &&
71 test_must_fail git apply --check --allow-binary-replacement B.diff
75 'check incomplete binary diff with replacement (copy) -- should fail.' '
76 git checkout master &&
77 test_must_fail git apply --check --allow-binary-replacement C.diff
80 test_expect_success 'check binary diff with replacement.' \
82 git apply --check --allow-binary-replacement BF.diff'
84 test_expect_success 'check binary diff with replacement (copy).' \
86 git apply --check --allow-binary-replacement CF.diff'
88 # Now we start applying them.
93 git checkout -f master
96 test_expect_success 'apply binary diff -- should fail.' \
98 test_must_fail git apply B.diff'
100 test_expect_success 'apply binary diff -- should fail.' \
102 test_must_fail git apply --index B.diff'
104 test_expect_success 'apply binary diff (copy) -- should fail.' \
106 test_must_fail git apply C.diff'
108 test_expect_success 'apply binary diff (copy) -- should fail.' \
110 test_must_fail git apply --index C.diff'
112 test_expect_success 'apply binary diff with full-index' '
114 git apply B-index.diff
117 test_expect_success 'apply binary diff with full-index (copy)' '
119 git apply C-index.diff
122 test_expect_success 'apply full-index binary diff in new repo' '
125 test_must_fail git apply ../B-index.diff)
128 test_expect_success 'apply binary diff without replacement.' \
132 test_expect_success 'apply binary diff without replacement (copy).' \
136 test_expect_success 'apply binary diff.' \
138 git apply --allow-binary-replacement --index BF.diff &&
139 test -z "$(git diff --name-status binary)"'
141 test_expect_success 'apply binary diff (copy).' \
143 git apply --allow-binary-replacement --index CF.diff &&
144 test -z "$(git diff --name-status binary)"'