mirror of
https://github.com/git/git.git
synced 2026-01-09 01:34:00 +00:00
odb: introduce odb_source_new()
We have three different locations where we create a new ODB source. Deduplicate the logic via a new `odb_source_new()` function. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
f82e430b4e
commit
0820a4b120
14
repository.c
14
repository.c
@@ -160,20 +160,24 @@ void repo_set_gitdir(struct repository *repo,
|
||||
* until after xstrdup(root). Then we can free it.
|
||||
*/
|
||||
char *old_gitdir = repo->gitdir;
|
||||
char *objects_path = NULL;
|
||||
|
||||
repo->gitdir = xstrdup(gitfile ? gitfile : root);
|
||||
free(old_gitdir);
|
||||
|
||||
repo_set_commondir(repo, o->commondir);
|
||||
expand_base_dir(&objects_path, o->object_dir,
|
||||
repo->commondir, "objects");
|
||||
|
||||
if (!repo->objects->sources) {
|
||||
CALLOC_ARRAY(repo->objects->sources, 1);
|
||||
repo->objects->sources->odb = repo->objects;
|
||||
repo->objects->sources->local = true;
|
||||
repo->objects->sources = odb_source_new(repo->objects,
|
||||
objects_path, true);
|
||||
repo->objects->sources_tail = &repo->objects->sources->next;
|
||||
free(objects_path);
|
||||
} else {
|
||||
free(repo->objects->sources->path);
|
||||
repo->objects->sources->path = objects_path;
|
||||
}
|
||||
expand_base_dir(&repo->objects->sources->path, o->object_dir,
|
||||
repo->commondir, "objects");
|
||||
|
||||
repo->objects->sources->disable_ref_updates = o->disable_ref_updates;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user