summaryrefslogtreecommitdiff
path: root/builtin/init-db.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-03-10 23:32:43 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-03-10 23:32:43 (GMT)
commit90a2bf9ca155c8e0e43d9e30197d9562dd02ea96 (patch)
tree5c6b98713a4724ef44054b5fe513d260157e3bd4 /builtin/init-db.c
parentc505a850157961d2db4512d029753946d0591649 (diff)
parent160ad147fe9f644fc35224095e1d1a01be0208de (diff)
downloadgit-90a2bf9ca155c8e0e43d9e30197d9562dd02ea96.zip
git-90a2bf9ca155c8e0e43d9e30197d9562dd02ea96.tar.gz
git-90a2bf9ca155c8e0e43d9e30197d9562dd02ea96.tar.bz2
Merge branch 'sd/init-template'
* sd/init-template: wrap-for-bin: do not export an empty GIT_TEMPLATE_DIR t/t0001-init.sh: add test for 'init with init.templatedir set' init: having keywords without value is not a global error. Add a "TEMPLATE DIRECTORY" section to git-init[1]. Add `init.templatedir` configuration variable.
Diffstat (limited to 'builtin/init-db.c')
-rw-r--r--builtin/init-db.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/builtin/init-db.c b/builtin/init-db.c
index aae7a4d..edc40ff 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -20,6 +20,7 @@
static int init_is_bare_repository = 0;
static int init_shared_repository = -1;
+static const char *init_db_template_dir;
static void safe_create_dir(const char *dir, int share)
{
@@ -121,6 +122,8 @@ static void copy_templates(const char *template_dir)
if (!template_dir)
template_dir = getenv(TEMPLATE_DIR_ENVIRONMENT);
if (!template_dir)
+ template_dir = init_db_template_dir;
+ if (!template_dir)
template_dir = system_path(DEFAULT_GIT_TEMPLATE_DIR);
if (!template_dir[0])
return;
@@ -165,6 +168,14 @@ static void copy_templates(const char *template_dir)
closedir(dir);
}
+static int git_init_db_config(const char *k, const char *v, void *cb)
+{
+ if (!strcmp(k, "init.templatedir"))
+ return git_config_pathname(&init_db_template_dir, k, v);
+
+ return 0;
+}
+
static int create_default_files(const char *template_path)
{
const char *git_dir = get_git_dir();
@@ -190,6 +201,9 @@ static int create_default_files(const char *template_path)
safe_create_dir(git_path("refs/heads"), 1);
safe_create_dir(git_path("refs/tags"), 1);
+ /* Just look for `init.templatedir` */
+ git_config(git_init_db_config, NULL);
+
/* First copy the templates -- we might have the default
* config file there, in which case we would want to read
* from it after installing.