]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4103-apply-binary.sh
svn: properly escape arguments for authors-prog
[thirdparty/git.git] / t / t4103-apply-binary.sh
CommitLineData
27dedf0c
JH
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
5be60078 6test_description='git apply handling binary patches
27dedf0c
JH
7
8'
9. ./test-lib.sh
10
11# setup
12
13cat >file1 <<EOF
14A quick brown fox jumps over the lazy dog.
15A tiny little penguin runs around in circles.
16There is a flag with Linux written on it.
17A slow black-and-white panda just sits there,
18munching on his bamboo.
19EOF
20cat file1 >file2
21cat file1 >file4
22
5be60078 23git update-index --add --remove file1 file2 file4
3604e7c5 24git commit -m 'Initial Version' 2>/dev/null
27dedf0c 25
3604e7c5 26git checkout -b binary
e85fe4d8 27perl -pe 'y/x/\000/' <file1 >file3
27dedf0c 28cat file3 >file4
5be60078 29git add file2
e85fe4d8 30perl -pe 'y/\000/v/' <file3 >file1
27dedf0c 31rm -f file2
5be60078 32git update-index --add --remove file1 file2 file3 file4
3604e7c5 33git commit -m 'Second Version'
27dedf0c 34
5be60078
JH
35git diff-tree -p master binary >B.diff
36git diff-tree -p -C master binary >C.diff
27dedf0c 37
5be60078
JH
38git diff-tree -p --binary master binary >BF.diff
39git diff-tree -p --binary -C master binary >CF.diff
27dedf0c
JH
40
41test_expect_success 'stat binary diff -- should not fail.' \
3604e7c5 42 'git checkout master
5be60078 43 git apply --stat --summary B.diff'
27dedf0c
JH
44
45test_expect_success 'stat binary diff (copy) -- should not fail.' \
3604e7c5 46 'git checkout master
5be60078 47 git apply --stat --summary C.diff'
27dedf0c 48
41ac414e 49test_expect_success 'check binary diff -- should fail.' \
3604e7c5 50 'git checkout master &&
d492b31c 51 test_must_fail git apply --check B.diff'
41ac414e
JH
52
53test_expect_success 'check binary diff (copy) -- should fail.' \
3604e7c5 54 'git checkout master &&
d492b31c 55 test_must_fail git apply --check C.diff'
41ac414e
JH
56
57test_expect_success \
58 'check incomplete binary diff with replacement -- should fail.' '
3604e7c5 59 git checkout master &&
d492b31c 60 test_must_fail git apply --check --allow-binary-replacement B.diff
41ac414e 61'
27dedf0c 62
41ac414e
JH
63test_expect_success \
64 'check incomplete binary diff with replacement (copy) -- should fail.' '
3604e7c5 65 git checkout master &&
d492b31c 66 test_must_fail git apply --check --allow-binary-replacement C.diff
41ac414e 67'
27dedf0c
JH
68
69test_expect_success 'check binary diff with replacement.' \
3604e7c5 70 'git checkout master
5be60078 71 git apply --check --allow-binary-replacement BF.diff'
27dedf0c
JH
72
73test_expect_success 'check binary diff with replacement (copy).' \
3604e7c5 74 'git checkout master
5be60078 75 git apply --check --allow-binary-replacement CF.diff'
27dedf0c
JH
76
77# Now we start applying them.
78
79do_reset () {
41ac414e 80 rm -f file? &&
3604e7c5
NS
81 git reset --hard &&
82 git checkout -f master
27dedf0c
JH
83}
84
41ac414e
JH
85test_expect_success 'apply binary diff -- should fail.' \
86 'do_reset &&
d492b31c 87 test_must_fail git apply B.diff'
27dedf0c 88
41ac414e
JH
89test_expect_success 'apply binary diff -- should fail.' \
90 'do_reset &&
d492b31c 91 test_must_fail git apply --index B.diff'
27dedf0c 92
41ac414e
JH
93test_expect_success 'apply binary diff (copy) -- should fail.' \
94 'do_reset &&
d492b31c 95 test_must_fail git apply C.diff'
27dedf0c 96
41ac414e
JH
97test_expect_success 'apply binary diff (copy) -- should fail.' \
98 'do_reset &&
d492b31c 99 test_must_fail git apply --index C.diff'
27dedf0c 100
2b6eef94 101test_expect_success 'apply binary diff without replacement.' \
41ac414e 102 'do_reset &&
5be60078 103 git apply BF.diff'
27dedf0c 104
2b6eef94 105test_expect_success 'apply binary diff without replacement (copy).' \
41ac414e 106 'do_reset &&
5be60078 107 git apply CF.diff'
27dedf0c
JH
108
109test_expect_success 'apply binary diff.' \
41ac414e 110 'do_reset &&
5be60078
JH
111 git apply --allow-binary-replacement --index BF.diff &&
112 test -z "$(git diff --name-status binary)"'
27dedf0c
JH
113
114test_expect_success 'apply binary diff (copy).' \
41ac414e 115 'do_reset &&
5be60078
JH
116 git apply --allow-binary-replacement --index CF.diff &&
117 test -z "$(git diff --name-status binary)"'
27dedf0c
JH
118
119test_done