]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pack-objects: fix handling of multiple --filter options
authorRené Scharfe <l.s.r@web.de>
Tue, 29 Nov 2022 12:23:53 +0000 (13:23 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 30 Nov 2022 01:00:33 +0000 (10:00 +0900)
Since 5cb28270a1 (pack-objects: lazily set up "struct rev_info", don't
leak, 2022-03-28) --filter options given to git pack-objects overrule
earlier ones, letting only the leftmost win and leaking the memory
allocated for earlier ones.  Fix that by only initializing the rev_info
struct once.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/pack-objects.c
t/t5317-pack-objects-filter-objects.sh

index 573d0b20b76b5115c99781b28f65ae1b5d7d8dc3..c702c09dd45e7fc84e6867c5449012a7e10c1e51 100644 (file)
@@ -4158,7 +4158,8 @@ static struct list_objects_filter_options *po_filter_revs_init(void *value)
 {
        struct po_filter_data *data = value;
 
-       repo_init_revisions(the_repository, &data->revs, NULL);
+       if (!data->have_revs)
+               repo_init_revisions(the_repository, &data->revs, NULL);
        data->have_revs = 1;
 
        return &data->revs.filter;
index 25faebaada89af482ec14ff5ff2e1cd9a673a84a..5b707d911b5818f29ed75650256b096bd680168a 100755 (executable)
@@ -265,7 +265,7 @@ test_expect_success 'verify normal and blob:limit packfiles have same commits/tr
        test_cmp expected observed
 '
 
-test_expect_failure 'verify small limit and big limit results in small limit' '
+test_expect_success 'verify small limit and big limit results in small limit' '
        git -C r2 ls-files -s large.1000 >ls_files_result &&
        test_parse_ls_files_stage_oids <ls_files_result |
        sort >expected &&