]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6102-rev-list-unexpected-objects.sh
Merge branch 'wb/fsmonitor-bitmap-fix'
[thirdparty/git.git] / t / t6102-rev-list-unexpected-objects.sh
CommitLineData
0616617c
TB
1#!/bin/sh
2
3test_description='git rev-list should handle unexpected object types'
4
5. ./test-lib.sh
6
7test_expect_success 'setup well-formed objects' '
8 blob="$(printf "foo" | git hash-object -w --stdin)" &&
9 tree="$(printf "100644 blob $blob\tfoo" | git mktree)" &&
10 commit="$(git commit-tree $tree -m "first commit")" &&
11 git cat-file commit $commit >good-commit
12'
13
14test_expect_success 'setup unexpected non-blob entry' '
15 printf "100644 foo\0$(echo $tree | hex2oct)" >broken-tree &&
16 broken_tree="$(git hash-object -w --literally -t tree broken-tree)"
17'
18
19test_expect_failure 'traverse unexpected non-blob entry (lone)' '
20 test_must_fail git rev-list --objects $broken_tree
21'
22
23c20445
TB
23test_expect_success 'traverse unexpected non-blob entry (seen)' '
24 test_must_fail git rev-list --objects $tree $broken_tree >output 2>&1 &&
25 test_i18ngrep "is not a blob" output
0616617c
TB
26'
27
28test_expect_success 'setup unexpected non-tree entry' '
29 printf "40000 foo\0$(echo $blob | hex2oct)" >broken-tree &&
30 broken_tree="$(git hash-object -w --literally -t tree broken-tree)"
31'
32
ee4dfee2 33test_expect_success 'traverse unexpected non-tree entry (lone)' '
0616617c
TB
34 test_must_fail git rev-list --objects $broken_tree
35'
36
b49e74ea
TB
37test_expect_success 'traverse unexpected non-tree entry (seen)' '
38 test_must_fail git rev-list --objects $blob $broken_tree >output 2>&1 &&
39 test_i18ngrep "is not a tree" output
0616617c
TB
40'
41
42test_expect_success 'setup unexpected non-commit parent' '
43 sed "/^author/ { h; s/.*/parent $blob/; G; }" <good-commit \
44 >broken-commit &&
45 broken_commit="$(git hash-object -w --literally -t commit \
46 broken-commit)"
47'
48
49test_expect_success 'traverse unexpected non-commit parent (lone)' '
50 test_must_fail git rev-list --objects $broken_commit >output 2>&1 &&
51 test_i18ngrep "not a commit" output
52'
53
54test_expect_success 'traverse unexpected non-commit parent (seen)' '
55 test_must_fail git rev-list --objects $commit $broken_commit \
56 >output 2>&1 &&
57 test_i18ngrep "not a commit" output
58'
59
60test_expect_success 'setup unexpected non-tree root' '
61 sed -e "s/$tree/$blob/" <good-commit >broken-commit &&
62 broken_commit="$(git hash-object -w --literally -t commit \
63 broken-commit)"
64'
65
ee4dfee2 66test_expect_success 'traverse unexpected non-tree root (lone)' '
0616617c
TB
67 test_must_fail git rev-list --objects $broken_commit
68'
69
97dd512a
JK
70test_expect_success 'traverse unexpected non-tree root (seen)' '
71 test_must_fail git rev-list --objects $blob $broken_commit \
72 >output 2>&1 &&
73 test_i18ngrep "not a tree" output
0616617c
TB
74'
75
76test_expect_success 'setup unexpected non-commit tag' '
77 git tag -a -m "tagged commit" tag $commit &&
78 git cat-file tag tag >good-tag &&
79 test_when_finished "git tag -d tag" &&
80 sed -e "s/$commit/$blob/" <good-tag >broken-tag &&
81 tag=$(git hash-object -w --literally -t tag broken-tag)
82'
83
84test_expect_success 'traverse unexpected non-commit tag (lone)' '
85 test_must_fail git rev-list --objects $tag
86'
87
88test_expect_success 'traverse unexpected non-commit tag (seen)' '
89 test_must_fail git rev-list --objects $blob $tag >output 2>&1 &&
90 test_i18ngrep "not a commit" output
91'
92
93test_expect_success 'setup unexpected non-tree tag' '
94 git tag -a -m "tagged tree" tag $tree &&
95 git cat-file tag tag >good-tag &&
96 test_when_finished "git tag -d tag" &&
97 sed -e "s/$tree/$blob/" <good-tag >broken-tag &&
98 tag=$(git hash-object -w --literally -t tag broken-tag)
99'
100
101test_expect_success 'traverse unexpected non-tree tag (lone)' '
102 test_must_fail git rev-list --objects $tag
103'
104
105test_expect_success 'traverse unexpected non-tree tag (seen)' '
106 test_must_fail git rev-list --objects $blob $tag >output 2>&1 &&
107 test_i18ngrep "not a tree" output
108'
109
110test_expect_success 'setup unexpected non-blob tag' '
111 git tag -a -m "tagged blob" tag $blob &&
112 git cat-file tag tag >good-tag &&
113 test_when_finished "git tag -d tag" &&
114 sed -e "s/$blob/$commit/" <good-tag >broken-tag &&
115 tag=$(git hash-object -w --literally -t tag broken-tag)
116'
117
118test_expect_failure 'traverse unexpected non-blob tag (lone)' '
119 test_must_fail git rev-list --objects $tag
120'
121
122test_expect_success 'traverse unexpected non-blob tag (seen)' '
123 test_must_fail git rev-list --objects $commit $tag >output 2>&1 &&
124 test_i18ngrep "not a blob" output
125'
126
127test_done