# [PATCH] Having keywords without value is not a global error.

7 messages from 2010-02-26 to 2010-02-26. Participants: Steven Drake, Junio C Hamano, Alex Riesen.
Thread: https://gitlist.dev/t/22831

## Steven Drake, 2010-02-26 04:00

Subject: [PATCH] Having keywords without value is not a global error.
Message-ID: <c28821e9079f35e7267a1e7381ccf7793c12bf24.1267156694.git.sdrake@xnet.co.nz>
URL: https://gitlist.dev/e/c28821e9079f35e7267a1e7381ccf7793c12bf24.1267156694.git.sdrake%40xnet.co.nz

```
It is not a good Idea to give a config_error for _any_ keyword without a
value as it means that

	[section]
		keyword

sytle can not be using for setting bool type keyword.

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

diff --git a/builtin/init-db.c b/builtin/init-db.c
index 9273942..edc40ff 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -170,8 +170,6 @@ static void copy_templates(const char *template_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);
 
-- 
1.6.6

```

## Steven Drake, 2010-02-26 04:00

Subject: [PATCH] t/t0001-init.sh: add test for 'init with init.templatedir set'
Message-ID: <7bce5804fd71ac19c9164c9c2deb9dd714dc7aee.1267156694.git.sdrake@xnet.co.nz>
URL: https://gitlist.dev/e/7bce5804fd71ac19c9164c9c2deb9dd714dc7aee.1267156694.git.sdrake%40xnet.co.nz
In-Reply-To: <c28821e9079f35e7267a1e7381ccf7793c12bf24.1267156694.git.sdrake@xnet.co.nz>

```
Requires a small change to wrap-for-bin.sh in order to work.

Signed-off-by: Steven Drake <sdrake@xnet.co.nz>
---
 t/t0001-init.sh |   19 +++++++++++++++++++
 wrap-for-bin.sh |    3 ++-
 2 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 5386504..6757734 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -167,6 +167,25 @@ test_expect_success 'init with --template (blank)' '
 	! test -f template-blank/.git/info/exclude
 '
 
+test_expect_success 'init with init.templatedir set' '
+	mkdir templatedir-source &&
+	echo Content >templatedir-source/file &&
+	(
+		HOME="`pwd`" &&
+		export HOME &&
+		test_config="${HOME}/.gitconfig" &&
+		git config -f "$test_config"  init.templatedir "${HOME}/templatedir-source" &&
+		mkdir templatedir-set &&
+		cd templatedir-set &&
+		unset GIT_CONFIG_NOGLOBAL &&
+		unset GIT_TEMPLATE_DIR &&
+		NO_SET_GIT_TEMPLATE_DIR=t &&
+		export NO_SET_GIT_TEMPLATE_DIR &&
+		git init
+	) &&
+	test_cmp templatedir-source/file templatedir-set/.git/file
+'
+
 test_expect_success 'init --bare/--shared overrides system/global config' '
 	(
 		HOME="`pwd`" &&
diff --git a/wrap-for-bin.sh b/wrap-for-bin.sh
index c5075c9..aece782 100644
--- a/wrap-for-bin.sh
+++ b/wrap-for-bin.sh
@@ -7,7 +7,8 @@
 # @@BUILD_DIR@@ and @@PROG@@.
 
 GIT_EXEC_PATH='@@BUILD_DIR@@'
-GIT_TEMPLATE_DIR='@@BUILD_DIR@@/templates/blt'
+test -z "$NO_SET_GIT_TEMPLATE_DIR" &&
+	GIT_TEMPLATE_DIR='@@BUILD_DIR@@/templates/blt'
 GITPERLLIB='@@BUILD_DIR@@/perl/blib/lib'
 PATH='@@BUILD_DIR@@/bin-wrappers:'"$PATH"
 export GIT_EXEC_PATH GIT_TEMPLATE_DIR GITPERLLIB PATH
-- 
1.6.6

```

## Junio C Hamano, 2010-02-26 05:14

Subject: Re: [PATCH] Having keywords without value is not a global error.
Message-ID: <7vk4u0efxy.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vk4u0efxy.fsf%40alter.siamese.dyndns.org
In-Reply-To: <c28821e9079f35e7267a1e7381ccf7793c12bf24.1267156694.git.sdrake@xnet.co.nz>

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

