From: Justin Tobler <jltobler@gmail.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org, Toon Claes <toon@iotcl.com>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v3 2/9] builtin/clone: defer setup of the object database
Date: Tue, 8 Sep 2026 17:20:06 -0500 [thread overview]
Message-ID: <aqCI5pfM3AGtfQsJ@denethor> (raw)
In-Reply-To: <20260907-pks-odb-write-alternates-at-creation-time-v3-2-735d0b5b3e00@pks.im>
On 26/09/07 10:25AM, Patrick Steinhardt wrote:
> When cloning a repository we defer initialization of the reference
> database. This is because we don't yet know all details required for us
> to initialize the refdb in the first place. Most importantly, what we
> are missing is information about the object hash.
>
> We don't do the same thing for the object database yet, but here we
> essentially have the same problem. While the "files" database does not
> need any information about the object format at creation time, alternate
> backends are likely to require that information so that they can
> properly set up their data structures.
>
> Besides this forward-looking future proofing though, we also have a
> second use case for deferring initialization of the object database,
> namely alternates. When initializing the object database we do not yet
> know whether we'll need alternates or not because this depends on the
> repository we're about to clone from. If it is a local repository and
> the user has passed "--refernce{,-if-able}", then we will end up writing
> alternates into the object database.
>
> The ugly part though is that we cannot determine where the repository is
> getting cloned from before it has been initialized. While we of course
> already have access to the user-provided URI, that URI can be very well
> rewritten via "url.<base>.insteadOf". We can of course read the global-
> and system-level configuration to resolve it. But we explicitly resolve
> the URI a second time after we have initialized the repository because
> it can happen that we copy a ".git/config" over from our templates, and
> that file may cause us to rewrite the path.
>
> In a subsequent commit though we'll start to write alternates as part of
> the repository initialization, so we'll need to have the URI properly
> resolved before we can initialize the object database. This is ugly, but
> as mentioned above it makes sense for us to defer its initialization
> anyway so that we also know about the object hash already.
>
> Defer creation of the object database until after we have resolved the
> URI.
>
> Note that this also requires us to defer the call to `setup_reference()`
> until after we have created the object database. While you might think
> that this function has something to do with references ("refs/*"), it is
> in fact responsible for setting up alternates. Consequently, we can only
> call it after we have created the object database already.
Ah ok, so now that we are deferring ODB creation a bit further, we need
to also move ref DB creation to afterwards too. Makes sense.
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> builtin/clone.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/builtin/clone.c b/builtin/clone.c
> index 904d2d859f..bdcbd7aa1b 100644
> --- a/builtin/clone.c
> +++ b/builtin/clone.c
> @@ -1188,7 +1188,6 @@ int cmd_clone(int argc,
> create_repository(the_repository, git_dir, real_git_dir, work_tree,
> option_template, GIT_HASH_UNKNOWN, ref_storage_format,
> do_not_override_repo_unix_permissions, NULL);
> - create_object_database(the_repository);
>
> if (real_git_dir) {
> free((char *)git_dir);
> @@ -1311,9 +1310,6 @@ int cmd_clone(int argc,
> strbuf_reset(&key);
> }
>
> - if (option_required_reference.nr || option_optional_reference.nr)
> - setup_reference();
> -
> remote = remote_get_early(remote_name);
>
> if (!option_rev)
> @@ -1342,6 +1338,10 @@ int cmd_clone(int argc,
> if (option_local > 0 && !is_local)
> warning(_("--local is ignored"));
>
> + create_object_database(the_repository);
> + if (option_required_reference.nr || option_optional_reference.nr)
> + setup_reference();
Ok so the move here is really just in preparation for the alternates
setup being handled as part of ODB creation in a subsequent patch and
purely just structural. Looks good.
-Justin
next prev parent reply other threads:[~2026-09-08 22:20 UTC|newest]
Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 14:11 [PATCH 0/8] odb: write alternates at creation time Patrick Steinhardt
2026-08-25 14:11 ` [PATCH 1/8] builtin/clone: defer setup of the object database Patrick Steinhardt
2026-08-25 14:11 ` [PATCH 2/8] builtin/clone: move around `setup_reference()` Patrick Steinhardt
2026-08-25 14:11 ` [PATCH 3/8] builtin/clone: refactor handling of "--reference{,-if-able}" Patrick Steinhardt
2026-08-28 14:52 ` Toon Claes
2026-08-25 14:11 ` [PATCH 4/8] builtin/clone: move setup of alternates for shared local clones Patrick Steinhardt
2026-08-28 14:52 ` Toon Claes
2026-08-25 14:11 ` [PATCH 5/8] builtin/clone: move setup of alternates for non-shared " Patrick Steinhardt
2026-08-28 14:52 ` Toon Claes
2026-08-31 8:13 ` Patrick Steinhardt
2026-08-25 14:11 ` [PATCH 6/8] odb/source: support writing alternates when creating the database Patrick Steinhardt
2026-08-28 14:53 ` Toon Claes
2026-08-31 8:14 ` Patrick Steinhardt
2026-08-28 19:13 ` Junio C Hamano
2026-08-31 8:14 ` Patrick Steinhardt
2026-08-25 14:11 ` [PATCH 7/8] builtin/clone: write alternates via `odb_create_on_disk()` Patrick Steinhardt
2026-08-25 14:11 ` [PATCH 8/8] odb/source: remove the ability to write alternates Patrick Steinhardt
2026-08-28 14:53 ` Toon Claes
2026-08-31 8:14 ` Patrick Steinhardt
2026-08-31 10:02 ` [PATCH v2 0/8] odb: write alternates at creation time Patrick Steinhardt
2026-08-31 10:02 ` [PATCH v2 1/8] builtin/clone: defer setup of the object database Patrick Steinhardt
2026-09-06 16:42 ` Justin Tobler
2026-09-07 7:23 ` Patrick Steinhardt
2026-08-31 10:02 ` [PATCH v2 2/8] builtin/clone: move around `setup_reference()` Patrick Steinhardt
2026-08-31 10:02 ` [PATCH v2 3/8] builtin/clone: refactor handling of "--reference{,-if-able}" Patrick Steinhardt
2026-08-31 10:02 ` [PATCH v2 4/8] builtin/clone: move setup of alternates for shared local clones Patrick Steinhardt
2026-08-31 10:02 ` [PATCH v2 5/8] builtin/clone: move setup of alternates for non-shared " Patrick Steinhardt
2026-08-31 10:02 ` [PATCH v2 6/8] odb/source: support writing alternates when creating the database Patrick Steinhardt
2026-09-06 17:02 ` Justin Tobler
2026-09-07 7:23 ` Patrick Steinhardt
2026-08-31 10:02 ` [PATCH v2 7/8] builtin/clone: write alternates via `odb_create_on_disk()` Patrick Steinhardt
2026-09-06 17:07 ` Justin Tobler
2026-08-31 10:02 ` [PATCH v2 8/8] odb/source: remove the ability to write alternates Patrick Steinhardt
2026-09-01 6:09 ` [PATCH v2 0/8] odb: write alternates at creation time Toon Claes
2026-09-07 8:25 ` [PATCH v3 0/9] " Patrick Steinhardt
2026-09-07 8:25 ` [PATCH v3 1/9] setup: split up concerns of `init_db()` Patrick Steinhardt
2026-09-08 22:12 ` Justin Tobler
2026-09-09 5:48 ` Patrick Steinhardt
2026-09-07 8:25 ` [PATCH v3 2/9] builtin/clone: defer setup of the object database Patrick Steinhardt
2026-09-08 22:20 ` Justin Tobler [this message]
2026-09-09 5:48 ` Patrick Steinhardt
2026-09-07 8:25 ` [PATCH v3 3/9] builtin/clone: move around `setup_reference()` Patrick Steinhardt
2026-09-07 8:25 ` [PATCH v3 4/9] builtin/clone: refactor handling of "--reference{,-if-able}" Patrick Steinhardt
2026-09-07 8:25 ` [PATCH v3 5/9] builtin/clone: move setup of alternates for shared local clones Patrick Steinhardt
2026-09-08 22:43 ` Justin Tobler
2026-09-08 22:48 ` Justin Tobler
2026-09-07 8:25 ` [PATCH v3 6/9] builtin/clone: move setup of alternates for non-shared " Patrick Steinhardt
2026-09-07 8:25 ` [PATCH v3 7/9] odb/source: support writing alternates when creating the database Patrick Steinhardt
2026-09-07 8:25 ` [PATCH v3 8/9] builtin/clone: write alternates via `odb_create_on_disk()` Patrick Steinhardt
2026-09-07 8:25 ` [PATCH v3 9/9] odb/source: remove the ability to write alternates Patrick Steinhardt
2026-09-09 5:48 ` [PATCH v4 0/9] odb: write alternates at creation time Patrick Steinhardt
2026-09-09 5:48 ` [PATCH v4 1/9] setup: split up concerns of `init_db()` Patrick Steinhardt
2026-09-10 9:24 ` Karthik Nayak
2026-09-09 5:48 ` [PATCH v4 2/9] builtin/clone: defer setup of the object database Patrick Steinhardt
2026-09-10 9:28 ` Karthik Nayak
2026-09-09 5:48 ` [PATCH v4 3/9] builtin/clone: move around `setup_reference()` Patrick Steinhardt
2026-09-10 9:29 ` Karthik Nayak
2026-09-09 5:48 ` [PATCH v4 4/9] builtin/clone: refactor handling of "--reference{,-if-able}" Patrick Steinhardt
2026-09-10 9:37 ` Karthik Nayak
2026-09-10 14:26 ` Patrick Steinhardt
2026-09-09 5:48 ` [PATCH v4 5/9] builtin/clone: move setup of alternates for shared local clones Patrick Steinhardt
2026-09-10 10:52 ` Karthik Nayak
2026-09-10 10:54 ` Karthik Nayak
2026-09-10 14:26 ` Patrick Steinhardt
2026-09-09 5:48 ` [PATCH v4 6/9] builtin/clone: move setup of alternates for non-shared " Patrick Steinhardt
2026-09-10 11:00 ` Karthik Nayak
2026-09-09 5:48 ` [PATCH v4 7/9] odb/source: support writing alternates when creating the database Patrick Steinhardt
2026-09-10 11:10 ` Karthik Nayak
2026-09-11 5:15 ` Patrick Steinhardt
2026-09-09 5:48 ` [PATCH v4 8/9] builtin/clone: write alternates via `odb_create_on_disk()` Patrick Steinhardt
2026-09-09 5:48 ` [PATCH v4 9/9] odb/source: remove the ability to write alternates Patrick Steinhardt
2026-09-09 18:30 ` [PATCH v4 0/9] odb: write alternates at creation time Justin Tobler
2026-09-10 15:09 ` [PATCH v5 " Patrick Steinhardt
2026-09-10 15:09 ` [PATCH v5 1/9] setup: split up concerns of `init_db()` Patrick Steinhardt
2026-09-10 15:09 ` [PATCH v5 2/9] builtin/clone: defer setup of the object database Patrick Steinhardt
2026-09-10 15:09 ` [PATCH v5 3/9] builtin/clone: move around `setup_reference()` Patrick Steinhardt
2026-09-10 15:09 ` [PATCH v5 4/9] builtin/clone: refactor handling of "--reference{,-if-able}" Patrick Steinhardt
2026-09-10 15:09 ` [PATCH v5 5/9] builtin/clone: move setup of alternates for shared local clones Patrick Steinhardt
2026-09-10 15:09 ` [PATCH v5 6/9] builtin/clone: move setup of alternates for non-shared " Patrick Steinhardt
2026-09-10 15:09 ` [PATCH v5 7/9] odb/source: support writing alternates when creating the database Patrick Steinhardt
2026-09-10 15:09 ` [PATCH v5 8/9] builtin/clone: write alternates via `odb_create_on_disk()` Patrick Steinhardt
2026-09-10 15:09 ` [PATCH v5 9/9] odb/source: remove the ability to write alternates Patrick Steinhardt
2026-09-10 19:53 ` [PATCH v5 0/9] odb: write alternates at creation time Karthik Nayak
2026-09-11 5:15 ` 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=aqCI5pfM3AGtfQsJ@denethor \
--to=jltobler@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ps@pks.im \
--cc=toon@iotcl.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox