Skip to content

Commit 6e328d6

Browse files
committed
unpack-objects: call fsck_finish() after fscking objects
As with the previous commit, we must call fsck's "finish" function in order to catch any queued objects for .gitmodules checks. This second pass will be able to access any incoming objects, because we will have exploded them to loose objects by now. This isn't quite ideal, because it means that bad objects may have been written to the object database (and a subsequent operation could then reference them, even if the other side doesn't send the objects again). However, this is sufficient when used with receive.fsckObjects, since those loose objects will all be placed in a temporary quarantine area that will get wiped if we find any problems. Signed-off-by: Jeff King <[email protected]>
1 parent 1995b5e commit 6e328d6

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

builtin/unpack-objects.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,11 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
572572
unpack_all();
573573
the_hash_algo->update_fn(&ctx, buffer, offset);
574574
the_hash_algo->final_fn(oid.hash, &ctx);
575-
if (strict)
575+
if (strict) {
576576
write_rest();
577+
if (fsck_finish(&fsck_options))
578+
die(_("fsck error in pack objects"));
579+
}
577580
if (hashcmp(fill(the_hash_algo->rawsz), oid.hash))
578581
die("final sha1 did not match");
579582
use(the_hash_algo->rawsz);

t/t7415-submodule-names.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,11 @@ test_expect_success 'fsck detects evil superproject' '
7777
test_must_fail git fsck
7878
'
7979

80+
test_expect_success 'transfer.fsckObjects detects evil superproject (unpack)' '
81+
rm -rf dst.git &&
82+
git init --bare dst.git &&
83+
git -C dst.git config transfer.fsckObjects true &&
84+
test_must_fail git push dst.git HEAD
85+
'
86+
8087
test_done

0 commit comments

Comments
 (0)