]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/init-db.c
setup: limit get_git_work_tree()'s to explicit setup case only
[thirdparty/git.git] / builtin / init-db.c
index 0271285fad6ad532a6133838f7188498476fd77b..ea064784dbe0dc06527f8836e286059069ca1050 100644 (file)
@@ -294,11 +294,26 @@ static int create_default_files(const char *template_path)
        return reinit;
 }
 
+static void create_object_directory(void)
+{
+       const char *object_directory = get_object_directory();
+       int len = strlen(object_directory);
+       char *path = xmalloc(len + 40);
+
+       memcpy(path, object_directory, len);
+
+       safe_create_dir(object_directory, 1);
+       strcpy(path+len, "/pack");
+       safe_create_dir(path, 1);
+       strcpy(path+len, "/info");
+       safe_create_dir(path, 1);
+
+       free(path);
+}
+
 int init_db(const char *template_dir, unsigned int flags)
 {
-       const char *sha1_dir;
-       char *path;
-       int len, reinit;
+       int reinit;
 
        safe_create_dir(get_git_dir(), 0);
 
@@ -313,16 +328,7 @@ int init_db(const char *template_dir, unsigned int flags)
 
        reinit = create_default_files(template_dir);
 
-       sha1_dir = get_object_directory();
-       len = strlen(sha1_dir);
-       path = xmalloc(len + 40);
-       memcpy(path, sha1_dir, len);
-
-       safe_create_dir(sha1_dir, 1);
-       strcpy(path+len, "/pack");
-       safe_create_dir(path, 1);
-       strcpy(path+len, "/info");
-       safe_create_dir(path, 1);
+       create_object_directory();
 
        if (shared_repository) {
                char buf[10];
@@ -490,6 +496,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
        if (is_bare_repository_cfg < 0)
                is_bare_repository_cfg = guess_repository_type(git_dir);
 
+       startup_info->setup_explicit = 1;
        if (!is_bare_repository_cfg) {
                if (git_dir) {
                        const char *git_dir_parent = strrchr(git_dir, '/');