Re: [PATCH 1/3] pack-objects: fix handling of multiple --filter options
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Nov 12, 2022, 11:41 UTC
- Message-ID
- <221112.86bkpcmm6i.gmgdl@evledraar.gmail.com>
- In-Reply-To
- <53bffbf4-8308-0dd7-bca5-7c85b8334e05@web.de>
On Sat, Nov 12 2022, René Scharfe wrote:
Show 5 quoted lines
> 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.
If I do e.g. this with SANITIZE=leak:
echo e83c5163316f89bfbde7d9ab23ca2e25604af290 | ./git pack-objects --revs --filter=blob:limit=1001 --filter=object:type=blob --stdout >/dev/null
I see one leak that wasn't there, but two that are gone now. I haven't looked into it, but I think the commit message should discuss what leaks are fixed, which remain/are new etc.
Show 10 quoted lines
> @@ -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;FWIW as this goes away in your 2/3 I think just squashing the two with a leak fix would be nice, if...
Show 10 quoted lines
> diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh > index bb633c9b09..bd8983bb56 100755 > --- a/t/t5317-pack-objects-filter-objects.sh > +++ b/t/t5317-pack-objects-filter-objects.sh > @@ -178,6 +178,25 @@ test_expect_success 'verify blob:limit=1001' ' > test_cmp expected observed > ' > > +test_expect_success 'verify blob:limit=1001+object:type=blob' ' > + git -C r2 ls-files -s large.1000 |
Aside: Should do "git >tmp && test_parse... <tmp", we lose the exit code of "ls-files" here.
Show 12 quoted lines
> + test_parse_ls_files_stage_oids | > + sort >expected && > + > + git -C r2 pack-objects --revs --stdout --filter=blob:limit=1001 \ > + --filter=object:type=blob >filter.pack <<-EOF && > + HEAD > + EOF > + git -C r2 index-pack ../filter.pack && > + > + git -C r2 verify-pack -v ../filter.pack >verify_result && > + grep blob verify_result | > + parse_verify_pack_blob_oid |
Whereas this one's not a problem, no "git".
> + sort >observed && > + > + test_cmp expected observed
Aside: It would be nice if we had a "test_cmp_sort", but some other day...
Show 5 quoted lines
> +' > + > test_expect_success 'verify blob:limit=10001' ' > git -C r2 ls-files -s large.1000 large.10000 | > test_parse_ls_files_stage_oids |
...we can test it, but this test is in a file that's not part of "linux-leaks".
If that one leak I mentioned above can be fixed (or maybe it's not new?) this could be tested if we put it in a file of its own with TEST_PASSES_SANITIZE_LEAK=true.