On 4/21/2022 3:50 PM, Victoria Dye wrote: > 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