From: Tanay Abhra <tanayabh@gmail.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, Ramkumar Ramachandra <artagnon@gmail.com>,
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Subject: Re: [PATCH/RFC] alias.c: Replace git_config with git_config_get_string
Date: Tue, 17 Jun 2014 11:51:35 -0700 [thread overview]
Message-ID: <53A08E37.1040104@gmail.com> (raw)
In-Reply-To: <20140617054357.GC29957@sigill.intra.peff.net>
On 06/16/2014 10:43 PM, Jeff King wrote:
>
>> + v = git_config_get_string(alias_key);
>> + if (!v)
>> + config_error_nonbool(alias_key);
>
> What does a NULL output from git_config_get_string mean? I think with
> the current code, it means "no such key was found". In which case, you
> should be returning NULL here (there is no such alias), not complaining
> with config_error_nonbool.
>
Yes, you surmised correctly. I totally skipped the fact that git_config() can
return null for values indicating a boolean value. I will correct it in the next
patch.
> Again, this is going to depend on your strategy for storing booleans
> that I mentioned elsewhere.
I have read your other two replies related to it. I suggest the following approach
for git_config_get_string(), it will return,
1. Return null if no value was found for the entered key.
2. Empty string (""), returned for NULL values denoting boolean true in some cases.
I think it would be much better than converting NULL to "true" or something else
internally in the function.
We can easily handle such cases as the above with a strcmp like,
+ v = git_config_get_string(alias_key);
+ if (!strcmp(v, ""))
+ config_error_nonbool(alias_key);
What do you think about this approach?
Thanks for the suggestion, I was pulling my hair out due this bug for last two days.
Cheers,
Tanay Abhra.
next prev parent reply other threads:[~2014-06-17 18:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-16 9:15 [PATCH/RFC] alias.c: Replace git_config with git_config_get_string Tanay Abhra
2014-06-17 5:43 ` Jeff King
2014-06-17 18:51 ` Tanay Abhra [this message]
2014-06-17 21:14 ` Jeff King
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=53A08E37.1040104@gmail.com \
--to=tanayabh@gmail.com \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/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).