summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e923eae)
raw | patch | inline | side by side (parent: e923eae)
author | Steven Drake <sdrake@xnet.co.nz> | |
Tue, 16 Feb 2010 23:42:31 +0000 (12:42 +1300) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 17 Feb 2010 20:17:35 +0000 (12:17 -0800) |
Rather than having to pass --template to git init and clone for a custom
setup, `init.templatedir` may be set in '~/.gitconfig'. The environment
variable GIT_TEMPLATE_DIR can already be used for this but this is nicer.
System administrators may prefer using this variable in the system-wide
config file to point at a locally modified copy (e.g. /etc/gittemplate)
rather than editing vanilla template files in '/usr/share'.
Signed-off-by: Steven Drake <sdrake@xnet.co.nz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
setup, `init.templatedir` may be set in '~/.gitconfig'. The environment
variable GIT_TEMPLATE_DIR can already be used for this but this is nicer.
System administrators may prefer using this variable in the system-wide
config file to point at a locally modified copy (e.g. /etc/gittemplate)
rather than editing vanilla template files in '/usr/share'.
Signed-off-by: Steven Drake <sdrake@xnet.co.nz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-init-db.c | patch | blob | history |
diff --git a/builtin-init-db.c b/builtin-init-db.c
index dd84caecbc2a07bca90c8524157d50a8fd5ae316..0eb9efc9396bb5edb9f306700372b83ac2105140 100644 (file)
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
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)
{
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])
closedir(dir);
}
+static int git_init_db_config(const char *k, const char *v, void *cb)
+{
+ if (!v)
+ return config_error_nonbool(k);
+ 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();
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.