9057f6d04fa7f23fda93c110f4ce4575d3977867
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6test_description='git-apply handling binary patches
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
23git-update-index --add --remove file1 file2 file4
24git-commit -m 'Initial Version' 2>/dev/null
25
26git-checkout -b binary
27tr 'x' '\0' <file1 >file3
28cat file3 >file4
29git-add file2
30tr '\0' 'v' <file3 >file1
31rm -f file2
32git-update-index --add --remove file1 file2 file3 file4
33git-commit -m 'Second Version'
34
35git-diff-tree -p master binary >B.diff
36git-diff-tree -p -C master binary >C.diff
37
38test_expect_success 'stat binary diff -- should not fail.' \
39 'git-checkout master
40 git-apply --stat --summary B.diff'
41
42test_expect_success 'stat binary diff (copy) -- should not fail.' \
43 'git-checkout master
44 git-apply --stat --summary C.diff'
45
46test_expect_failure 'check binary diff -- should fail.' \
47 'git-checkout master
48 git-apply --check B.diff'
49
50test_expect_failure 'check binary diff (copy) -- should fail.' \
51 'git-checkout master
52 git-apply --check C.diff'
53
54test_expect_failure 'check incomplete binary diff with replacement -- should fail.' \
55 'git-checkout master
56 git-apply --check --allow-binary-replacement B.diff'
57
58test_expect_failure 'check incomplete binary diff with replacement (copy) -- should fail.' \
59 'git-checkout master
60 git-apply --check --allow-binary-replacement C.diff'
61
62# Now we start applying them.
63
64test_expect_failure 'apply binary diff -- should fail.' \
65 'git-checkout master
66 git-apply B.diff'
67
68git-reset --hard
69
70test_expect_failure 'apply binary diff -- should fail.' \
71 'git-checkout master
72 git-apply --index B.diff'
73
74git-reset --hard
75
76test_expect_failure 'apply binary diff (copy) -- should fail.' \
77 'git-checkout master
78 git-apply C.diff'
79
80git-reset --hard
81
82test_expect_failure 'apply binary diff (copy) -- should fail.' \
83 'git-checkout master
84 git-apply --index C.diff'
85
86test_done