]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4054-diff-bogus-tree.sh
Merge branch 'jk/escaped-wildcard-dwim'
[thirdparty/git.git] / t / t4054-diff-bogus-tree.sh
CommitLineData
e5450100
JK
1#!/bin/sh
2
3test_description='test diff with a bogus tree containing the null sha1'
4. ./test-lib.sh
5
e5450100 6test_expect_success 'create bogus tree' '
194264c1 7 name=$(echo $ZERO_OID | sed -e "s/00/Q/g") &&
e5450100 8 bogus_tree=$(
194264c1 9 printf "100644 fooQ$name" |
e5450100
JK
10 q_to_nul |
11 git hash-object -w --stdin -t tree
12 )
13'
14
15test_expect_success 'create tree with matching file' '
16 echo bar >foo &&
17 git add foo &&
99094a7a 18 good_tree=$(git write-tree) &&
e5450100
JK
19 blob=$(git rev-parse :foo)
20'
21
22test_expect_success 'raw diff shows null sha1 (addition)' '
8125a58b 23 echo ":000000 100644 $ZERO_OID $ZERO_OID A foo" >expect &&
f9e7d9f8 24 git diff-tree $EMPTY_TREE $bogus_tree >actual &&
e5450100
JK
25 test_cmp expect actual
26'
27
28test_expect_success 'raw diff shows null sha1 (removal)' '
8125a58b 29 echo ":100644 000000 $ZERO_OID $ZERO_OID D foo" >expect &&
f9e7d9f8 30 git diff-tree $bogus_tree $EMPTY_TREE >actual &&
e5450100
JK
31 test_cmp expect actual
32'
33
34test_expect_success 'raw diff shows null sha1 (modification)' '
8125a58b 35 echo ":100644 100644 $blob $ZERO_OID M foo" >expect &&
e5450100
JK
36 git diff-tree $good_tree $bogus_tree >actual &&
37 test_cmp expect actual
38'
39
40test_expect_success 'raw diff shows null sha1 (other direction)' '
8125a58b 41 echo ":100644 100644 $ZERO_OID $blob M foo" >expect &&
e5450100
JK
42 git diff-tree $bogus_tree $good_tree >actual &&
43 test_cmp expect actual
44'
45
46test_expect_success 'raw diff shows null sha1 (reverse)' '
8125a58b 47 echo ":100644 100644 $ZERO_OID $blob M foo" >expect &&
e5450100
JK
48 git diff-tree -R $good_tree $bogus_tree >actual &&
49 test_cmp expect actual
50'
51
52test_expect_success 'raw diff shows null sha1 (index)' '
8125a58b 53 echo ":100644 100644 $ZERO_OID $blob M foo" >expect &&
e5450100
JK
54 git diff-index $bogus_tree >actual &&
55 test_cmp expect actual
56'
57
58test_expect_success 'patch fails due to bogus sha1 (addition)' '
f9e7d9f8 59 test_must_fail git diff-tree -p $EMPTY_TREE $bogus_tree
e5450100
JK
60'
61
62test_expect_success 'patch fails due to bogus sha1 (removal)' '
f9e7d9f8 63 test_must_fail git diff-tree -p $bogus_tree $EMPTY_TREE
e5450100
JK
64'
65
66test_expect_success 'patch fails due to bogus sha1 (modification)' '
67 test_must_fail git diff-tree -p $good_tree $bogus_tree
68'
69
70test_expect_success 'patch fails due to bogus sha1 (other direction)' '
71 test_must_fail git diff-tree -p $bogus_tree $good_tree
72'
73
74test_expect_success 'patch fails due to bogus sha1 (reverse)' '
75 test_must_fail git diff-tree -R -p $good_tree $bogus_tree
76'
77
78test_expect_success 'patch fails due to bogus sha1 (index)' '
79 test_must_fail git diff-index -p $bogus_tree
80'
81
82test_done