]>
git.ipfire.org Git - thirdparty/git.git/blob - t/t4054-diff-bogus-tree.sh
3 test_description
='test diff with a bogus tree containing the null sha1'
6 test_expect_success
'create bogus tree' '
7 name=$(echo $ZERO_OID | sed -e "s/00/Q/g") &&
9 printf "100644 fooQ$name" |
11 git hash-object -w --stdin -t tree
15 test_expect_success
'create tree with matching file' '
18 good_tree=$(git write-tree) &&
19 blob=$(git rev-parse :foo)
22 test_expect_success
'raw diff shows null sha1 (addition)' '
23 echo ":000000 100644 $ZERO_OID $ZERO_OID A foo" >expect &&
24 git diff-tree $EMPTY_TREE $bogus_tree >actual &&
25 test_cmp expect actual
28 test_expect_success
'raw diff shows null sha1 (removal)' '
29 echo ":100644 000000 $ZERO_OID $ZERO_OID D foo" >expect &&
30 git diff-tree $bogus_tree $EMPTY_TREE >actual &&
31 test_cmp expect actual
34 test_expect_success
'raw diff shows null sha1 (modification)' '
35 echo ":100644 100644 $blob $ZERO_OID M foo" >expect &&
36 git diff-tree $good_tree $bogus_tree >actual &&
37 test_cmp expect actual
40 test_expect_success
'raw diff shows null sha1 (other direction)' '
41 echo ":100644 100644 $ZERO_OID $blob M foo" >expect &&
42 git diff-tree $bogus_tree $good_tree >actual &&
43 test_cmp expect actual
46 test_expect_success
'raw diff shows null sha1 (reverse)' '
47 echo ":100644 100644 $ZERO_OID $blob M foo" >expect &&
48 git diff-tree -R $good_tree $bogus_tree >actual &&
49 test_cmp expect actual
52 test_expect_success
'raw diff shows null sha1 (index)' '
53 echo ":100644 100644 $ZERO_OID $blob M foo" >expect &&
54 git diff-index $bogus_tree >actual &&
55 test_cmp expect actual
58 test_expect_success
'patch fails due to bogus sha1 (addition)' '
59 test_must_fail git diff-tree -p $EMPTY_TREE $bogus_tree
62 test_expect_success
'patch fails due to bogus sha1 (removal)' '
63 test_must_fail git diff-tree -p $bogus_tree $EMPTY_TREE
66 test_expect_success
'patch fails due to bogus sha1 (modification)' '
67 test_must_fail git diff-tree -p $good_tree $bogus_tree
70 test_expect_success
'patch fails due to bogus sha1 (other direction)' '
71 test_must_fail git diff-tree -p $bogus_tree $good_tree
74 test_expect_success
'patch fails due to bogus sha1 (reverse)' '
75 test_must_fail git diff-tree -R -p $good_tree $bogus_tree
78 test_expect_success
'patch fails due to bogus sha1 (index)' '
79 test_must_fail git diff-index -p $bogus_tree