Skip to content

Commit 325c017

Browse files
pks-tgitster
authored andcommitted
setup: stop using the_repository in create_reference_database()
Stop using `the_repository` in `create_reference_database()` and instead accept the repository as a parameter. The injection of `the_repository` is thus bumped one level higher, where callers now pass it in explicitly. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 50e71a3 commit 325c017

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

builtin/clone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,7 @@ int cmd_clone(int argc,
14421442
hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));
14431443
initialize_repository_version(the_repository, hash_algo, the_repository->ref_storage_format, 1);
14441444
repo_set_hash_algo(the_repository, hash_algo);
1445-
create_reference_database(NULL, 1);
1445+
create_reference_database(the_repository, NULL, 1);
14461446

14471447
/*
14481448
* Before fetching from the remote, download and install bundle

setup.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2465,13 +2465,14 @@ static int is_reinit(struct repository *repo)
24652465
return ret;
24662466
}
24672467

2468-
void create_reference_database(const char *initial_branch, int quiet)
2468+
void create_reference_database(struct repository *repo,
2469+
const char *initial_branch, int quiet)
24692470
{
24702471
struct strbuf err = STRBUF_INIT;
24712472
char *to_free = NULL;
2472-
int reinit = is_reinit(the_repository);
2473+
int reinit = is_reinit(repo);
24732474

2474-
if (ref_store_create_on_disk(get_main_ref_store(the_repository), 0, &err))
2475+
if (ref_store_create_on_disk(get_main_ref_store(repo), 0, &err))
24752476
die("failed to set up refs db: %s", err.buf);
24762477

24772478
/*
@@ -2483,14 +2484,14 @@ void create_reference_database(const char *initial_branch, int quiet)
24832484

24842485
if (!initial_branch)
24852486
initial_branch = to_free =
2486-
repo_default_branch_name(the_repository, quiet);
2487+
repo_default_branch_name(repo, quiet);
24872488

24882489
ref = xstrfmt("refs/heads/%s", initial_branch);
24892490
if (check_refname_format(ref, 0) < 0)
24902491
die(_("invalid initial branch name: '%s'"),
24912492
initial_branch);
24922493

2493-
if (refs_update_symref(get_main_ref_store(the_repository), "HEAD", ref, NULL) < 0)
2494+
if (refs_update_symref(get_main_ref_store(repo), "HEAD", ref, NULL) < 0)
24942495
exit(1);
24952496
free(ref);
24962497
}
@@ -2827,7 +2828,7 @@ int init_db(const char *git_dir, const char *real_git_dir,
28272828
&repo_fmt, init_shared_repository);
28282829

28292830
if (!(flags & INIT_DB_SKIP_REFDB))
2830-
create_reference_database(initial_branch, flags & INIT_DB_QUIET);
2831+
create_reference_database(the_repository, initial_branch, flags & INIT_DB_QUIET);
28312832
create_object_directory(the_repository);
28322833

28332834
if (repo_settings_get_shared_repository(the_repository)) {

setup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ void initialize_repository_version(struct repository *repo,
236236
int hash_algo,
237237
enum ref_storage_format ref_storage_format,
238238
int reinit);
239-
void create_reference_database(const char *initial_branch, int quiet);
239+
void create_reference_database(struct repository *repo, const char *initial_branch, int quiet);
240240

241241
/*
242242
* NOTE NOTE NOTE!!

0 commit comments

Comments
 (0)