]> git.ipfire.org Git - thirdparty/git.git/commitdiff
test-bloom: stop setting up Git directory twice
authorPatrick Steinhardt <ps@pks.im>
Mon, 6 Nov 2023 10:45:53 +0000 (11:45 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 6 Nov 2023 23:51:40 +0000 (08:51 +0900)
We're setting up the Git directory twice in the `test-tool bloom`
helper, once at the beginning of `cmd_bloom()` and once in the local
subcommand implementation `get_bloom_filter_for_commit()`. This can lead
to memory leaks as we'll overwrite variables of `the_repository` with
newly allocated data structures. On top of that it's simply unnecessary.

Fix this by only setting up the Git directory once.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/helper/test-bloom.c

index aabe31d724b675e4f69c9f3760bcd0a6e8e9bbad..1281e66876f35d380d5360be23883c5ed27aafcf 100644 (file)
@@ -40,7 +40,6 @@ static void get_bloom_filter_for_commit(const struct object_id *commit_oid)
 {
        struct commit *c;
        struct bloom_filter *filter;
-       setup_git_directory();
        c = lookup_commit(the_repository, commit_oid);
        filter = get_or_compute_bloom_filter(the_repository, c, 1,
                                             &settings,