X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-init-db.c;h=d30c3fe2ca542b061ab8b7a7696cdd5416e17147;hb=1689c5de8730ea334535337a341db3c7a21ad002;hp=5ba213a595fb9d7de4d36ff5cab888bde2035722;hpb=c158cae110c917372efe9ff2f080ea0357b05879;p=git.git diff --git a/builtin-init-db.c b/builtin-init-db.c index 5ba213a59..d30c3fe2c 100644 --- a/builtin-init-db.c +++ b/builtin-init-db.c @@ -17,6 +17,9 @@ #define TEST_FILEMODE 1 #endif +static int init_is_bare_repository = 0; +static int init_shared_repository = -1; + static void safe_create_dir(const char *dir, int share) { if (mkdir(dir, 0777) < 0) { @@ -37,7 +40,7 @@ static void copy_templates_1(char *path, int baselen, /* Note: if ".git/hooks" file exists in the repository being * re-initialized, /etc/core-git/templates/hooks/update would - * cause git-init to fail here. I think this is sane but + * cause "git init" to fail here. I think this is sane but * it means that the set of templates we ship by default, along * with the way the namespace under .git/ is organized, should * be really carefully chosen. @@ -117,6 +120,8 @@ static void copy_templates(const char *template_dir) template_dir = getenv(TEMPLATE_DIR_ENVIRONMENT); if (!template_dir) template_dir = system_path(DEFAULT_GIT_TEMPLATE_DIR); + if (!template_dir[0]) + return; strcpy(template_path, template_dir); template_len = strlen(template_path); if (template_path[template_len-1] != '/') { @@ -189,6 +194,9 @@ static int create_default_files(const char *template_path) copy_templates(template_path); git_config(git_default_config, NULL); + is_bare_repository_cfg = init_is_bare_repository; + if (init_shared_repository != -1) + shared_repository = init_shared_repository; /* * We would have created the above under user's umask -- under @@ -275,6 +283,8 @@ int init_db(const char *template_dir, unsigned int flags) safe_create_dir(get_git_dir(), 0); + init_is_bare_repository = is_bare_repository(); + /* Check to see if the repository version is right. * Note that a newly created repository does not have * config file, so this will not fail. What we are catching @@ -354,7 +364,7 @@ static int guess_repository_type(const char *git_dir) } static const char init_db_usage[] = -"git-init [-q | --quiet] [--bare] [--template=] [--shared[=]]"; +"git init [-q | --quiet] [--bare] [--template=] [--shared[=]]"; /* * If you want to, you can share the DB area with any number of branches. @@ -379,9 +389,9 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, sizeof(git_dir)), 0); } else if (!strcmp(arg, "--shared")) - shared_repository = PERM_GROUP; + init_shared_repository = PERM_GROUP; else if (!prefixcmp(arg, "--shared=")) - shared_repository = git_config_perm("arg", arg+9); + init_shared_repository = git_config_perm("arg", arg+9); else if (!strcmp(arg, "-q") || !strcmp(arg, "--quiet")) flags |= INIT_DB_QUIET; else