git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Sixt <j.sixt@viscovery.net>
To: Christian Couder <chriscool@tuxfamily.org>
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: Mon, 04 Feb 2008 18:01:55 +0100	[thread overview]
Message-ID: <47A74503.4090201@viscovery.net> (raw)
In-Reply-To: <200802040727.44522.chriscool@tuxfamily.org>

Christian Couder schrieb:
> Le jeudi 31 janvier 2008, Pierre Habouzit a écrit :
>> On Thu, Jan 31, 2008 at 09:25:32AM +0000, Junio C Hamano wrote:
>>> Pierre Habouzit <madcoder@debian.org> writes:
>>>>   One of my co-workers stumbled upon a misfeature of the git config
>>>> parser. The following syntax is allowed:
>>>>
>>>>     [section]
>>>> 	 foo
>>> Yeah, that is how "truth" value of boolean is spelled.
>>>
>>>> [user]
>>>>     name
>>> That's very unfortunate.  Whatever is expecting string value
>>> should check for NULL.  Fix should probably be easy enough for
>>> any git-hacker-wannabe to tackle ;-)
>>   I think so too, though my count is something like 40 functions to
>> investigate (the 40 handlers) and where it recurses into ;) Too much
>> work for the time I have right now.
> 
> I would suggest this patch:
> 
> ---8<---
> diff --git a/config.c b/config.c
> index 526a3f4..92613c5 100644
> --- a/config.c
> +++ b/config.c
> @@ -139,7 +139,7 @@ static int get_value(config_fn_t fn, char *name, 
> unsigned in
>                 if (!value)
>                         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. :-(

-- Hannes

  reply	other threads:[~2008-02-04 17:03 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 [this message]
2008-02-04 23:13         ` Christian Couder
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=47A74503.4090201@viscovery.net \
    --to=j.sixt@viscovery.net \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --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).