]> git.ipfire.org Git - thirdparty/git.git/commit - list-objects-filter-options.h
list-objects-filter: convert filter_spec to a strbuf
authorJeff King <peff@peff.net>
Sun, 11 Sep 2022 05:03:31 +0000 (01:03 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 12 Sep 2022 15:38:59 +0000 (08:38 -0700)
commitc54980ab83661e8e290003fbd5ab44b12e4e77b1
tree0ec7e41434232177aec0c5f2fb040b82676a5014
parent2a01bdedf87d7cbfc4411ff5059cfe406e1637db
list-objects-filter: convert filter_spec to a strbuf

Originally, the filter_spec field was just a string pointer. In
cf9ceb5a12 (list-objects-filter-options: make filter_spec a string_list,
2019-06-27) it became a string_list, but that commit notes:

    A strbuf would seem to be a more natural choice for this object, but
    it unfortunately requires initialization besides just zero'ing out
    the memory.  This results in all container structs, and all
    containers of those structs, etc., to also require initialization.
    Initializing them all would be more cumbersome that simply using a
    string_list, which behaves properly when its contents are zero'd.

Now that we've changed the struct to require non-zero initialization
anyway (ironically, because string_list also needed non-zero
initialization to avoid leaks), we can now convert to that more natural
type.

This makes the list_objects_filter_spec() function much less awkward, as
it had to collapse the string_list to a single-entry list on the fly.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
list-objects-filter-options.c
list-objects-filter-options.h