From: Christian Couder <chriscool@tuxfamily.org>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: Pierre Habouzit <madcoder@debian.org>,
Junio C Hamano <gitster@pobox.com>, Git ML <git@vger.kernel.org>
Subject: Re: [bug] generic issue with git_config handlers
Date: Tue, 5 Feb 2008 00:13:20 +0100 [thread overview]
Message-ID: <200802050013.20335.chriscool@tuxfamily.org> (raw)
In-Reply-To: <47A74503.4090201@viscovery.net>
Le lundi 4 février 2008, Johannes Sixt a écrit :
> Christian Couder schrieb:
> > return -1;
> > }
> > - return fn(name, value);
> > + return fn(name, value ? value : "");
> > }
>
> You can't. The reason is that get_config_bool() treats value == NULL and
> *value == '\0' differently. *That's* the most unfortunate part of it. :-(
You are right. We have this (in config.c:299):
int git_config_bool(const char *name, const char *value)
{
if (!value)
return 1;
if (!*value)
return 0;
if (!strcasecmp(value, "true") || !strcasecmp(value, "yes"))
return 1;
if (!strcasecmp(value, "false") || !strcasecmp(value, "no"))
return 0;
return git_config_int(name, value) != 0;
}
Very unfortunate.
I finally had the following patch that passed all tests (it changed only one
test), in case someone wants to suggest that we change git_config_bool,
hint, hint!
Thanks,
Christian.
---8<---
diff --git a/builtin-config.c b/builtin-config.c
index e4a12e3..b92cf4b 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -20,7 +20,7 @@ static enum { T_RAW, T_INT, T_BOOL } type = T_RAW;
static int show_all_config(const char *key_, const char *value_)
{
- if (value_)
+ if (value_ && *value_)
printf("%s%c%s%c", key_, delim, value_, term);
else
printf("%s%c", key_, term);
@@ -42,7 +42,7 @@ static int show_config(const char* key_, const char*
value_)
return 0;
if (show_keys) {
- if (value_)
+ if (value_ && *value_)
printf("%s%c", key_, key_delim);
else
printf("%s", key_);
diff --git a/config.c b/config.c
index 526a3f4..a2c7214 100644
--- a/config.c
+++ b/config.c
@@ -131,7 +131,7 @@ static int get_value(config_fn_t fn, char *name,
unsigned in
while (c == ' ' || c == '\t')
c = get_next_char();
- value = NULL;
+ value = "";
if (c != '\n') {
if (c != '=')
return -1;
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index a786c5c..deb11dc 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -611,8 +611,7 @@ foo
barQsection.sub=section.val3
-Qsection.sub=section.val4
-Qsection.sub=section.val5Q
+Qsection.sub=section.val4Qsection.sub=section.val5Q
EOF
git config --null --list | tr '\000' 'Q' > result
---8<---
next prev parent reply other threads:[~2008-02-04 23:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-31 9:16 [bug] generic issue with git_config handlers Pierre Habouzit
2008-01-31 9:25 ` Junio C Hamano
2008-01-31 10:10 ` Pierre Habouzit
2008-02-04 6:27 ` Christian Couder
2008-02-04 17:01 ` Johannes Sixt
2008-02-04 23:13 ` Christian Couder [this message]
2008-02-05 0:03 ` Junio C Hamano
2008-02-07 5:45 ` Christian Couder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200802050013.20335.chriscool@tuxfamily.org \
--to=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j.sixt@viscovery.net \
--cc=madcoder@debian.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).