# [PATCH 1/2] Add `init-db.templatedir` configuration variable.

3 messages from 2010-01-13 to 2010-01-18. Participants: Steven Drake, Junio C Hamano.
Thread: https://gitlist.dev/t/22192

## Steven Drake, 2010-01-13 04:19

Subject: [PATCH 1/2] Add `init-db.templatedir` configuration variable.
Message-ID: <alpine.LNX.2.00.1001131719050.22639@vqena.qenxr.bet.am>
URL: https://gitlist.dev/e/alpine.LNX.2.00.1001131719050.22639%40vqena.qenxr.bet.am

```
Include `init.templatedir` as an alias for `init-db.templatedir`.

Signed-off-by: Steven Drake <sdrake@xnet.co.nz>
---
 builtin-init-db.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/builtin-init-db.c b/builtin-init-db.c
index dd84cae..d56b3a4 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,15 @@ static void copy_templates(const char *template_dir)
 	closedir(dir);
 }
 
+static int git_init_db_config(const char *k, const char *v, void *cb)
+{
+	/* we will accept "init-db.templatedir" or "init.templatedir" */
+	if (!strcmp(k, "init-db.templatedir") || !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 +202,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-db.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.
-- 
1.6.4

```

## Junio C Hamano, 2010-01-13 08:50

Subject: Re: [PATCH 1/2] Add `init-db.templatedir` configuration variable.
Message-ID: <7vljg2pewo.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vljg2pewo.fsf%40alter.siamese.dyndns.org
In-Reply-To: <alpine.LNX.2.00.1001131719050.22639@vqena.qenxr.bet.am>

```
Steven Drake <sdrake@xnet.co.nz> writes:

> Include `init.templatedir` as an alias for `init-db.templatedir`.

This describes what the patch adds, which we can read in the diff *if* we
wanted to.  The primary job of the first paragraph of the proposed commit
log message is to convince reviewers why it might be worthwhile to read
the diff, and to explain whoever reads "git log" output in the future what
motivated this change to be made.

Your log message doesn't say anything about why it is a good idea to add
this feature, which is much more important to talk about [*1*].

The target _may_ be probably to have this in $HOME/.gitconfig so that your
personal templates in $HOME/.gittemplate/ are used in all repositories you
will create.  But you shouldn't make me, anybody who reviews, or readers
of the documentation for that matter, *guess* what problem the new feature
is meant to solve.

IOW, code talks what it itself does, but it often cannot say why it does
what it does, nor why a particular way it does what it does was chosen.
You help your code justify itself by describing the motivation in your
commit log message.

I don't think init-db.templatedir is needed nor wanted.

 - People who learn about this configuration will never heard of init-db
  (i.e. lack of necessity);

 - We have already deprecated init-db and do not advertise in "git help
   git"---the longer term direction is to remove it once everybody forgets
   about it (i.e. actively undesirable).

By the way, this is probably less useful in /etc/gitconfig, as somebody
who can configure it can customize the system-wide templates with the same
ease.  That might also be something you would want to mention in the log.

[Footnote]

*1* I am not saying the commit log message shouldn't talk about what it
does or how it does it.  It also is a good thing to do, especially when
the linkage between the motivation and the implementation is not obvious.

```

## Steven Drake, 2010-01-18 03:54

Subject: Re: [PATCH 1/2] Add `init-db.templatedir` configuration variable.
Message-ID: <alpine.LNX.2.00.1001181627220.2911@vqena.qenxr.bet.am>
URL: https://gitlist.dev/e/alpine.LNX.2.00.1001181627220.2911%40vqena.qenxr.bet.am
In-Reply-To: <7vljg2pewo.fsf@alter.siamese.dyndns.org>

```
On Wed, 13 Jan 2010, Junio C Hamano wrote:

> Steven Drake <sdrake@xnet.co.nz> writes:
> 
> > Include `init.templatedir` as an alias for `init-db.templatedir`.
> 
> This describes what the patch adds, which we can read in the diff *if* we
> wanted to.  The primary job of the first paragraph of the proposed commit
> log message is to convince reviewers why it might be worthwhile to read
> the diff, and to explain whoever reads "git log" output in the future what
> motivated this change to be made.
> 
> Your log message doesn't say anything about why it is a good idea to add
> this feature, which is much more important to talk about [*1*].
> 
> The target _may_ be probably to have this in $HOME/.gitconfig so that your
> personal templates in $HOME/.gittemplate/ are used in all repositories you
> will create.  But you shouldn't make me, anybody who reviews, or readers
> of the documentation for that matter, *guess* what problem the new feature
> is meant to solve.
> 
> IOW, code talks what it itself does, but it often cannot say why it does
> what it does, nor why a particular way it does what it does was chosen.
> You help your code justify itself by describing the motivation in your
> commit log message.

Thanks for the advise if you cann't tell I'm used to writing spares message
both in log messages and email, so this is a great help as to what to
write.  I'll resubmit some improved patches with better log messages.

On that subject do you prefer resubmits as replies to the originals or new
email? 

Do you accept email that use inbodyr-headers and/or scissors?


-- 
Steven
"won't be big"
	-- Linus Torvalds, 25 Aug 1991 - in his first post about linux.

```
