{"thread":{"id":"22192","subject":"[PATCH 1/2] Add `init-db.templatedir` configuration variable.","startedAt":"2010-01-13T04:19:36Z","lastAt":"2010-01-18T03:54:09Z","messageCount":3,"participants":["Steven Drake","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"131417","messageId":"alpine.LNX.2.00.1001131719050.22639@vqena.qenxr.bet.am","threadId":"22192","inReplyTo":null,"subject":"[PATCH 1/2] Add `init-db.templatedir` configuration variable.","fromName":"Steven Drake","fromEmail":"sdrake@xnet.co.nz","sentAt":"2010-01-13T04:19:36Z","receivedAt":"2010-01-13T04:19:36Z","isPatch":true,"sender":{"key":"sdrake@xnet.co.nz","avatar":null},"body":"Include `init.templatedir` as an alias for `init-db.templatedir`.\n\nSigned-off-by: Steven Drake <sdrake@xnet.co.nz>\n---\n builtin-init-db.c |   15 +++++++++++++++\n 1 files changed, 15 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-init-db.c b/builtin-init-db.c\nindex dd84cae..d56b3a4 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,15 @@ 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+\t/* we will accept \"init-db.templatedir\" or \"init.templatedir\" */\n+\tif (!strcmp(k, \"init-db.templatedir\") || !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 +202,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-db.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.4\n"},{"id":"131443","messageId":"7vljg2pewo.fsf@alter.siamese.dyndns.org","threadId":"22192","inReplyTo":"alpine.LNX.2.00.1001131719050.22639@vqena.qenxr.bet.am","subject":"Re: [PATCH 1/2] Add `init-db.templatedir` configuration variable.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-01-13T08:50:15Z","receivedAt":"2010-01-13T08:50:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Steven Drake <sdrake@xnet.co.nz> writes:\n\n> Include `init.templatedir` as an alias for `init-db.templatedir`.\n\nThis describes what the patch adds, which we can read in the diff *if* we\nwanted to.  The primary job of the first paragraph of the proposed commit\nlog message is to convince reviewers why it might be worthwhile to read\nthe diff, and to explain whoever reads \"git log\" output in the future what\nmotivated this change to be made.\n\nYour log message doesn't say anything about why it is a good idea to add\nthis feature, which is much more important to talk about [*1*].\n\nThe target _may_ be probably to have this in $HOME/.gitconfig so that your\npersonal templates in $HOME/.gittemplate/ are used in all repositories you\nwill create.  But you shouldn't make me, anybody who reviews, or readers\nof the documentation for that matter, *guess* what problem the new feature\nis meant to solve.\n\nIOW, code talks what it itself does, but it often cannot say why it does\nwhat it does, nor why a particular way it does what it does was chosen.\nYou help your code justify itself by describing the motivation in your\ncommit log message.\n\nI don't think init-db.templatedir is needed nor wanted.\n\n - People who learn about this configuration will never heard of init-db\n  (i.e. lack of necessity);\n\n - We have already deprecated init-db and do not advertise in \"git help\n   git\"---the longer term direction is to remove it once everybody forgets\n   about it (i.e. actively undesirable).\n\nBy the way, this is probably less useful in /etc/gitconfig, as somebody\nwho can configure it can customize the system-wide templates with the same\nease.  That might also be something you would want to mention in the log.\n\n[Footnote]\n\n*1* I am not saying the commit log message shouldn't talk about what it\ndoes or how it does it.  It also is a good thing to do, especially when\nthe linkage between the motivation and the implementation is not obvious.\n"},{"id":"132012","messageId":"alpine.LNX.2.00.1001181627220.2911@vqena.qenxr.bet.am","threadId":"22192","inReplyTo":"7vljg2pewo.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 1/2] Add `init-db.templatedir` configuration variable.","fromName":"Steven Drake","fromEmail":"sdrake@xnet.co.nz","sentAt":"2010-01-18T03:54:09Z","receivedAt":"2010-01-18T03:54:09Z","isPatch":true,"sender":{"key":"sdrake@xnet.co.nz","avatar":null},"body":"On Wed, 13 Jan 2010, Junio C Hamano wrote:\n\n> Steven Drake <sdrake@xnet.co.nz> writes:\n> \n> > Include `init.templatedir` as an alias for `init-db.templatedir`.\n> \n> This describes what the patch adds, which we can read in the diff *if* we\n> wanted to.  The primary job of the first paragraph of the proposed commit\n> log message is to convince reviewers why it might be worthwhile to read\n> the diff, and to explain whoever reads \"git log\" output in the future what\n> motivated this change to be made.\n> \n> Your log message doesn't say anything about why it is a good idea to add\n> this feature, which is much more important to talk about [*1*].\n> \n> The target _may_ be probably to have this in $HOME/.gitconfig so that your\n> personal templates in $HOME/.gittemplate/ are used in all repositories you\n> will create.  But you shouldn't make me, anybody who reviews, or readers\n> of the documentation for that matter, *guess* what problem the new feature\n> is meant to solve.\n> \n> IOW, code talks what it itself does, but it often cannot say why it does\n> what it does, nor why a particular way it does what it does was chosen.\n> You help your code justify itself by describing the motivation in your\n> commit log message.\n\nThanks for the advise if you cann't tell I'm used to writing spares message\nboth in log messages and email, so this is a great help as to what to\nwrite.  I'll resubmit some improved patches with better log messages.\n\nOn that subject do you prefer resubmits as replies to the originals or new\nemail? \n\nDo you accept email that use inbodyr-headers and/or scissors?\n\n\n-- \nSteven\n\"won't be big\"\n\t-- Linus Torvalds, 25 Aug 1991 - in his first post about linux.\n"}]}