]>
Commit | Line | Data |
---|---|---|
27dedf0c JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Junio C Hamano | |
4 | # | |
5 | ||
5be60078 | 6 | test_description='git apply handling binary patches |
27dedf0c JH |
7 | |
8 | ' | |
9 | . ./test-lib.sh | |
10 | ||
11 | # setup | |
12 | ||
13 | cat >file1 <<EOF | |
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. | |
19 | EOF | |
20 | cat file1 >file2 | |
21 | cat file1 >file4 | |
22 | ||
4a45f7dd BG |
23 | test_expect_success 'setup' " |
24 | git update-index --add --remove file1 file2 file4 && | |
25 | git commit -m 'Initial Version' 2>/dev/null && | |
26 | ||
27 | git checkout -b binary && | |
28 | perl -pe 'y/x/\000/' <file1 >file3 && | |
29 | cat file3 >file4 && | |
30 | git add file2 && | |
31 | perl -pe 'y/\000/v/' <file3 >file1 && | |
32 | rm -f file2 && | |
33 | git update-index --add --remove file1 file2 file3 file4 && | |
34 | git commit -m 'Second Version' && | |
35 | ||
36 | git diff-tree -p master binary >B.diff && | |
37 | git diff-tree -p -C master binary >C.diff && | |
38 | ||
39 | git diff-tree -p --binary master binary >BF.diff && | |
40 | git diff-tree -p --binary -C master binary >CF.diff | |
41 | " | |
27dedf0c JH |
42 | |
43 | test_expect_success 'stat binary diff -- should not fail.' \ | |
3604e7c5 | 44 | 'git checkout master |
5be60078 | 45 | git apply --stat --summary B.diff' |
27dedf0c JH |
46 | |
47 | test_expect_success 'stat binary diff (copy) -- should not fail.' \ | |
3604e7c5 | 48 | 'git checkout master |
5be60078 | 49 | git apply --stat --summary C.diff' |
27dedf0c | 50 | |
41ac414e | 51 | test_expect_success 'check binary diff -- should fail.' \ |
3604e7c5 | 52 | 'git checkout master && |
d492b31c | 53 | test_must_fail git apply --check B.diff' |
41ac414e JH |
54 | |
55 | test_expect_success 'check binary diff (copy) -- should fail.' \ | |
3604e7c5 | 56 | 'git checkout master && |
d492b31c | 57 | test_must_fail git apply --check C.diff' |
41ac414e JH |
58 | |
59 | test_expect_success \ | |
60 | 'check incomplete binary diff with replacement -- should fail.' ' | |
3604e7c5 | 61 | git checkout master && |
d492b31c | 62 | test_must_fail git apply --check --allow-binary-replacement B.diff |
41ac414e | 63 | ' |
27dedf0c | 64 | |
41ac414e JH |
65 | test_expect_success \ |
66 | 'check incomplete binary diff with replacement (copy) -- should fail.' ' | |
3604e7c5 | 67 | git checkout master && |
d492b31c | 68 | test_must_fail git apply --check --allow-binary-replacement C.diff |
41ac414e | 69 | ' |
27dedf0c JH |
70 | |
71 | test_expect_success 'check binary diff with replacement.' \ | |
3604e7c5 | 72 | 'git checkout master |
5be60078 | 73 | git apply --check --allow-binary-replacement BF.diff' |
27dedf0c JH |
74 | |
75 | test_expect_success 'check binary diff with replacement (copy).' \ | |
3604e7c5 | 76 | 'git checkout master |
5be60078 | 77 | git apply --check --allow-binary-replacement CF.diff' |
27dedf0c JH |
78 | |
79 | # Now we start applying them. | |
80 | ||
81 | do_reset () { | |
41ac414e | 82 | rm -f file? && |
3604e7c5 NS |
83 | git reset --hard && |
84 | git checkout -f master | |
27dedf0c JH |
85 | } |
86 | ||
41ac414e JH |
87 | test_expect_success 'apply binary diff -- should fail.' \ |
88 | 'do_reset && | |
d492b31c | 89 | test_must_fail git apply B.diff' |
27dedf0c | 90 | |
41ac414e JH |
91 | test_expect_success 'apply binary diff -- should fail.' \ |
92 | 'do_reset && | |
d492b31c | 93 | test_must_fail git apply --index B.diff' |
27dedf0c | 94 | |
41ac414e JH |
95 | test_expect_success 'apply binary diff (copy) -- should fail.' \ |
96 | 'do_reset && | |
d492b31c | 97 | test_must_fail git apply C.diff' |
27dedf0c | 98 | |
41ac414e JH |
99 | test_expect_success 'apply binary diff (copy) -- should fail.' \ |
100 | 'do_reset && | |
d492b31c | 101 | test_must_fail git apply --index C.diff' |
27dedf0c | 102 | |
2b6eef94 | 103 | test_expect_success 'apply binary diff without replacement.' \ |
41ac414e | 104 | 'do_reset && |
5be60078 | 105 | git apply BF.diff' |
27dedf0c | 106 | |
2b6eef94 | 107 | test_expect_success 'apply binary diff without replacement (copy).' \ |
41ac414e | 108 | 'do_reset && |
5be60078 | 109 | git apply CF.diff' |
27dedf0c JH |
110 | |
111 | test_expect_success 'apply binary diff.' \ | |
41ac414e | 112 | 'do_reset && |
5be60078 JH |
113 | git apply --allow-binary-replacement --index BF.diff && |
114 | test -z "$(git diff --name-status binary)"' | |
27dedf0c JH |
115 | |
116 | test_expect_success 'apply binary diff (copy).' \ | |
41ac414e | 117 | 'do_reset && |
5be60078 JH |
118 | git apply --allow-binary-replacement --index CF.diff && |
119 | test -z "$(git diff --name-status binary)"' | |
27dedf0c JH |
120 | |
121 | test_done |