Re: [GSoC PATCH v4 2/7] list-objects-filter: add list_objects_filter__filter_oidset()
- From
Christian Couder <christian.couder@gmail.com>
- Date
- Aug 12, 2026, 17:09 UTC
- Message-ID
- <CAP8UFD0i6zo1pLLeKS4oGismNvadZ2Xc_QC1tt_9KuJiMJq40Q@mail.gmail.com>
- In-Reply-To
- <20260810174047.6524-3-r.siddharth.shrimali@gmail.com>
On Mon, Aug 10, 2026 at 7:41 PM Siddharth Shrimali <r.siddharth.shrimali@gmail.com> wrote:
[...]
Show 19 quoted lines
> diff --git a/list-objects-filter.c b/list-objects-filter.c > index c912ff3079..6a2e9d5b24 100644 > --- a/list-objects-filter.c > +++ b/list-objects-filter.c > @@ -828,3 +828,48 @@ void list_objects_filter__free(struct filter *filter) > filter->free_fn(filter->filter_data); > free(filter); > } > + > +/* > + * NEEDSWORK: this reimplements the blob:limit size check rather than > + * reusing the existing filter machinery in > + * list_objects_filter__filter_object(). That machinery is currently > + * tied to the object-walk path and cannot easily be driven from a > + * plain oidset. It would be nice to refactor the filter code so this > + * helper can reuse it instead of duplicating the size check. > + */ > +int list_objects_filter__filter_oidset(struct repository *r, > + struct list_objects_filter_options *opts,
I think this could be "const" like "const struct list_objects_filter_options *opts," which could avoid a cast in a following patch...
Show 34 quoted lines
> + const struct oidset *in,
> + struct oidset *omitted)
> +{
> + struct oidset_iter iter;
> + const struct object_id *oid;
> +
> + if (opts->choice != LOFC_BLOB_LIMIT)
> + return error(_("filter_oidset: only blob:limit filters are supported"));
> +
> + oidset_iter_init(in, &iter);
> + while ((oid = oidset_iter_next(&iter))) {
> + struct object_info info = OBJECT_INFO_INIT;
> + enum object_type type;
> + unsigned long size;
> +
> + info.typep = &type;
> + info.sizep = &size;
> +
> + /*
> + * Use OBJECT_INFO_SKIP_FETCH_OBJECT to avoid triggering
> + * a lazy fetch while inspecting candidates for removal.
> + */
> + if (odb_read_object_info_extended(r->objects, oid, &info,
> + OBJECT_INFO_SKIP_FETCH_OBJECT) < 0)
> + continue;
> +
> + if (type != OBJ_BLOB)
> + continue;
> +
> + if (size >= opts->blob_limit_value)
> + oidset_insert(omitted, oid);
> + }
> + return 0;
> +}... as opts is only used to check `opts->choice != LOFC_BLOB_LIMIT` and `size >= opts->blob_limit_value`.