threads / patch / 22831

patchHaving keywords without value is not a global error.

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

## tl;dr

7 messages between Feb 26, 2010 and Feb 26, 2010. Diffs are folded; open one to read it.

replies: 6people: 3as markdown or json

Steven Drake· Feb 26, 2010, 04:00 UTC · lore

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(-)
Show changes to builtin/init-db.c +0 −2
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· Feb 26, 2010, 04:00 UTC · re: Steven Drake · lore

[PATCH] t/t0001-init.sh: add test for 'init with init.templatedir set'

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(-)
Show changes to 2 files +21 −1

t/t0001-init.sh, wrap-for-bin.sh

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· Feb 26, 2010, 05:14 UTC · re: Steven Drake · lore

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

Steven Drake <sdrake@xnet.co.nz> writes:
Show 25 quoted lines
> 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· Feb 26, 2010, 05:44 UTC · re: Junio C Hamano · lore

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

On Thu, 25 Feb 2010, Junio C Hamano wrote:
Show 30 quoted lines
> 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· Feb 26, 2010, 05:57 UTC · re: Steven Drake · lore

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

Steven Drake <sdrake@xnet.co.nz> writes:
Show 7 quoted lines
>> >  	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· Feb 26, 2010, 08:19 UTC · re: Steven Drake · lore

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

On Fri, Feb 26, 2010 at 05:00, Steven Drake <sdrake@xnet.co.nz> wrote:
Show 7 quoted lines
> 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· Feb 26, 2010, 08:35 UTC · re: Alex Riesen · lore

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

On Fri, 26 Feb 2010, Alex Riesen wrote:
Show 10 quoted lines
> 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

← back to recent threads