3 # Copyright (c) 2006 Junio C Hamano
6 test_description='Binary diff and apply
11 test_expect_success 'prepare repository' \
12 'echo AIT >a && echo BIT >b && echo CIT >c && echo DIT >d &&
13 git-update-index --add a b c d &&
15 cat ../test4012.png >b &&
19 test_expect_success 'diff without --binary' \
20 'git-diff | git-apply --stat --summary >current &&
26 4 files changed, 2 insertions(+), 2 deletions(-)
29 test_expect_success 'diff with --binary' \
30 'git-diff --binary | git-apply --stat --summary >current &&
36 4 files changed, 2 insertions(+), 2 deletions(-)
39 # apply needs to be able to skip the binary material correctly
40 # in order to report the line number of a corrupt patch.
41 test_expect_success 'apply detecting corrupt patch correctly' \
42 'git-diff | sed -e 's/-CIT/xCIT/' >broken &&
43 if git-apply --stat --summary broken 2>detected
45 echo unhappy - should have detected an error
50 detected=`cat detected` &&
51 detected=`expr "$detected" : "fatal.*at line \\([0-9]*\\)\$"` &&
52 detected=`sed -ne "${detected}p" broken` &&
53 test "$detected" = xCIT'
55 test_expect_success 'apply detecting corrupt patch correctly' \
56 'git-diff --binary | sed -e 's/-CIT/xCIT/' >broken &&
57 if git-apply --stat --summary broken 2>detected
59 echo unhappy - should have detected an error
64 detected=`cat detected` &&
65 detected=`expr "$detected" : "fatal.*at line \\([0-9]*\\)\$"` &&
66 detected=`sed -ne "${detected}p" broken` &&
67 test "$detected" = xCIT'
69 test_expect_success 'initial commit' 'git-commit -a -m initial'
71 # Try removal (b), modification (d), and creation (e).
72 test_expect_success 'diff-index with --binary' \
73 'echo AIT >a && mv b e && echo CIT >c && cat e >d &&
74 git-update-index --add --remove a b c d e &&
75 tree0=`git-write-tree` &&
76 git-diff --cached --binary >current &&
77 git-apply --stat --summary current'
79 test_expect_success 'apply binary patch' \
81 git-apply --binary --index <current &&
82 tree1=`git-write-tree` &&
83 test "$tree1" = "$tree0"'