use strpbrk(3) to search for characters from a given set
[git/debian.git] / t / t4054-diff-bogus-tree.sh
blobfcae82fffa7f74a65fc6b475cc5c3eeefda3029a
1 #!/bin/sh
3 test_description='test diff with a bogus tree containing the null sha1'
4 . ./test-lib.sh
6 test_expect_success 'create bogus tree' '
7 bogus_tree=$(
8 printf "100644 fooQQQQQQQQQQQQQQQQQQQQQ" |
9 q_to_nul |
10 git hash-object -w --stdin -t tree
14 test_expect_success 'create tree with matching file' '
15 echo bar >foo &&
16 git add foo &&
17 good_tree=$(git write-tree) &&
18 blob=$(git rev-parse :foo)
21 test_expect_success 'raw diff shows null sha1 (addition)' '
22 echo ":000000 100644 $ZERO_OID $ZERO_OID A foo" >expect &&
23 git diff-tree $EMPTY_TREE $bogus_tree >actual &&
24 test_cmp expect actual
27 test_expect_success 'raw diff shows null sha1 (removal)' '
28 echo ":100644 000000 $ZERO_OID $ZERO_OID D foo" >expect &&
29 git diff-tree $bogus_tree $EMPTY_TREE >actual &&
30 test_cmp expect actual
33 test_expect_success 'raw diff shows null sha1 (modification)' '
34 echo ":100644 100644 $blob $ZERO_OID M foo" >expect &&
35 git diff-tree $good_tree $bogus_tree >actual &&
36 test_cmp expect actual
39 test_expect_success 'raw diff shows null sha1 (other direction)' '
40 echo ":100644 100644 $ZERO_OID $blob M foo" >expect &&
41 git diff-tree $bogus_tree $good_tree >actual &&
42 test_cmp expect actual
45 test_expect_success 'raw diff shows null sha1 (reverse)' '
46 echo ":100644 100644 $ZERO_OID $blob M foo" >expect &&
47 git diff-tree -R $good_tree $bogus_tree >actual &&
48 test_cmp expect actual
51 test_expect_success 'raw diff shows null sha1 (index)' '
52 echo ":100644 100644 $ZERO_OID $blob M foo" >expect &&
53 git diff-index $bogus_tree >actual &&
54 test_cmp expect actual
57 test_expect_success 'patch fails due to bogus sha1 (addition)' '
58 test_must_fail git diff-tree -p $EMPTY_TREE $bogus_tree
61 test_expect_success 'patch fails due to bogus sha1 (removal)' '
62 test_must_fail git diff-tree -p $bogus_tree $EMPTY_TREE
65 test_expect_success 'patch fails due to bogus sha1 (modification)' '
66 test_must_fail git diff-tree -p $good_tree $bogus_tree
69 test_expect_success 'patch fails due to bogus sha1 (other direction)' '
70 test_must_fail git diff-tree -p $bogus_tree $good_tree
73 test_expect_success 'patch fails due to bogus sha1 (reverse)' '
74 test_must_fail git diff-tree -R -p $good_tree $bogus_tree
77 test_expect_success 'patch fails due to bogus sha1 (index)' '
78 test_must_fail git diff-index -p $bogus_tree
81 test_done