]>
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 | ||
5be60078 | 23 | git update-index --add --remove file1 file2 file4 |
27dedf0c JH |
24 | git-commit -m 'Initial Version' 2>/dev/null |
25 | ||
26 | git-checkout -b binary | |
27 | tr 'x' '\0' <file1 >file3 | |
28 | cat file3 >file4 | |
5be60078 | 29 | git add file2 |
27dedf0c JH |
30 | tr '\0' 'v' <file3 >file1 |
31 | rm -f file2 | |
5be60078 | 32 | git update-index --add --remove file1 file2 file3 file4 |
27dedf0c JH |
33 | git-commit -m 'Second Version' |
34 | ||
5be60078 JH |
35 | git diff-tree -p master binary >B.diff |
36 | git diff-tree -p -C master binary >C.diff | |
27dedf0c | 37 | |
5be60078 JH |
38 | git diff-tree -p --binary master binary >BF.diff |
39 | git diff-tree -p --binary -C master binary >CF.diff | |
27dedf0c JH |
40 | |
41 | test_expect_success 'stat binary diff -- should not fail.' \ | |
42 | 'git-checkout master | |
5be60078 | 43 | git apply --stat --summary B.diff' |
27dedf0c JH |
44 | |
45 | test_expect_success 'stat binary diff (copy) -- should not fail.' \ | |
46 | 'git-checkout master | |
5be60078 | 47 | git apply --stat --summary C.diff' |
27dedf0c JH |
48 | |
49 | test_expect_failure 'check binary diff -- should fail.' \ | |
50 | 'git-checkout master | |
5be60078 | 51 | git apply --check B.diff' |
27dedf0c JH |
52 | |
53 | test_expect_failure 'check binary diff (copy) -- should fail.' \ | |
54 | 'git-checkout master | |
5be60078 | 55 | git apply --check C.diff' |
27dedf0c JH |
56 | |
57 | test_expect_failure 'check incomplete binary diff with replacement -- should fail.' \ | |
58 | 'git-checkout master | |
5be60078 | 59 | git apply --check --allow-binary-replacement B.diff' |
27dedf0c JH |
60 | |
61 | test_expect_failure 'check incomplete binary diff with replacement (copy) -- should fail.' \ | |
62 | 'git-checkout master | |
5be60078 | 63 | git apply --check --allow-binary-replacement C.diff' |
27dedf0c JH |
64 | |
65 | test_expect_success 'check binary diff with replacement.' \ | |
66 | 'git-checkout master | |
5be60078 | 67 | git apply --check --allow-binary-replacement BF.diff' |
27dedf0c JH |
68 | |
69 | test_expect_success 'check binary diff with replacement (copy).' \ | |
70 | 'git-checkout master | |
5be60078 | 71 | git apply --check --allow-binary-replacement CF.diff' |
27dedf0c JH |
72 | |
73 | # Now we start applying them. | |
74 | ||
75 | do_reset () { | |
76 | rm -f file? | |
77 | git-reset --hard | |
78 | git-checkout -f master | |
79 | } | |
80 | ||
81 | test_expect_failure 'apply binary diff -- should fail.' \ | |
82 | 'do_reset | |
5be60078 | 83 | git apply B.diff' |
27dedf0c JH |
84 | |
85 | test_expect_failure 'apply binary diff -- should fail.' \ | |
86 | 'do_reset | |
5be60078 | 87 | git apply --index B.diff' |
27dedf0c JH |
88 | |
89 | test_expect_failure 'apply binary diff (copy) -- should fail.' \ | |
90 | 'do_reset | |
5be60078 | 91 | git apply C.diff' |
27dedf0c JH |
92 | |
93 | test_expect_failure 'apply binary diff (copy) -- should fail.' \ | |
94 | 'do_reset | |
5be60078 | 95 | git apply --index C.diff' |
27dedf0c | 96 | |
2b6eef94 | 97 | test_expect_success 'apply binary diff without replacement.' \ |
27dedf0c | 98 | 'do_reset |
5be60078 | 99 | git apply BF.diff' |
27dedf0c | 100 | |
2b6eef94 | 101 | test_expect_success 'apply binary diff without replacement (copy).' \ |
27dedf0c | 102 | 'do_reset |
5be60078 | 103 | git apply CF.diff' |
27dedf0c JH |
104 | |
105 | test_expect_success 'apply binary diff.' \ | |
106 | 'do_reset | |
5be60078 JH |
107 | git apply --allow-binary-replacement --index BF.diff && |
108 | test -z "$(git diff --name-status binary)"' | |
27dedf0c JH |
109 | |
110 | test_expect_success 'apply binary diff (copy).' \ | |
111 | 'do_reset | |
5be60078 JH |
112 | git apply --allow-binary-replacement --index CF.diff && |
113 | test -z "$(git diff --name-status binary)"' | |
27dedf0c JH |
114 | |
115 | test_done |