Re: [PATCH 5/5] builtin/multi-pack-index: de-globalize options handling
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Dec 1, 2026, 10:59 UTC
- Message-ID
- <aw6onR6DqUkKJmzY@pks.im>
- In-Reply-To
- <d8ac438101939336c17481b18ab8f3636aaabbd5.1796075503.git.jltobler@gmail.com>
On Mon, Nov 30, 2026 at 03:55:01PM -0600, Justin Tobler wrote:
Show 19 quoted lines
> diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c > index d3881aee6a11..eb5c77456b33 100644 > --- a/builtin/multi-pack-index.c > +++ b/builtin/multi-pack-index.c > @@ -214,6 +216,7 @@ static int cmd_multi_pack_index_write(int argc, const char **argv, > > string_list_clear(&packs, 0); > free(opts.refs_snapshot); > + free(opts.object_dir); > > return ret; > > @@ -223,6 +226,7 @@ static int cmd_multi_pack_index_write(int argc, const char **argv, > opts.refs_snapshot, opts.flags); > > free(opts.refs_snapshot); > + free(opts.object_dir); > return ret; > }
Okay. Now that the options aren't global anymore we of course have to free everything they reference. It would have been nice though to unify the logic a bit, either by introducing a common return path or by introducing a function that releases the memory held on to by `opts`. Or both.
Show 9 quoted lines
> @@ -404,8 +424,5 @@ int cmd_multi_pack_index(int argc, > argc = parse_options(argc, argv, prefix, options, > builtin_multi_pack_index_usage, 0); > > - res = fn(argc, argv, prefix, repo); > - > - free(opts.object_dir); > - return res; > + return fn(argc, argv, prefix, repo);
Ah, no, not quite. We did free it, but in the global function. Quite ugly, so good that we're getting rid of this now.
Thanks!
Patrick