Re: [PATCH 3/6] t6601: add helper for testing path-walk API
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Nov 6, 2024, 14:04 UTC
- Message-ID
- <Zyt3aE2yNOgDyw4Y@pks.im>
- In-Reply-To
- <6f93dff88e7cf81800c8f2c8d39175d962a0576f.1730356023.git.gitgitgadget@gmail.com>
On Thu, Oct 31, 2024 at 06:27:00AM +0000, Derrick Stolee via GitGitGadget wrote: [snip]
Show 35 quoted lines
> +int cmd__path_walk(int argc, const char **argv)
> +{
> + int res;
> + struct rev_info revs = REV_INFO_INIT;
> + struct path_walk_info info = PATH_WALK_INFO_INIT;
> + struct path_walk_test_data data = { 0 };
> + struct option options[] = {
> + OPT_END(),
> + };
> +
> + initialize_repository(the_repository);
> + setup_git_directory();
> + revs.repo = the_repository;
> +
> + argc = parse_options(argc, argv, NULL,
> + options, path_walk_usage,
> + PARSE_OPT_KEEP_UNKNOWN_OPT | PARSE_OPT_KEEP_ARGV0);
> +
> + if (argc > 1)
> + setup_revisions(argc, argv, &revs, NULL);
> + else
> + usage(path_walk_usage[0]);
> +
> + info.revs = &revs;
> + info.path_fn = emit_block;
> + info.path_fn_data = &data;
> +
> + res = walk_objects_by_path(&info);
> +
> + printf("trees:%" PRIuMAX "\n"
> + "blobs:%" PRIuMAX "\n",
> + data.tree_nr, data.blob_nr);
> +
> + return res;
> +}This function is leaking memory. I'd propose to add below patch on top to plug them, which makes t6601 pass with the leak sanitizer enabled.
Patrick
diff --git a/t/helper/test-path-walk.c b/t/helper/test-path-walk.c index 06b103d876..fa3bfe46b5 100644 --- a/t/helper/test-path-walk.c +++ b/t/helper/test-path-walk.c @@ -85,7 +85,6 @@ int cmd__path_walk(int argc, const char **argv) OPT_END(), }; - initialize_repository(the_repository); setup_git_directory(); revs.repo = the_repository; @@ -110,5 +109,6 @@ int cmd__path_walk(int argc, const char **argv) "tags:%" PRIuMAX "\n", data.commit_nr, data.tree_nr, data.blob_nr, data.tag_nr); + release_revisions(&revs); return res; }