[PATCH v2 11/13] list-objects: clarify how promised blobs are excluded
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Apr 25, 2025, 07:09 UTC
- Message-ID
- <20250425-pks-object-store-cleanups-v2-11-63f1695b7700@pks.im>
- In-Reply-To
- <20250425-pks-object-store-cleanups-v2-0-63f1695b7700@pks.im>
When "--exclude-promisor-objects" is passed by the user, commands like git-rev-list(1) will exclude any objects part of a promisor pack. For blobs this logic is handled in `process_blob()` with the following logic:
if (ctx->revs->exclude_promisor_objects &&
!repo_has_object_file(the_repository, &obj->oid) &&
is_promisor_object(ctx->revs->repo, &obj->oid))
return;It is somewhat puzzling that we use `repo_has_object_file()` to check for existence of the blob because this function will cause us to fetch missing objects in case they are part of a promisor pack. As such, one may wonder whether the logic to exclude promised blobs is completely broken.
As it turns out it's not broken: when "--exclude-promisor-objects" is set we also unset the global `fetch_if_missing` variable, which causes `do_oid_object_info_extended()` to not fetch any promised objects at all.
Clarify this logic by using `has_object()`, which doesn't fetch promised objects by default.
Signed-off-by: Patrick Steinhardt <ps@pks.im> --- list-objects.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/list-objects.c b/list-objects.c index 1e5512e1318..cae4f7aff8c 100644 --- a/list-objects.c +++ b/list-objects.c @@ -74,7 +74,8 @@ static void process_blob(struct traversal_context *ctx, * of missing objects. */ if (ctx->revs->exclude_promisor_objects && - !repo_has_object_file(the_repository, &obj->oid) && + !has_object(the_repository, &obj->oid, + HAS_OBJECT_RECHECK_PACKED) && is_promisor_object(ctx->revs->repo, &obj->oid)) return;
-- 2.49.0.901.g37484f566f.dirty