Skip to content

Commit 2738744

Browse files
committed
fsck: handle promisor objects in .gitmodules check
If we have a tree that points to a .gitmodules blob but don't have that blob, we can't check its contents. This produces an fsck error when we encounter it. But in the case of a promisor object, this absence is expected, and we must not complain. Note that this can technically circumvent our transfer.fsckObjects check. Imagine a client fetches a tree, but not the matching .gitmodules blob. An fsck of the incoming objects will show that we don't have enough information. Later, we do fetch the actual blob. But we have no idea that it's a .gitmodules file. The only ways to get around this would be to re-scan all of the existing trees whenever new ones enter (which is expensive), or to somehow persist the gitmodules_found set between fsck runs (which is complicated). In practice, it's probably OK to ignore the problem. Any repository which has all of the objects (including the one serving the promisor packs) can perform the checks. Since promisor packs are inherently about a hierarchical topology in which clients rely on upstream repositories, those upstream repositories can protect all of their downstream clients from broken objects. Signed-off-by: Jeff King <[email protected]>
1 parent 159e7b0 commit 2738744

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fsck.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "sha1-array.h"
1212
#include "decorate.h"
1313
#include "oidset.h"
14+
#include "packfile.h"
1415

1516
static struct oidset gitmodules_found = OIDSET_INIT;
1617
static struct oidset gitmodules_done = OIDSET_INIT;
@@ -974,6 +975,8 @@ int fsck_finish(struct fsck_options *options)
974975

975976
buf = read_sha1_file(oid->hash, &type, &size);
976977
if (!buf) {
978+
if (is_promisor_object(&blob->object.oid))
979+
continue;
977980
ret |= report(options, &blob->object,
978981
FSCK_MSG_GITMODULES_MISSING,
979982
"unable to read .gitmodules blob");

0 commit comments

Comments
 (0)