{"thread":{"id":"22684","subject":"[PATCH 1/2] Add `init.templatedir` configuration variable.","startedAt":"2010-02-16T23:42:31Z","lastAt":"2010-02-17T18:59:32Z","messageCount":3,"participants":["Steven Drake","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"134811","messageId":"alpine.LNX.2.00.1002171242150.2477@vqena.qenxr.bet.am","threadId":"22684","inReplyTo":null,"subject":"[PATCH 1/2] Add `init.templatedir` configuration variable.","fromName":"Steven Drake","fromEmail":"sdrake@xnet.co.nz","sentAt":"2010-02-16T23:42:31Z","receivedAt":"2010-02-16T23:42:31Z","isPatch":true,"sender":{"key":"sdrake@xnet.co.nz","avatar":null},"body":"Rather than having to pass --template to git init and clone for a custom\nsetup, `init.templatedir` may be set in '~/.gitconfig'\n(Eg.  git config --global --add init.templatedir ~/.gittemplate )\n\nSystem administrators may prefer using this varialbe in the system-wide\nconfig file rather than editing files under '/usr/share'.\n(I.e. setting init.templatedir to $(prefix)/etc/gittempalte )\n\nThe environment variable GIT_TEMPLATE_DIR can already be used for this but\nthe '.gitconfig' file is a much better place for this type of setting.\n\nSigned-off-by: Steven Drake <sdrake@xnet.co.nz>\n---\n builtin-init-db.c |   14 ++++++++++++++\n 1 files changed, 14 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-init-db.c b/builtin-init-db.c\nindex dd84cae..a54f489 100644\n--- a/builtin-init-db.c\n+++ b/builtin-init-db.c\n@@ -20,6 +20,7 @@\n \n static int init_is_bare_repository = 0;\n static int init_shared_repository = -1;\n+static const char *init_db_template_dir;\n \n static void safe_create_dir(const char *dir, int share)\n {\n@@ -121,6 +122,8 @@ static void copy_templates(const char *template_dir)\n \tif (!template_dir)\n \t\ttemplate_dir = getenv(TEMPLATE_DIR_ENVIRONMENT);\n \tif (!template_dir)\n+\t\ttemplate_dir = init_db_template_dir;\n+\tif (!template_dir)\n \t\ttemplate_dir = system_path(DEFAULT_GIT_TEMPLATE_DIR);\n \tif (!template_dir[0])\n \t\treturn;\n@@ -165,6 +168,14 @@ static void copy_templates(const char *template_dir)\n \tclosedir(dir);\n }\n \n+static int git_init_db_config(const char *k, const char *v, void *cb)\n+{\n+\tif (!strcmp(k, \"init.templatedir\"))\n+\t\treturn git_config_pathname(&init_db_template_dir, k, v);\n+\n+\treturn 0;\n+}\n+\n static int create_default_files(const char *template_path)\n {\n \tconst char *git_dir = get_git_dir();\n@@ -190,6 +201,9 @@ static int create_default_files(const char *template_path)\n \tsafe_create_dir(git_path(\"refs/heads\"), 1);\n \tsafe_create_dir(git_path(\"refs/tags\"), 1);\n \n+\t/* Just look for `init.templatedir` */\n+\tgit_config(git_init_db_config, NULL);\n+\n \t/* First copy the templates -- we might have the default\n \t * config file there, in which case we would want to read\n \t * from it after installing.\n-- \n1.6.6.208.gcaa4e.dirty\n"},{"id":"134813","messageId":"alpine.LNX.2.00.1002171244160.2477@vqena.qenxr.bet.am","threadId":"22684","inReplyTo":"alpine.LNX.2.00.1002171242150.2477@vqena.qenxr.bet.am","subject":"[PATCH 2/2] Add a \"TEMPLATE DIRECTORY\" section to git-init[1].","fromName":"Steven Drake","fromEmail":"sdrake@xnet.co.nz","sentAt":"2010-02-16T23:44:46Z","receivedAt":"2010-02-16T23:44:46Z","isPatch":true,"sender":{"key":"sdrake@xnet.co.nz","avatar":null},"body":"The new section is supposed to be more informative, with references to it\nin config.txt and with the '--template' option of git-init and git-clone.\n\nSigned-off-by: Steven Drake <sdrake@xnet.co.nz>\n---\n Documentation/config.txt    |    4 ++++\n Documentation/git-clone.txt |    3 +--\n Documentation/git-init.txt  |   29 +++++++++++++++++++++--------\n 3 files changed, 26 insertions(+), 10 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 8acb613..da176e4 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1181,6 +1181,10 @@ imap::\n \tThe configuration variables in the 'imap' section are described\n \tin linkgit:git-imap-send[1].\n \n+init.templatedir::\n+\tSpecify the directory from which templates will be copied.\n+\t(See the \"TEMPLATE DIRECTORY\" section of linkgit:git-init[1].)\n+\n instaweb.browser::\n \tSpecify the program that will be used to browse your working\n \trepository in gitweb. See linkgit:git-instaweb[1].\ndiff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt\nindex 7ccd742..731b57e 100644\n--- a/Documentation/git-clone.txt\n+++ b/Documentation/git-clone.txt\n@@ -143,8 +143,7 @@ objects from the source repository into a pack in the cloned repository.\n \n --template=<template_directory>::\n \tSpecify the directory from which templates will be used;\n-\tif unset the templates are taken from the installation\n-\tdefined default, typically `/usr/share/git-core/templates`.\n+\t(See the \"TEMPLATE DIRECTORY\" section of linkgit:git-init[1].)\n \n --depth <depth>::\n \tCreate a 'shallow' clone with a history truncated to the\ndiff --git a/Documentation/git-init.txt b/Documentation/git-init.txt\nindex f081b24..dcab667 100644\n--- a/Documentation/git-init.txt\n+++ b/Documentation/git-init.txt\n@@ -28,14 +28,8 @@ current working directory.\n \n --template=<template_directory>::\n \n-Provide the directory from which templates will be used.  The default template\n-directory is `/usr/share/git-core/templates`.\n-\n-When specified, `<template_directory>` is used as the source of the template\n-files rather than the default.  The template files include some directory\n-structure, some suggested \"exclude patterns\", and copies of non-executing\n-\"hook\" files.  The suggested patterns and hook files are all modifiable and\n-extensible.\n+Specify the directory from which templates will be used.  (See the \"TEMPLATE\n+DIRECTORY\" section below.)\n \n --shared[={false|true|umask|group|all|world|everybody|0xxx}]::\n \n@@ -106,6 +100,25 @@ of the repository, such as installing the default hooks and\n setting the configuration variables.  The old name is retained\n for backward compatibility reasons.\n \n+TEMPLATE DIRECTORY\n+------------------\n+\n+The template directory contains files and directories that will be copied to\n+the `$GIT_DIR` after it is created.\n+\n+The template directory used will (in order):\n+\n+ - The argument given with the `--template` option.\n+\n+ - The contents of the `$GIT_TEMPLATE_DIR` environment variable.\n+\n+ - The `init.templatedir` configuration variable.\n+\n+ - The default template directory: `/usr/share/git-core/templates`.\n+\n+The default template directory includes some directory structure, some\n+suggested \"exclude patterns\", and copies of non-executing \"hook\" files.\n+The suggested patterns and hook files are all modifiable and extensible.\n \n EXAMPLES\n --------\n-- \n1.6.6.208.gcaa4e.dirty\n"},{"id":"134875","messageId":"7v1vgjsn6z.fsf@alter.siamese.dyndns.org","threadId":"22684","inReplyTo":"alpine.LNX.2.00.1002171242150.2477@vqena.qenxr.bet.am","subject":"Re: [PATCH 1/2] Add `init.templatedir` configuration variable.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-02-17T18:59:32Z","receivedAt":"2010-02-17T18:59:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks; I will make a minor touch-ups to both of these patches and queue.\nYou may want to add a few tests to t/t0001-init.sh before they get merged\nto 'next' branch and start cooking.\n"}]}