]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4054-diff-bogus-tree.sh
Merge tag 'l10n-2.24.0-rnd2' of https://github.com/git-l10n/git-po
[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
JK
6test_expect_success 'create bogus tree' '
7 bogus_tree=$(
8 printf "100644 fooQQQQQQQQQQQQQQQQQQQQQ" |
9 q_to_nul |
10 git hash-object -w --stdin -t tree
11 )
12'
13
14test_expect_success 'create tree with matching file' '
15 echo bar >foo &&
16 git add foo &&
99094a7a 17 good_tree=$(git write-tree) &&
e5450100
JK
18 blob=$(git rev-parse :foo)
19'
20
21test_expect_success 'raw diff shows null sha1 (addition)' '
8125a58b 22 echo ":000000 100644 $ZERO_OID $ZERO_OID A foo" >expect &&
f9e7d9f8 23 git diff-tree $EMPTY_TREE $bogus_tree >actual &&
e5450100
JK
24 test_cmp expect actual
25'
26
27test_expect_success 'raw diff shows null sha1 (removal)' '
8125a58b 28 echo ":100644 000000 $ZERO_OID $ZERO_OID D foo" >expect &&
f9e7d9f8 29 git diff-tree $bogus_tree $EMPTY_TREE >actual &&
e5450100
JK
30 test_cmp expect actual
31'
32
33test_expect_success 'raw diff shows null sha1 (modification)' '
8125a58b 34 echo ":100644 100644 $blob $ZERO_OID M foo" >expect &&
e5450100
JK
35 git diff-tree $good_tree $bogus_tree >actual &&
36 test_cmp expect actual
37'
38
39test_expect_success 'raw diff shows null sha1 (other direction)' '
8125a58b 40 echo ":100644 100644 $ZERO_OID $blob M foo" >expect &&
e5450100
JK
41 git diff-tree $bogus_tree $good_tree >actual &&
42 test_cmp expect actual
43'
44
45test_expect_success 'raw diff shows null sha1 (reverse)' '
8125a58b 46 echo ":100644 100644 $ZERO_OID $blob M foo" >expect &&
e5450100
JK
47 git diff-tree -R $good_tree $bogus_tree >actual &&
48 test_cmp expect actual
49'
50
51test_expect_success 'raw diff shows null sha1 (index)' '
8125a58b 52 echo ":100644 100644 $ZERO_OID $blob M foo" >expect &&
e5450100
JK
53 git diff-index $bogus_tree >actual &&
54 test_cmp expect actual
55'
56
57test_expect_success 'patch fails due to bogus sha1 (addition)' '
f9e7d9f8 58 test_must_fail git diff-tree -p $EMPTY_TREE $bogus_tree
e5450100
JK
59'
60
61test_expect_success 'patch fails due to bogus sha1 (removal)' '
f9e7d9f8 62 test_must_fail git diff-tree -p $bogus_tree $EMPTY_TREE
e5450100
JK
63'
64
65test_expect_success 'patch fails due to bogus sha1 (modification)' '
66 test_must_fail git diff-tree -p $good_tree $bogus_tree
67'
68
69test_expect_success 'patch fails due to bogus sha1 (other direction)' '
70 test_must_fail git diff-tree -p $bogus_tree $good_tree
71'
72
73test_expect_success 'patch fails due to bogus sha1 (reverse)' '
74 test_must_fail git diff-tree -R -p $good_tree $bogus_tree
75'
76
77test_expect_success 'patch fails due to bogus sha1 (index)' '
78 test_must_fail git diff-index -p $bogus_tree
79'
80
81test_done