We're about to add a new implementation of the connectivity check via the object quarantine directory, which will directly iterate over any loose object via their paths. For optimization purposes, we'll want to skip over any loose blobs, but right now there's no easy way to read a loose object without also slurping in all its contents. Fix this shortcoming by modifying `read_loose_object()` such that it can handle the case where no pointer for `contents` was passed in. If so, then we'll simply skip reading the loose object. Signed-off-by: Patrick Steinhardt <ps@xxxxxx> --- object-file.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/object-file.c b/object-file.c index 884855b9df..ab695823fd 100644 --- a/object-file.c +++ b/object-file.c @@ -2552,7 +2552,8 @@ int read_loose_object(const char *path, git_zstream stream; char hdr[MAX_HEADER_LEN]; - *contents = NULL; + if (contents) + *contents = NULL; map = map_loose_object_1(the_repository, path, NULL, &mapsize); if (!map) { @@ -2572,6 +2573,12 @@ int read_loose_object(const char *path, goto out; } + if (!contents) { + git_inflate_end(&stream); + ret = 0; + goto out; + } + if (*type == OBJ_BLOB && *size > big_file_threshold) { if (check_stream_oid(&stream, hdr, *size, path, expected_oid) < 0) goto out; -- 2.31.1
Attachment:
signature.asc
Description: PGP signature