Code

Merge branch 'maint'
[git.git] / builtin-init-db.c
index d8bdf928b1e97864722352955a2e2e37b5c00806..5ba213a595fb9d7de4d36ff5cab888bde2035722 100644 (file)
@@ -115,18 +115,8 @@ static void copy_templates(const char *template_dir)
 
        if (!template_dir)
                template_dir = getenv(TEMPLATE_DIR_ENVIRONMENT);
-       if (!template_dir) {
-               /*
-                * if the hard-coded template is relative, it is
-                * interpreted relative to the exec_dir
-                */
-               template_dir = DEFAULT_GIT_TEMPLATE_DIR;
-               if (!is_absolute_path(template_dir)) {
-                       struct strbuf d = STRBUF_INIT;
-                       strbuf_addf(&d, "%s/%s", git_exec_path(), template_dir);
-                       template_dir = strbuf_detach(&d, NULL);
-               }
-       }
+       if (!template_dir)
+               template_dir = system_path(DEFAULT_GIT_TEMPLATE_DIR);
        strcpy(template_path, template_dir);
        template_len = strlen(template_path);
        if (template_path[template_len-1] != '/') {
@@ -364,7 +354,7 @@ static int guess_repository_type(const char *git_dir)
 }
 
 static const char init_db_usage[] =
-"git-init [-q | --quiet] [--template=<template-directory>] [--shared]";
+"git-init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]]";
 
 /*
  * If you want to, you can share the DB area with any number of branches.
@@ -383,7 +373,12 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
                const char *arg = argv[1];
                if (!prefixcmp(arg, "--template="))
                        template_dir = arg+11;
-               else if (!strcmp(arg, "--shared"))
+               else if (!strcmp(arg, "--bare")) {
+                       static char git_dir[PATH_MAX+1];
+                       is_bare_repository_cfg = 1;
+                       setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir,
+                                               sizeof(git_dir)), 0);
+               } else if (!strcmp(arg, "--shared"))
                        shared_repository = PERM_GROUP;
                else if (!prefixcmp(arg, "--shared="))
                        shared_repository = git_config_perm("arg", arg+9);