Re: [PATCH 2/2] multi-pack-index: use --object-dir real path
- From
Derrick Stolee <derrickstolee@github.com>
- Date
- Apr 21, 2022, 19:55 UTC
- Message-ID
- <be6aed1c-6237-3090-983f-42ef7e043d72@github.com>
- In-Reply-To
- <936e7f12-362d-3303-ddf4-5b40f17a0b9e@github.com>
On 4/21/2022 3:50 PM, Victoria Dye wrote:
Show 28 quoted lines
> Derrick Stolee via GitGitGadget wrote:
>> +static void normalize_object_dir(void)
>> +{
>> + if (!opts.object_dir)
>> + opts.object_dir = get_object_directory();
>> + else
>> + opts.object_dir = real_pathdup(opts.object_dir, 1);
>> +}
>> +
>
> Rather than copy the 'normalize_object_dir()' calls to every subcommand, you
> could "centralize" this by making the 'object_dir' option an 'OPT_CALLBACK'
> option, something like:
>
> static struct option common_opts[] = {
> OPT_CALLBACK(0, "object-dir", &opts.object_dir, N_("file"),
> N_("object directory containing set of packfile and pack-index pairs"),
> normalize_object_dir),
> OPT_END(),
> };
>
> It would require changing the function signature of 'normalize_object_dir'
> to match what's shown in 'Documentation/technical/api-parse-options.txt',
> and it potentially needs prefix handling similar to what's done in
> parse-options.c:get_value() (which internally calls 'fix_filename()' for
> filename opts), but I think it's probably worth reducing duplication here
> and avoiding the need to add 'normalize_object_dir()' to any new subcommand
> in the future.Thanks! I agree that that would be a cleaner approach, especially if a new subcommand is added in the future.
Thanks, -Stolee