Skip to content

Commit 825babe

Browse files
rscharfegitster
authored andcommitted
pack-objects: fix handling of multiple --filter options
Since 5cb2827 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f00d811 commit 825babe

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

builtin/pack-objects.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4158,7 +4158,8 @@ static struct list_objects_filter_options *po_filter_revs_init(void *value)
41584158
{
41594159
struct po_filter_data *data = value;
41604160

4161-
repo_init_revisions(the_repository, &data->revs, NULL);
4161+
if (!data->have_revs)
4162+
repo_init_revisions(the_repository, &data->revs, NULL);
41624163
data->have_revs = 1;
41634164

41644165
return &data->revs.filter;

t/t5317-pack-objects-filter-objects.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ test_expect_success 'verify normal and blob:limit packfiles have same commits/tr
265265
test_cmp expected observed
266266
'
267267

268-
test_expect_failure 'verify small limit and big limit results in small limit' '
268+
test_expect_success 'verify small limit and big limit results in small limit' '
269269
git -C r2 ls-files -s large.1000 >ls_files_result &&
270270
test_parse_ls_files_stage_oids <ls_files_result |
271271
sort >expected &&

0 commit comments

Comments
 (0)