pack-objects: simplify --filter handling
commit0d5448a554723acfb0d8bbb131e0583504dc7230
authorRené Scharfe <l.s.r@web.de>
Tue, 29 Nov 2022 12:25:05 +0000 (29 13:25 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 30 Nov 2022 01:00:33 +0000 (30 10:00 +0900)
treea18b5dc3d8ef1eeb534f25c3f0a45389b7fc899a
parent825babe5d5c720cb196f4f12c8eeb15fe00e95a1
pack-objects: simplify --filter handling

pack-objects uses OPT_PARSE_LIST_OBJECTS_FILTER_INIT() to initialize the
a rev_info struct lazily before populating its filter member using the
--filter option values.  It tracks whether the initialization is needed
using the .have_revs member of the callback data.

There is a better way: Use a stand-alone list_objects_filter_options
struct and build a rev_info struct with its .filter member after option
parsing.  This allows using the simpler OPT_PARSE_LIST_OBJECTS_FILTER()
and getting rid of the extra callback mechanism.

Even simpler would be using a struct rev_info as before 5cb28270a1
(pack-objects: lazily set up "struct rev_info", don't leak, 2022-03-28),
but that would expose a memory leak caused by repo_init_revisions()
followed by release_revisions() without a setup_revisions() call in
between.

Using list_objects_filter_options also allows pushing the rev_info
struct into get_object_list(), where it arguably belongs. Either way,
this is all left for later.

Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/pack-objects.c