From: Patrick Steinhardt Date: Wed, 02 Dec 2026 16:04:06 GMT Subject: Re: [PATCH v2 1/5] builtin/multi-pack-index: resolve default object directory lazily Message-ID: In-Reply-To: <3e6369b99ba39b135fc1b315dc0721d098968e13.1796147221.git.jltobler@gmail.com> On Tue, Dec 01, 2026 at 12:16:12PM -0600, Justin Tobler wrote: > diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c > index c48212290cf8..ba5f326dd6ef 100644 > --- a/builtin/multi-pack-index.c > +++ b/builtin/multi-pack-index.c > @@ -73,33 +72,24 @@ static struct opts_multi_pack_index { > int stdin_packs; > } opts; > > - > -static int parse_object_dir(const struct option *opt, const char *arg, > - int unset) > -{ > - char **value = opt->value; > - free(*value); > - if (unset) > - *value = xstrdup(the_repository->objects->source->path); > - else > - *value = real_pathdup(arg, 1); > - return 0; > -} > - > static struct odb_source_packed *handle_object_dir_option(struct repository *repo) > { > - struct odb_files_dir *dir = odb_source_files_find_dir(repo->objects, opts.object_dir); > + const char *object_dir = opts.object_dir; > + struct odb_files_dir *dir; > + > + if (!object_dir) > + object_dir = repo->objects->source->path; > + > + dir = odb_source_files_find_dir(repo->objects, object_dir); > if (!dir) > die(_("object directory is not an alternate of the current repository: '%s'"), > - opts.object_dir); > + object_dir); > return dir->packed; > } > > static struct option common_opts[] = { > - OPT_CALLBACK(0, "object-dir", &opts.object_dir, > - N_("directory"), > - N_("object directory containing set of packfile and pack-index pairs"), > - parse_object_dir), > + OPT_STRING(0, "object-dir", &opts.object_dir, N_("directory"), > + N_("object directory containing set of packfile and pack-index pairs")), > OPT_BIT(0, "progress", &opts.flags, N_("force progress reporting"), > MIDX_PROGRESS), > OPT_END(), Nice simplification overall. Patrick