Re: [GSoC PATCH v4 2/7] list-objects-filter: add list_objects_filter__filter_oidset()

Christian Couder <[email protected]>
Newsgroups org.kernel.vger.git
Message-ID <CAP8UFD0i6zo1pLLeKS4oGismNvadZ2Xc_QC1tt_9KuJiMJq40Q@mail.gmail.com>
On Mon, Aug 10, 2026 at 7:41 PM Siddharth Shrimali
<[email protected]> wrote:

[...]

> 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...

> +       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`.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.