302
)
303
'
304
305
+# create a static test repo which is broken by omitting
306
+# one particular object ($1, which is looked up via rev-parse
307
+# in the new repository).
308
+create_repo_missing () {
309
+ rm -rf missing &&
310
+ git init missing &&
311
+ (
312
+ cd missing &&
313
+ git commit -m one --allow-empty &&
314
+ mkdir subdir &&
315
+ echo content >subdir/file &&
316
+ git add subdir/file &&
317
+ git commit -m two &&
318
+ unrelated=$(echo unrelated | git hash-object --stdin -w) &&
319
+ git tag -m foo tag $unrelated &&
320
+ sha1=$(git rev-parse --verify "$1") &&
321
+ path=$(echo $sha1 | sed 's|..|&/|') &&
322
+ rm .git/objects/$path
323
+ )
324
+}
325
+
326
+test_expect_success 'fsck notices missing blob' '
327
+ create_repo_missing HEAD:subdir/file &&
328
+ test_must_fail git -C missing fsck
329
+'
330
+
331
+test_expect_success 'fsck notices missing subtree' '
332
+ create_repo_missing HEAD:subdir &&
333
+ test_must_fail git -C missing fsck
334
+'
335
+
336
+test_expect_success 'fsck notices missing root tree' '
337
+ create_repo_missing HEAD^{tree} &&
338
+ test_must_fail git -C missing fsck
339
+'
340
+
341
+test_expect_success 'fsck notices missing parent' '
342
+ create_repo_missing HEAD^ &&
343
+ test_must_fail git -C missing fsck
344
+'
345
+
346
+test_expect_success 'fsck notices missing tagged object' '
347
+ create_repo_missing tag^{blob} &&
348
+ test_must_fail git -C missing fsck
349
+'
350
+
351
+test_expect_success 'fsck notices ref pointing to missing commit' '
352
+ create_repo_missing HEAD &&
353
+ test_must_fail git -C missing fsck
354
+'
355
+
356
+test_expect_success 'fsck notices ref pointing to missing tag' '
357
+ create_repo_missing tag &&
358
+ test_must_fail git -C missing fsck
359
+'
360
+
361
test_done