* [PATCH 1/2] Add `init-db.templatedir` configuration variable.
@ 2010-01-13 4:19 Steven Drake
2010-01-13 8:50 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Steven Drake @ 2010-01-13 4:19 UTC (permalink / raw)
To: git
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] Add `init-db.templatedir` configuration variable.
2010-01-13 4:19 [PATCH 1/2] Add `init-db.templatedir` configuration variable Steven Drake
@ 2010-01-13 8:50 ` Junio C Hamano
2010-01-18 3:54 ` Steven Drake
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2010-01-13 8:50 UTC (permalink / raw)
To: Steven Drake; +Cc: git
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] Add `init-db.templatedir` configuration variable.
2010-01-13 8:50 ` Junio C Hamano
@ 2010-01-18 3:54 ` Steven Drake
0 siblings, 0 replies; 3+ messages in thread
From: Steven Drake @ 2010-01-18 3:54 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-01-18 4:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-13 4:19 [PATCH 1/2] Add `init-db.templatedir` configuration variable Steven Drake
2010-01-13 8:50 ` Junio C Hamano
2010-01-18 3:54 ` Steven Drake
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).