string-list.[ch]: add a string_list_init_{nodup,dup}()
[git.git] / t / t6102-rev-list-unexpected-objects.sh
blob52cde097dd5c1c473df987cf74f51da714bd17b4
1 #!/bin/sh
3 test_description='git rev-list should handle unexpected object types'
5 . ./test-lib.sh
7 test_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
14 test_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)"
19 test_expect_failure 'traverse unexpected non-blob entry (lone)' '
20 test_must_fail git rev-list --objects $broken_tree
23 test_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
28 test_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)"
33 test_expect_success 'traverse unexpected non-tree entry (lone)' '
34 test_must_fail git rev-list --objects $broken_tree
37 test_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
42 test_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)"
49 test_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
54 test_expect_success 'traverse unexpected non-commit parent (seen)' '
55 test_must_fail git rev-list --objects $blob $broken_commit \
56 >output 2>&1 &&
57 test_i18ngrep "not a commit" output
60 test_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)"
66 test_expect_success 'traverse unexpected non-tree root (lone)' '
67 test_must_fail git rev-list --objects $broken_commit
70 test_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
76 test_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)
84 test_expect_success 'traverse unexpected non-commit tag (lone)' '
85 test_must_fail git rev-list --objects $tag
88 test_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
93 test_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)
101 test_expect_success 'traverse unexpected non-tree tag (lone)' '
102 test_must_fail git rev-list --objects $tag
105 test_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
110 test_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)
118 test_expect_failure 'traverse unexpected non-blob tag (lone)' '
119 test_must_fail git rev-list --objects $tag
122 test_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
127 test_done