@@ -133,6 +133,34 @@ committer Bugs Bunny <bugs@bun.ni> 1234567890 +0000
133133This commit object intentionally broken
134134EOF
135135
136+ test_expect_success ' setup bogus commit' '
137+ commit="$(git hash-object -t commit -w --stdin <bogus-commit)"
138+ '
139+
140+ test_expect_success ' fsck with no skipList input' '
141+ test_must_fail git fsck 2>err &&
142+ test_i18ngrep "missingEmail" err
143+ '
144+
145+ test_expect_success ' setup sorted and unsorted skipLists' '
146+ cat >SKIP.unsorted <<-EOF &&
147+ 0000000000000000000000000000000000000004
148+ 0000000000000000000000000000000000000002
149+ $commit
150+ 0000000000000000000000000000000000000001
151+ 0000000000000000000000000000000000000003
152+ EOF
153+ sort SKIP.unsorted >SKIP.sorted
154+ '
155+
156+ test_expect_success ' fsck with sorted skipList' '
157+ git -c fsck.skipList=SKIP.sorted fsck
158+ '
159+
160+ test_expect_success ' fsck with unsorted skipList' '
161+ git -c fsck.skipList=SKIP.unsorted fsck
162+ '
163+
136164test_expect_success ' fsck with invalid or bogus skipList input' '
137165 git -c fsck.skipList=/dev/null -c fsck.missingEmail=ignore fsck &&
138166 test_must_fail git -c fsck.skipList=does-not-exist -c fsck.missingEmail=ignore fsck 2>err &&
@@ -141,8 +169,47 @@ test_expect_success 'fsck with invalid or bogus skipList input' '
141169 test_i18ngrep "Invalid SHA-1: \[core\]" err
142170'
143171
172+ test_expect_success ' fsck with other accepted skipList input (comments & empty lines)' '
173+ cat >SKIP.with-comment <<-EOF &&
174+ # Some bad commit
175+ 0000000000000000000000000000000000000001
176+ EOF
177+ test_must_fail git -c fsck.skipList=SKIP.with-comment fsck 2>err-with-comment &&
178+ test_i18ngrep "missingEmail" err-with-comment &&
179+ cat >SKIP.with-empty-line <<-EOF &&
180+ 0000000000000000000000000000000000000001
181+
182+ 0000000000000000000000000000000000000002
183+ EOF
184+ test_must_fail git -c fsck.skipList=SKIP.with-empty-line fsck 2>err-with-empty-line &&
185+ test_i18ngrep "missingEmail" err-with-empty-line
186+ '
187+
188+ test_expect_success ' fsck no garbage output from comments & empty lines errors' '
189+ test_line_count = 1 err-with-comment &&
190+ test_line_count = 1 err-with-empty-line
191+ '
192+
193+ test_expect_success ' fsck with invalid abbreviated skipList input' '
194+ echo $commit | test_copy_bytes 20 >SKIP.abbreviated &&
195+ test_must_fail git -c fsck.skipList=SKIP.abbreviated fsck 2>err-abbreviated &&
196+ test_i18ngrep "^fatal: Invalid SHA-1: " err-abbreviated
197+ '
198+
199+ test_expect_success ' fsck with exhaustive accepted skipList input (various types of comments etc.)' '
200+ >SKIP.exhaustive &&
201+ echo "# A commented line" >>SKIP.exhaustive &&
202+ echo "" >>SKIP.exhaustive &&
203+ echo " " >>SKIP.exhaustive &&
204+ echo " # Comment after whitespace" >>SKIP.exhaustive &&
205+ echo "$commit # Our bad commit (with leading whitespace and trailing comment)" >>SKIP.exhaustive &&
206+ echo "# Some bad commit (leading whitespace)" >>SKIP.exhaustive &&
207+ echo " 0000000000000000000000000000000000000001" >>SKIP.exhaustive &&
208+ git -c fsck.skipList=SKIP.exhaustive fsck 2>err &&
209+ test_must_be_empty err
210+ '
211+
144212test_expect_success ' push with receive.fsck.skipList' '
145- commit="$(git hash-object -t commit -w --stdin <bogus-commit)" &&
146213 git push . $commit:refs/heads/bogus &&
147214 rm -rf dst &&
148215 git init dst &&
@@ -169,7 +236,6 @@ test_expect_success 'push with receive.fsck.skipList' '
169236'
170237
171238test_expect_success ' fetch with fetch.fsck.skipList' '
172- commit="$(git hash-object -t commit -w --stdin <bogus-commit)" &&
173239 refspec=refs/heads/bogus:refs/heads/bogus &&
174240 git push . $commit:refs/heads/bogus &&
175241 rm -rf dst &&
@@ -204,7 +270,6 @@ test_expect_success 'fsck.<unknownmsg-id> dies' '
204270'
205271
206272test_expect_success ' push with receive.fsck.missingEmail=warn' '
207- commit="$(git hash-object -t commit -w --stdin <bogus-commit)" &&
208273 git push . $commit:refs/heads/bogus &&
209274 rm -rf dst &&
210275 git init dst &&
@@ -232,7 +297,6 @@ test_expect_success 'push with receive.fsck.missingEmail=warn' '
232297'
233298
234299test_expect_success ' fetch with fetch.fsck.missingEmail=warn' '
235- commit="$(git hash-object -t commit -w --stdin <bogus-commit)" &&
236300 refspec=refs/heads/bogus:refs/heads/bogus &&
237301 git push . $commit:refs/heads/bogus &&
238302 rm -rf dst &&
0 commit comments