]> git.ipfire.org Git - thirdparty/git.git/commitdiff
setup: allow skipping creation of the refdb
authorPatrick Steinhardt <ps@pks.im>
Tue, 12 Dec 2023 07:00:46 +0000 (08:00 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 12 Dec 2023 19:16:54 +0000 (11:16 -0800)
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 <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
setup.c
setup.h

diff --git a/setup.c b/setup.c
index 865cfe6743e2dd819bec4043645c7cac17c69f69..d6a1c59b7bd915e8779bb28c0bcc3847fee9e830 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -1949,11 +1949,9 @@ static void create_reference_database(const char *initial_branch, int quiet)
 
 static int create_default_files(const char *template_path,
                                const char *original_git_dir,
-                               const char *initial_branch,
                                const struct repository_format *fmt,
                                int prev_bare_repository,
-                               int init_shared_repository,
-                               int quiet)
+                               int init_shared_repository)
 {
        struct stat st1;
        struct strbuf buf = STRBUF_INIT;
@@ -2024,7 +2022,6 @@ static int create_default_files(const char *template_path,
                adjust_shared_perm(get_git_dir());
        }
 
-       create_reference_database(initial_branch, quiet);
        initialize_repository_version(fmt->hash_algo, 0);
 
        /* Check filemode trustability */
@@ -2184,11 +2181,11 @@ int init_db(const char *git_dir, const char *real_git_dir,
        validate_hash_algorithm(&repo_fmt, hash);
 
        reinit = create_default_files(template_dir, original_git_dir,
-                                     initial_branch, &repo_fmt,
-                                     prev_bare_repository,
-                                     init_shared_repository,
-                                     flags & INIT_DB_QUIET);
+                                     &repo_fmt, prev_bare_repository,
+                                     init_shared_repository);
 
+       if (!(flags & INIT_DB_SKIP_REFDB))
+               create_reference_database(initial_branch, flags & INIT_DB_QUIET);
        create_object_directory();
 
        if (get_shared_repository()) {
diff --git a/setup.h b/setup.h
index b48cf1c43b5a559057a2e92d2fe4250c15255344..cbf538286bfefc53d5a99e48f4932b5c53c830b7 100644 (file)
--- a/setup.h
+++ b/setup.h
@@ -169,8 +169,9 @@ int verify_repository_format(const struct repository_format *format,
  */
 void check_repository_format(struct repository_format *fmt);
 
-#define INIT_DB_QUIET 0x0001
-#define INIT_DB_EXIST_OK 0x0002
+#define INIT_DB_QUIET      (1 << 0)
+#define INIT_DB_EXIST_OK   (1 << 1)
+#define INIT_DB_SKIP_REFDB (1 << 2)
 
 int init_db(const char *git_dir, const char *real_git_dir,
            const char *template_dir, int hash_algo,