Skip to content

Commit 6cf965c

Browse files
pks-tgitster
authored andcommitted
builtin/fsck: fix flags passed to odb_has_object()
In `mark_object()` we invoke `has_object()` with a value of 1. This is somewhat fishy given that the function expects a bitset of flags, so any behaviour that this results in is purely coincidental and may break at any point in time. The call to `has_object()` was originally introduced in 9eb86f4 (fsck: do not lazy fetch known non-promisor object, 2020-08-05). The intent here was to skip lazy fetches of promisor objects: we have already verified that the object is not a promisor object, so if the object is missing it indicates a corrupt repository. The hardcoded value that we pass maps to `HAS_OBJECT_RECHECK_PACKED`, which is probably the intended behaviour: `odb_has_object()` will not fetch promisor objects unless `HAS_OBJECT_FETCH_PROMISOR` is passed, but we may want to verify that no concurrent process has written the object that we're trying to read. Convert the code to use the named flag instead of the the hardcoded value. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 048357d commit 6cf965c

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

builtin/fsck.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ static int mark_object(struct object *obj, enum object_type type,
162162
return 0;
163163

164164
if (!(obj->flags & HAS_OBJ)) {
165-
if (parent && !odb_has_object(the_repository->objects, &obj->oid, 1)) {
165+
if (parent && !odb_has_object(the_repository->objects, &obj->oid,
166+
HAS_OBJECT_RECHECK_PACKED)) {
166167
printf_ln(_("broken link from %7s %s\n"
167168
" to %7s %s"),
168169
printable_type(&parent->oid, parent->type),

0 commit comments

Comments
 (0)