config.txt: document include, includeIf
[git/debian.git] / t / t6102-rev-list-unexpected-objects.sh
blob6f0902b86383191511116ee4fc5406e9dac6fb2e
1 #!/bin/sh
3 test_description='git rev-list should handle unexpected object types'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'setup well-formed objects' '
9 blob="$(printf "foo" | git hash-object -w --stdin)" &&
10 tree="$(printf "100644 blob $blob\tfoo" | git mktree)" &&
11 commit="$(git commit-tree $tree -m "first commit")" &&
12 git cat-file commit $commit >good-commit
15 test_expect_success 'setup unexpected non-blob entry' '
16 printf "100644 foo\0$(echo $tree | hex2oct)" >broken-tree &&
17 broken_tree="$(git hash-object -w --literally -t tree broken-tree)"
20 test_expect_failure 'traverse unexpected non-blob entry (lone)' '
21 test_must_fail git rev-list --objects $broken_tree
24 test_expect_success 'traverse unexpected non-blob entry (seen)' '
25 test_must_fail git rev-list --objects $tree $broken_tree >output 2>&1 &&
26 test_i18ngrep "is not a blob" output
29 test_expect_success 'setup unexpected non-tree entry' '
30 printf "40000 foo\0$(echo $blob | hex2oct)" >broken-tree &&
31 broken_tree="$(git hash-object -w --literally -t tree broken-tree)"
34 test_expect_success 'traverse unexpected non-tree entry (lone)' '
35 test_must_fail git rev-list --objects $broken_tree
38 test_expect_success 'traverse unexpected non-tree entry (seen)' '
39 test_must_fail git rev-list --objects $blob $broken_tree >output 2>&1 &&
40 test_i18ngrep "is not a tree" output
43 test_expect_success 'setup unexpected non-commit parent' '
44 sed "/^author/ { h; s/.*/parent $blob/; G; }" <good-commit \
45 >broken-commit &&
46 broken_commit="$(git hash-object -w --literally -t commit \
47 broken-commit)"
50 test_expect_success 'traverse unexpected non-commit parent (lone)' '
51 test_must_fail git rev-list --objects $broken_commit >output 2>&1 &&
52 test_i18ngrep "not a commit" output
55 test_expect_success 'traverse unexpected non-commit parent (seen)' '
56 test_must_fail git rev-list --objects $blob $broken_commit \
57 >output 2>&1 &&
58 test_i18ngrep "not a commit" output
61 test_expect_success 'setup unexpected non-tree root' '
62 sed -e "s/$tree/$blob/" <good-commit >broken-commit &&
63 broken_commit="$(git hash-object -w --literally -t commit \
64 broken-commit)"
67 test_expect_success 'traverse unexpected non-tree root (lone)' '
68 test_must_fail git rev-list --objects $broken_commit
71 test_expect_success 'traverse unexpected non-tree root (seen)' '
72 test_must_fail git rev-list --objects $blob $broken_commit \
73 >output 2>&1 &&
74 test_i18ngrep "not a tree" output
77 test_expect_success 'setup unexpected non-commit tag' '
78 git tag -a -m "tagged commit" tag $commit &&
79 git cat-file tag tag >good-tag &&
80 test_when_finished "git tag -d tag" &&
81 sed -e "s/$commit/$blob/" <good-tag >broken-tag &&
82 tag=$(git hash-object -w --literally -t tag broken-tag)
85 test_expect_success 'traverse unexpected non-commit tag (lone)' '
86 test_must_fail git rev-list --objects $tag
89 test_expect_success 'traverse unexpected non-commit tag (seen)' '
90 test_must_fail git rev-list --objects $blob $tag >output 2>&1 &&
91 test_i18ngrep "not a commit" output
94 test_expect_success 'setup unexpected non-tree tag' '
95 git tag -a -m "tagged tree" tag $tree &&
96 git cat-file tag tag >good-tag &&
97 test_when_finished "git tag -d tag" &&
98 sed -e "s/$tree/$blob/" <good-tag >broken-tag &&
99 tag=$(git hash-object -w --literally -t tag broken-tag)
102 test_expect_success 'traverse unexpected non-tree tag (lone)' '
103 test_must_fail git rev-list --objects $tag
106 test_expect_success 'traverse unexpected non-tree tag (seen)' '
107 test_must_fail git rev-list --objects $blob $tag >output 2>&1 &&
108 test_i18ngrep "not a tree" output
111 test_expect_success 'setup unexpected non-blob tag' '
112 git tag -a -m "tagged blob" tag $blob &&
113 git cat-file tag tag >good-tag &&
114 test_when_finished "git tag -d tag" &&
115 sed -e "s/$blob/$commit/" <good-tag >broken-tag &&
116 tag=$(git hash-object -w --literally -t tag broken-tag)
119 test_expect_failure 'traverse unexpected non-blob tag (lone)' '
120 test_must_fail git rev-list --objects $tag
123 test_expect_success 'traverse unexpected non-blob tag (seen)' '
124 test_must_fail git rev-list --objects $commit $tag >output 2>&1 &&
125 test_i18ngrep "not a blob" output
128 test_done