From: Justin Tobler <jltobler@gmail.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org, Karthik Nayak <karthik.188@gmail.com>,
Jeff King <peff@peff.net>
Subject: Re: [PATCH v2 2/8] setup: stop applying repository format twice
Date: Wed, 17 Jun 2026 12:22:50 -0500 [thread overview]
Message-ID: <ajLV1if5XYO-pyNb@denethor> (raw)
In-Reply-To: <20260615-b4-pks-refs-avoid-chdir-notify-reparent-v2-2-f4854aa99859@pks.im>
On 26/06/15 03:56PM, Patrick Steinhardt wrote:
> When discovering the repository in "setup.c" we apply the final
> repository format multiple times:
>
> - Once via `repository_format_configure()`, where we apply the hash
> algorithm and ref storage format to both `struct repository_format`
> and `struct repository`.
>
> - And once via `apply_repository_format()`, where we apply these two
> settings from `struct repository_format` to `struct repository`.
>
> With the current flow both of these are in fact necessary. But this is
> only because we call `repository_format_configure()` after we have
> called `apply_repository_format()`. Consequently, if we only changed the
> repository format in `repository_format_configure()` it would never
> propagate to the repository.
Ok, so because `repository_format_configure()` is invoked after the
repository format was already applied, it had to explictly configure the
repository as well.
> Refactor the code so that we first configure the repository format
> before applying it to the repository so that we can stop setting the
> hash and reference storage format multiple times.
Makes sense. Sounds like a good change.
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> setup.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/setup.c b/setup.c
> index a9db1f2c23..2748155964 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -2710,8 +2710,7 @@ static int read_default_format_config(const char *key, const char *value,
> return ret;
> }
>
> -static void repository_format_configure(struct repository *repo,
> - struct repository_format *repo_fmt,
> +static void repository_format_configure(struct repository_format *repo_fmt,
> int hash, enum ref_storage_format ref_format)
We now only care about configuring the repository format and will let
`apply_repository_format()` handle setting the repository. Looks good.
[snip]
> @@ -2830,10 +2825,10 @@ int init_db(struct repository *repo,
> * is an attempt to reinitialize new repository with an old tool.
> */
> check_repository_format_gently(repo_get_git_dir(repo), &repo_fmt, NULL);
> + repository_format_configure(&repo_fmt, hash, ref_storage_format);
> if (apply_repository_format(repo, &repo_fmt, APPLY_REPOSITORY_FORMAT_HONOR_ENV, &err) < 0)
> die("%s", err.buf);
> startup_info->have_repository = 1;
> - repository_format_configure(repo, &repo_fmt, hash, ref_storage_format);
`apply_repository_format()` already has the logic to set the hash algo
and ref storage format from the repository format, so change changing
the order here is ok and a good change.
-Justin
next prev parent reply other threads:[~2026-06-17 17:22 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 14:57 [PATCH 0/9] refs: stop using `chdir_notify_reparent()` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 1/9] setup: inline `check_and_apply_repository_format()` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 2/9] setup: stop applying repository format twice Patrick Steinhardt
2026-06-12 9:00 ` Karthik Nayak
2026-06-15 12:36 ` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 3/9] setup: don't apply "GIT_REFERENCE_BACKEND" without a repository Patrick Steinhardt
2026-06-10 17:32 ` Junio C Hamano
2026-06-12 6:18 ` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 4/9] refs: unregister reference stores from "chdir_notify" Patrick Steinhardt
2026-06-12 9:18 ` Karthik Nayak
2026-06-15 12:36 ` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 5/9] chdir-notify: drop unused `chdir_notify_reparent()` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 6/9] repository: free main reference database Patrick Steinhardt
2026-06-12 9:20 ` Karthik Nayak
2026-06-10 14:57 ` [PATCH 7/9] refs: fix recursing `get_main_ref_store()` with "onbranch" config Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 8/9] refs: drop local buffer in `refs_compute_filesystem_location()` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 9/9] refs: always use absolute paths for reference stores Patrick Steinhardt
2026-06-12 9:58 ` Karthik Nayak
2026-06-15 12:36 ` Patrick Steinhardt
2026-06-11 6:53 ` [PATCH 0/9] refs: stop using `chdir_notify_reparent()` Jeff King
2026-06-12 6:18 ` Patrick Steinhardt
2026-06-13 14:00 ` Jeff King
2026-06-15 12:36 ` Patrick Steinhardt
2026-06-15 13:56 ` [PATCH v2 0/8] " Patrick Steinhardt
2026-06-15 13:56 ` [PATCH v2 1/8] setup: inline `check_and_apply_repository_format()` Patrick Steinhardt
2026-06-15 13:56 ` [PATCH v2 2/8] setup: stop applying repository format twice Patrick Steinhardt
2026-06-17 17:22 ` Justin Tobler [this message]
2026-06-15 13:56 ` [PATCH v2 3/8] setup: don't apply "GIT_REFERENCE_BACKEND" without a repository Patrick Steinhardt
2026-06-17 17:43 ` Justin Tobler
2026-06-15 13:56 ` [PATCH v2 4/8] refs: unregister reference stores from "chdir_notify" Patrick Steinhardt
2026-06-17 18:02 ` Justin Tobler
2026-06-17 18:07 ` Justin Tobler
2026-06-15 13:56 ` [PATCH v2 5/8] chdir-notify: drop unused `chdir_notify_reparent()` Patrick Steinhardt
2026-06-15 13:56 ` [PATCH v2 6/8] repository: free main reference database Patrick Steinhardt
2026-06-17 18:09 ` Justin Tobler
2026-06-15 13:56 ` [PATCH v2 7/8] refs: fix recursing `get_main_ref_store()` with "onbranch" config Patrick Steinhardt
2026-06-17 18:41 ` Justin Tobler
2026-06-15 13:56 ` [PATCH v2 8/8] refs: drop local buffer in `refs_compute_filesystem_location()` Patrick Steinhardt
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=ajLV1if5XYO-pyNb@denethor \
--to=jltobler@gmail.com \
--cc=git@vger.kernel.org \
--cc=karthik.188@gmail.com \
--cc=peff@peff.net \
--cc=ps@pks.im \
/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.