@@ -69,7 +69,7 @@ test_expect_success 'object with bad sha1' '
6969 git update-ref refs/heads/bogus $cmt &&
7070 test_when_finished "git update-ref -d refs/heads/bogus" &&
7171
72- test_might_fail git fsck 2>out &&
72+ test_must_fail git fsck 2>out &&
7373 cat out &&
7474 grep "$sha.*corrupt" out
7575'
@@ -101,7 +101,7 @@ test_expect_success 'email with embedded > is not okay' '
101101 test_when_finished "remove_object $new" &&
102102 git update-ref refs/heads/bogus "$new" &&
103103 test_when_finished "git update-ref -d refs/heads/bogus" &&
104- git fsck 2>out &&
104+ test_must_fail git fsck 2>out &&
105105 cat out &&
106106 grep "error in commit $new" out
107107'
@@ -113,7 +113,7 @@ test_expect_success 'missing < email delimiter is reported nicely' '
113113 test_when_finished "remove_object $new" &&
114114 git update-ref refs/heads/bogus "$new" &&
115115 test_when_finished "git update-ref -d refs/heads/bogus" &&
116- git fsck 2>out &&
116+ test_must_fail git fsck 2>out &&
117117 cat out &&
118118 grep "error in commit $new.* - bad name" out
119119'
@@ -125,7 +125,7 @@ test_expect_success 'missing email is reported nicely' '
125125 test_when_finished "remove_object $new" &&
126126 git update-ref refs/heads/bogus "$new" &&
127127 test_when_finished "git update-ref -d refs/heads/bogus" &&
128- git fsck 2>out &&
128+ test_must_fail git fsck 2>out &&
129129 cat out &&
130130 grep "error in commit $new.* - missing email" out
131131'
@@ -137,7 +137,7 @@ test_expect_success '> in name is reported' '
137137 test_when_finished "remove_object $new" &&
138138 git update-ref refs/heads/bogus "$new" &&
139139 test_when_finished "git update-ref -d refs/heads/bogus" &&
140- git fsck 2>out &&
140+ test_must_fail git fsck 2>out &&
141141 cat out &&
142142 grep "error in commit $new" out
143143'
@@ -151,11 +151,31 @@ test_expect_success 'integer overflow in timestamps is reported' '
151151 test_when_finished "remove_object $new" &&
152152 git update-ref refs/heads/bogus "$new" &&
153153 test_when_finished "git update-ref -d refs/heads/bogus" &&
154- git fsck 2>out &&
154+ test_must_fail git fsck 2>out &&
155155 cat out &&
156156 grep "error in commit $new.*integer overflow" out
157157'
158158
159+ test_expect_success ' malformatted tree object' '
160+ test_when_finished "git update-ref -d refs/tags/wrong" &&
161+ test_when_finished "remove_object \$T" &&
162+ T=$(
163+ GIT_INDEX_FILE=test-index &&
164+ export GIT_INDEX_FILE &&
165+ rm -f test-index &&
166+ >x &&
167+ git add x &&
168+ T=$(git write-tree) &&
169+ (
170+ git cat-file tree $T &&
171+ git cat-file tree $T
172+ ) |
173+ git hash-object -w -t tree --stdin
174+ ) &&
175+ test_must_fail git fsck 2>out &&
176+ grep "error in tree .*contains duplicate file entries" out
177+ '
178+
159179test_expect_success ' tag pointing to nonexistent' '
160180 cat >invalid-tag <<-\EOF &&
161181 object ffffffffffffffffffffffffffffffffffffffff
0 commit comments