> It is not a good Idea to give a config_error for _any_ keyword without a
> value as it means that
>
> 	[section]
> 		keyword
>
> sytle can not be using for setting bool type keyword.
>
> Signed-off-by: Steven Drake <sdrake@xnet.co.nz>
> ---
>  builtin/init-db.c |    2 --
>  1 files changed, 0 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/init-db.c b/builtin/init-db.c
> index 9273942..edc40ff 100644
> --- a/builtin/init-db.c
> +++ b/builtin/init-db.c
> @@ -170,8 +170,6 @@ static void copy_templates(const char *template_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);

But then don't you need to catch init.templatedir does have a string
value?

>  
> -- 
> 1.6.6

```

## Steven Drake, 2010-02-26 05:44

Subject: Re: [PATCH] Having keywords without value is not a global error.
Message-ID: <alpine.LNX.2.00.1002261838360.8597@vqena.qenxr.bet.am>
URL: https://gitlist.dev/e/alpine.LNX.2.00.1002261838360.8597%40vqena.qenxr.bet.am
In-Reply-To: <7vk4u0efxy.fsf@alter.siamese.dyndns.org>

```
On Thu, 25 Feb 2010, Junio C Hamano wrote:
> Steven Drake <sdrake@xnet.co.nz> writes:
> 
> > It is not a good Idea to give a config_error for _any_ keyword without a
> > value as it means that
> >
> > 	[section]
> > 		keyword
> >
> > sytle can not be using for setting bool type keyword.
> >
> > Signed-off-by: Steven Drake <sdrake@xnet.co.nz>
> > ---
> >  builtin/init-db.c |    2 --
> >  1 files changed, 0 insertions(+), 2 deletions(-)
> >
> > diff --git a/builtin/init-db.c b/builtin/init-db.c
> > index 9273942..edc40ff 100644
> > --- a/builtin/init-db.c
> > +++ b/builtin/init-db.c
> > @@ -170,8 +170,6 @@ static void copy_templates(const char *template_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);
> 
> But then don't you need to catch init.templatedir does have a string
> value?

Yes, but the change dose not touch that test, it removes two lines that I
can't remember why a put there.

-- 
Steven

```

## Junio C Hamano, 2010-02-26 05:57

Subject: Re: [PATCH] Having keywords without value is not a global error.
Message-ID: <7vljegczes.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vljegczes.fsf%40alter.siamese.dyndns.org
In-Reply-To: <alpine.LNX.2.00.1002261838360.8597@vqena.qenxr.bet.am>

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

>> >  	if (!strcmp(k, "init.templatedir"))
>> >  		return git_config_pathname(&init_db_template_dir, k, v);
>> 
>> But then don't you need to catch init.templatedir does have a string
>> value?
>
> Yes, but the change dose not touch that test,...

Ahh, config_pathname() does its own check for NULLness, Ok, I forgot.

Thanks.

```

## Alex Riesen, 2010-02-26 08:19

Subject: Re: [PATCH] Having keywords without value is not a global error.
Message-ID: <81b0412b1002260019r3d5268f2x4b48051409e0c8f5@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b1002260019r3d5268f2x4b48051409e0c8f5%40mail.gmail.com
In-Reply-To: <c28821e9079f35e7267a1e7381ccf7793c12bf24.1267156694.git.sdrake@xnet.co.nz>

```
On Fri, Feb 26, 2010 at 05:00, Steven Drake <sdrake@xnet.co.nz> wrote:
> It is not a good Idea to give a config_error for _any_ keyword without a
> value as it means that
>
>        [section]
>                keyword
>
> sytle can not be using for setting bool type keyword.

Typo: sytle (style?)

```

## Steven Drake, 2010-02-26 08:35

Subject: Re: [PATCH] Having keywords without value is not a global error.
Message-ID: <alpine.LNX.2.00.1002262135150.8908@vqena.qenxr.bet.am>
URL: https://gitlist.dev/e/alpine.LNX.2.00.1002262135150.8908%40vqena.qenxr.bet.am
In-Reply-To: <81b0412b1002260019r3d5268f2x4b48051409e0c8f5@mail.gmail.com>

```
On Fri, 26 Feb 2010, Alex Riesen wrote:

> On Fri, Feb 26, 2010 at 05:00, Steven Drake <sdrake@xnet.co.nz> wrote:
> > It is not a good Idea to give a config_error for _any_ keyword without a
> > value as it means that
> >
> >        [section]
> >                keyword
> >
> > sytle can not be using for setting bool type keyword.
> 
> Typo: sytle (style?)

Yes!!! 

-- 
Steven
```
