Re: [PATCH v2 7/8] builtin/clone: write alternates via `odb_create_on_disk()`
- From
Justin Tobler <jltobler@gmail.com>
- Date
- Sep 6, 2026, 17:07 UTC
- Message-ID
- <ap2c8QObeMWlGSd2@denethor>
- In-Reply-To
- <20260831-pks-odb-write-alternates-at-creation-time-v2-7-aecd2382ba1c@pks.im>
On 26/08/31 12:02PM, Patrick Steinhardt wrote:
Show 7 quoted lines
> When creating a repository with alternates we first initialize the > object database and then write alternates to it in a separate step. This > is unfortunate due to a couple of reasons: > > - It requires us to have a `write_alternates()` callback, which is > unfortunate as we never even write alternates to an object database > after it has been created.
Happy to see the list of callbacks shrink. :)
Show 12 quoted lines
> - We're about to make alternates an implementation detail of the > object database's backend in a future patch series, so having this > callback is suboptimal there. > > - The backend has more flexibility with how exactly alternates are > configured when it itself is in full control over their setup at the > time where it creates the object database itself. > > We have thus introduced the ability to write alternates right at > creation time in the preceding commits, and we have unified setup of > alternates into a single location. All that's left to do for us now is > to wire up alternates as an option for the database creation.
Makes sense.
Show 23 quoted lines
> Do so.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> builtin/clone.c | 5 +----
> setup.c | 9 ++++++---
> setup.h | 2 +-
> 3 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/builtin/clone.c b/builtin/clone.c
> index 2e3473fddf..48ac379b1d 100644
> --- a/builtin/clone.c
> +++ b/builtin/clone.c
> @@ -1368,11 +1368,8 @@ int cmd_clone(int argc,
> if (option_local > 0 && !is_local)
> warning(_("--local is ignored"));
>
> - create_object_database(the_repository);
> collect_alternates(&alternates, path, is_local);
> -
> - for (size_t i = 0; i < alternates.nr; i++)
> - odb_add_to_alternates_file(the_repository->objects, alternates.v[i]);
> + create_object_database(the_repository, &alternates);Alternates are no longer explicitly set up here and instead wired and handled via `create_object_database()`. This patch looks good.
-Justin