From: Junio C Hamano <gitster@pobox.com>
To: Frank Lichtenheld <frank@lichtenheld.de>
Cc: Johannes Sixt <J.Sixt@eudaptics.com>, git@vger.kernel.org
Subject: Re: [PATCH] config: add support for --bool and --int while setting values
Date: Tue, 26 Jun 2007 19:13:32 -0700 [thread overview]
Message-ID: <7vbqf2ta9f.fsf@assigned-by-dhcp.pobox.com> (raw)
In-Reply-To: <20070625161401.GW19725@planck.djpig.de> (Frank Lichtenheld's message of "Mon, 25 Jun 2007 18:14:01 +0200")
Frank Lichtenheld <frank@lichtenheld.de> writes:
> On Mon, Jun 25, 2007 at 04:06:34PM +0200, Johannes Sixt wrote:
>> Frank Lichtenheld wrote:
>> >
>> > Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de>
>>
>> Please excuse if I'm missing the big picture, but why do we need this
>> change?
>
> - Of course the user or script calling git-config can do the
> normalization and error checking, if they want to. But I would
> prefer to have it available in git-config.
> - I would prefer that these options wouldn't be silently ignored,
> because that can be confusing (at least it is documented now, but
> still). So we should either using them or error out. I prefer the former.
>
> Something that I forgot to mention in the previous mail:
> One real problem with the patch is that it expands the k,m,g suffixes
> for integer values. It probably shouldn't do that.
How about doing something like this, then?
git_config_int() knows that a missing value is a nonsense and
barfs on such an input, so (value ? value : "") is redundant
here. Besides, you check value == NULL much earlier in this
function.
diff --git a/builtin-config.c b/builtin-config.c
index 9973f94..33b60ec 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -148,10 +148,11 @@ char* normalize_value(const char* key, const char* value)
if (type == T_RAW)
normalized = xstrdup(value);
else {
- normalized = xmalloc(64);
- if (type == T_INT)
- sprintf(normalized, "%d",
- git_config_int(key, value?value:""));
+ normalized = xmalloc(64 + strlen(value));
+ if (type == T_INT) {
+ int v = git_config_int(key, value);
+ sprintf(normalized, "%d # %s", v, value);
+ }
else if (type == T_BOOL)
sprintf(normalized, "%s",
git_config_bool(key, value) ? "true" : "false");
next prev parent reply other threads:[~2007-06-27 2:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-25 14:00 [PATCH] config: add support for --bool and --int while setting values Frank Lichtenheld
2007-06-25 14:06 ` Johannes Sixt
2007-06-25 16:14 ` Frank Lichtenheld
2007-06-27 2:13 ` Junio C Hamano [this message]
2007-06-27 2:18 ` Junio C Hamano
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=7vbqf2ta9f.fsf@assigned-by-dhcp.pobox.com \
--to=gitster@pobox.com \
--cc=J.Sixt@eudaptics.com \
--cc=frank@lichtenheld.de \
--cc=git@vger.kernel.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).