From: Patrick Steinhardt <ps@pks.im>
To: Justin Tobler <jltobler@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/5] builtin/multi-pack-index: resolve default object directory lazily
Date: Tue, 1 Dec 2026 11:58:13 +0100 [thread overview]
Message-ID: <aw6oO92LKQJM9TwS@pks.im> (raw)
In-Reply-To: <c381afb0da593080ae8fc96a6187b579da829658.1796075503.git.jltobler@gmail.com>
On Mon, Nov 30, 2026 at 03:54:57PM -0600, Justin Tobler wrote:
> diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c
> index c48212290cf8..1a27d523c7ab 100644
> --- a/builtin/multi-pack-index.c
> +++ b/builtin/multi-pack-index.c
> @@ -80,7 +80,7 @@ static int parse_object_dir(const struct option *opt, const char *arg,
> char **value = opt->value;
> free(*value);
> if (unset)
> - *value = xstrdup(the_repository->objects->source->path);
> + *value = NULL;
> else
> *value = real_pathdup(arg, 1);
> return 0;
Makes me wonder whether we could avoid allocating the value altogether
and just assign the static string?
> @@ -88,10 +88,16 @@ static int parse_object_dir(const struct option *opt, const char *arg,
>
> 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;
> }
Okay, so instead of handling the default value in `parse_object_dir()`
we set it up here. Makes sense.
> @@ -424,11 +430,6 @@ int cmd_multi_pack_index(int argc,
>
> repo_config(the_repository, git_default_config, NULL);
>
> - if (the_repository &&
> - the_repository->objects &&
> - the_repository->objects->source)
> - opts.object_dir = xstrdup(the_repository->objects->source->path);
We previously handled the case where there is no repository, but we
don't do that in `handle_object_dir_option()`. But this command does not
run without a repository anyway, so that looks like a sensible change to
me.
Patrick
next prev parent reply other threads:[~2026-12-01 10:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 21:54 [PATCH 0/5] builtin/multi-pack-index: remove global state Justin Tobler
2026-11-30 21:54 ` [PATCH 1/5] builtin/multi-pack-index: resolve default object directory lazily Justin Tobler
2026-12-01 10:58 ` Patrick Steinhardt [this message]
2026-12-01 16:39 ` Justin Tobler
2026-11-30 21:54 ` [PATCH 2/5] builtin/multi-pack-index: get rid of `the_repository` Justin Tobler
2026-12-01 10:58 ` Patrick Steinhardt
2026-12-01 16:46 ` Justin Tobler
2026-11-30 21:54 ` [PATCH 3/5] builtin/multi-pack-index: drop top-level options Justin Tobler
2026-12-01 10:58 ` Patrick Steinhardt
2026-12-01 17:11 ` Justin Tobler
2026-11-30 21:55 ` [PATCH 4/5] builtin/multi-pack-index: simplify how common options are wired up Justin Tobler
2026-12-01 10:58 ` Patrick Steinhardt
2026-12-01 17:13 ` Justin Tobler
2026-11-30 21:55 ` [PATCH 5/5] builtin/multi-pack-index: de-globalize options handling Justin Tobler
2026-12-01 10:59 ` Patrick Steinhardt
2026-12-01 17:18 ` Justin Tobler
2026-12-01 18:16 ` [PATCH v2 0/5] builtin/multi-pack-index: remove global state Justin Tobler
2026-12-01 18:16 ` [PATCH v2 1/5] builtin/multi-pack-index: resolve default object directory lazily Justin Tobler
2026-12-01 18:16 ` [PATCH v2 2/5] builtin/multi-pack-index: get rid of `the_repository` Justin Tobler
2026-12-01 18:16 ` [PATCH v2 3/5] builtin/multi-pack-index: drop top-level options Justin Tobler
2026-12-01 18:16 ` [PATCH v2 4/5] builtin/multi-pack-index: simplify how common options are wired up Justin Tobler
2026-12-01 18:16 ` [PATCH v2 5/5] builtin/multi-pack-index: de-globalize options handling Justin Tobler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aw6oO92LKQJM9TwS@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=jltobler@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.