Skip to content

Commit 56cd033

Browse files
pks-tgitster
authored andcommitted
setup: allow skipping creation of the refdb
Allow callers to skip creation of the reference database via a new flag `INIT_DB_SKIP_REFDB`, which is required for git-clone(1) so that we can create it at a later point once the object format has been discovered from the remote repository. Note that we also uplift the call to `create_reference_database()` into `init_db()`, which makes it easier to handle the new flag for us. This changes the order in which we do initialization so that we now set up the Git configuration before we create the reference database. In practice this move should not result in any change in behaviour. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 79543e7 commit 56cd033

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

setup.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,11 +1949,9 @@ static void create_reference_database(const char *initial_branch, int quiet)
19491949

19501950
static int create_default_files(const char *template_path,
19511951
const char *original_git_dir,
1952-
const char *initial_branch,
19531952
const struct repository_format *fmt,
19541953
int prev_bare_repository,
1955-
int init_shared_repository,
1956-
int quiet)
1954+
int init_shared_repository)
19571955
{
19581956
struct stat st1;
19591957
struct strbuf buf = STRBUF_INIT;
@@ -2024,7 +2022,6 @@ static int create_default_files(const char *template_path,
20242022
adjust_shared_perm(get_git_dir());
20252023
}
20262024

2027-
create_reference_database(initial_branch, quiet);
20282025
initialize_repository_version(fmt->hash_algo, 0);
20292026

20302027
/* Check filemode trustability */
@@ -2184,11 +2181,11 @@ int init_db(const char *git_dir, const char *real_git_dir,
21842181
validate_hash_algorithm(&repo_fmt, hash);
21852182

21862183
reinit = create_default_files(template_dir, original_git_dir,
2187-
initial_branch, &repo_fmt,
2188-
prev_bare_repository,
2189-
init_shared_repository,
2190-
flags & INIT_DB_QUIET);
2184+
&repo_fmt, prev_bare_repository,
2185+
init_shared_repository);
21912186

2187+
if (!(flags & INIT_DB_SKIP_REFDB))
2188+
create_reference_database(initial_branch, flags & INIT_DB_QUIET);
21922189
create_object_directory();
21932190

21942191
if (get_shared_repository()) {

setup.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,9 @@ int verify_repository_format(const struct repository_format *format,
169169
*/
170170
void check_repository_format(struct repository_format *fmt);
171171

172-
#define INIT_DB_QUIET 0x0001
173-
#define INIT_DB_EXIST_OK 0x0002
172+
#define INIT_DB_QUIET (1 << 0)
173+
#define INIT_DB_EXIST_OK (1 << 1)
174+
#define INIT_DB_SKIP_REFDB (1 << 2)
174175

175176
int init_db(const char *git_dir, const char *real_git_dir,
176177
const char *template_dir, int hash_algo,

0 commit comments

Comments
 (0)