Merge branch 'ap/remote-hg-unquote-cquote' into maint
[alt-git.git] / t / t4054-diff-bogus-tree.sh
blob0843c8789005e21eff2f771c97671f02cbaee022
1 #!/bin/sh
3 test_description='test diff with a bogus tree containing the null sha1'
4 . ./test-lib.sh
6 empty_tree=4b825dc642cb6eb9a060e54bf8d69288fbee4904
8 test_expect_success 'create bogus tree' '
9 bogus_tree=$(
10 printf "100644 fooQQQQQQQQQQQQQQQQQQQQQ" |
11 q_to_nul |
12 git hash-object -w --stdin -t tree
16 test_expect_success 'create tree with matching file' '
17 echo bar >foo &&
18 git add foo &&
19 good_tree=$(git write-tree)
20 blob=$(git rev-parse :foo)
23 test_expect_success 'raw diff shows null sha1 (addition)' '
24 echo ":000000 100644 $_z40 $_z40 A foo" >expect &&
25 git diff-tree $empty_tree $bogus_tree >actual &&
26 test_cmp expect actual
29 test_expect_success 'raw diff shows null sha1 (removal)' '
30 echo ":100644 000000 $_z40 $_z40 D foo" >expect &&
31 git diff-tree $bogus_tree $empty_tree >actual &&
32 test_cmp expect actual
35 test_expect_success 'raw diff shows null sha1 (modification)' '
36 echo ":100644 100644 $blob $_z40 M foo" >expect &&
37 git diff-tree $good_tree $bogus_tree >actual &&
38 test_cmp expect actual
41 test_expect_success 'raw diff shows null sha1 (other direction)' '
42 echo ":100644 100644 $_z40 $blob M foo" >expect &&
43 git diff-tree $bogus_tree $good_tree >actual &&
44 test_cmp expect actual
47 test_expect_success 'raw diff shows null sha1 (reverse)' '
48 echo ":100644 100644 $_z40 $blob M foo" >expect &&
49 git diff-tree -R $good_tree $bogus_tree >actual &&
50 test_cmp expect actual
53 test_expect_success 'raw diff shows null sha1 (index)' '
54 echo ":100644 100644 $_z40 $blob M foo" >expect &&
55 git diff-index $bogus_tree >actual &&
56 test_cmp expect actual
59 test_expect_success 'patch fails due to bogus sha1 (addition)' '
60 test_must_fail git diff-tree -p $empty_tree $bogus_tree
63 test_expect_success 'patch fails due to bogus sha1 (removal)' '
64 test_must_fail git diff-tree -p $bogus_tree $empty_tree
67 test_expect_success 'patch fails due to bogus sha1 (modification)' '
68 test_must_fail git diff-tree -p $good_tree $bogus_tree
71 test_expect_success 'patch fails due to bogus sha1 (other direction)' '
72 test_must_fail git diff-tree -p $bogus_tree $good_tree
75 test_expect_success 'patch fails due to bogus sha1 (reverse)' '
76 test_must_fail git diff-tree -R -p $good_tree $bogus_tree
79 test_expect_success 'patch fails due to bogus sha1 (index)' '
80 test_must_fail git diff-index -p $bogus_tree
83 test_done