builtin/clone: write alternates via `odb_create_on_disk()`
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.
- 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.
Do so.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
jch
parent
d540449b15
commit
1b65c850a5
|
|
@ -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);
|
||||
|
||||
transport = transport_get(remote, path ? path : remote->url.v[0]);
|
||||
transport_set_verbosity(transport, option_verbosity, option_progress);
|
||||
|
|
|
|||
9
setup.c
9
setup.c
|
|
@ -2647,9 +2647,12 @@ static int create_default_files(struct repository *repo,
|
|||
return reinit;
|
||||
}
|
||||
|
||||
void create_object_database(struct repository *repo)
|
||||
void create_object_database(struct repository *repo,
|
||||
const struct strvec *alternates)
|
||||
{
|
||||
struct odb_create_on_disk_options opts = { 0 };
|
||||
struct odb_create_on_disk_options opts = {
|
||||
.alternates = alternates,
|
||||
};
|
||||
|
||||
/*
|
||||
* Create the "objects" directory in the common directory. This is done
|
||||
|
|
@ -2907,7 +2910,7 @@ int init_db(struct repository *repo,
|
|||
if (!(flags & INIT_DB_SKIP_REFDB))
|
||||
create_reference_database(repo, initial_branch, flags & INIT_DB_QUIET);
|
||||
if (!(flags & INIT_DB_SKIP_ODB))
|
||||
create_object_database(repo);
|
||||
create_object_database(repo, NULL);
|
||||
|
||||
startup_info->have_repository = 1;
|
||||
|
||||
|
|
|
|||
2
setup.h
2
setup.h
|
|
@ -277,7 +277,7 @@ void initialize_repository_version(struct repository *repo,
|
|||
enum ref_storage_format ref_storage_format,
|
||||
int reinit);
|
||||
void create_reference_database(struct repository *repo, const char *initial_branch, int quiet);
|
||||
void create_object_database(struct repository *repo);
|
||||
void create_object_database(struct repository *repo, const struct strvec *alternates);
|
||||
|
||||
/*
|
||||
* NOTE NOTE NOTE!!
|
||||
|
|
|
|||
Loading…
Reference in New Issue