From: Junio C Hamano <gitster@pobox.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: Alternative approach to the git config NULL value checking patches..
Date: Sun, 10 Feb 2008 16:40:46 -0800 [thread overview]
Message-ID: <7vhcggcokx.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <alpine.LFD.1.00.0802101538030.2920@woody.linux-foundation.org> (Linus Torvalds's message of "Sun, 10 Feb 2008 15:41:23 -0800 (PST)")
Linus Torvalds <torvalds@linux-foundation.org> writes:
> And here's an example of this kind of effect. I'm not actually suggesting
> you apply this patch, but tell me it isn't simpler done this way?
Yes, that is a good example of simplification.
> So this is where it *does* make a difference whether we use NULL or
> config_bool, and where config_bool is simply better: it allows a config
> routine to simply never care..
But that applies only to "originally bool but now has additional
states" kind of variables.
For a variable that is never about boolean, if the original code
said:
if (!strcmp(var, "section.variable"))
foo = xstrdup(value);
it is wrong (would strdup NULL), and the correct fix would be:
if (!strcmp(var, "section.variable")) {
if (!value)
die("missing value for '%s'", var);
foo = xstrdup(value);
}
It does not make much of a difference if that "if (!value)"
becomes "if (value == config_true)". If you omit that check, as
your "user.name" example shows, foo may get an empty string or a
string "true", neither of which is what the user intended to
say.
next prev parent reply other threads:[~2008-02-11 0:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-10 20:32 Alternative approach to the git config NULL value checking patches Linus Torvalds
2008-02-10 21:25 ` Junio C Hamano
2008-02-10 22:08 ` Linus Torvalds
2008-02-10 22:29 ` Junio C Hamano
2008-02-10 22:47 ` Junio C Hamano
2008-02-10 23:29 ` Pierre Habouzit
2008-02-10 23:50 ` Linus Torvalds
2008-02-10 23:36 ` Linus Torvalds
2008-02-10 23:41 ` Linus Torvalds
2008-02-11 0:40 ` Junio C Hamano [this message]
2008-02-11 7:22 ` Christian Couder
2008-02-11 8:12 ` Junio C Hamano
2008-02-11 17:27 ` Daniel Barkalow
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=7vhcggcokx.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=torvalds@linux-foundation.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).