From: alex@chmrr.net
To: git@vger.kernel.org
Subject: [PATCH] config: Print the delimeter of intuited --bool values under --get-regexp
Date: Thu, 26 Aug 2010 16:49:35 -0400 [thread overview]
Message-ID: <1282855775-22582-1-git-send-email-alex@chmrr.net> (raw)
In-Reply-To: <1282844716-30591-1-git-send-email-alex@chmrr.net>
From: Alex Vandiver <alex@chmrr.net>
Keys with no explicit value set may still have values that need to be
printed, if used in conjunction with --bool, for example. Defer
printing the key-value delimeter until we know what value, if any, we
intend to output.
Signed-off-by: Alex Vandiver <alex@chmrr.net>
---
I found a couple tuits under the couch; perhaps something like the
following would be correct.
builtin/config.c | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/builtin/config.c b/builtin/config.c
index ca4a0db..98fd1ba 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -108,12 +108,9 @@ static int show_config(const char *key_, const char *value_, void *cb)
(do_not_match ^ !!regexec(regexp, (value_?value_:""), 0, NULL, 0)))
return 0;
- if (show_keys) {
- if (value_)
- printf("%s%c", key_, key_delim);
- else
- printf("%s", key_);
- }
+ if (show_keys)
+ printf("%s", key_);
+
if (seen && !do_all)
dup_error = 1;
if (types == TYPE_INT)
@@ -132,14 +129,21 @@ static int show_config(const char *key_, const char *value_, void *cb)
must_free_vptr = 1;
}
else
- vptr = value_?value_:"";
+ vptr = value_;
+
+ if (show_keys && vptr)
+ printf("%c", key_delim);
+
seen++;
if (dup_error) {
error("More than one value for the key %s: %s",
key_, vptr);
}
- else
+ else if (vptr)
printf("%s%c", vptr, term);
+ else
+ printf("%c", term);
+
if (must_free_vptr)
/* If vptr must be freed, it's a pointer to a
* dynamically allocated buffer, it's safe to cast to
--
1.7.2.2.458.g8d9c8
next prev parent reply other threads:[~2010-08-26 20:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-26 17:45 [PATCH] Test the interaction of --bool and --get-regexp on a key with no explicit value Alex Vandiver
2010-08-26 20:49 ` alex [this message]
2010-08-27 3:17 ` [PATCH] config: Print the delimeter of intuited --bool values under --get-regexp Jonathan Nieder
2010-08-27 3:15 ` [PATCH] Test the interaction of --bool and --get-regexp on a key with no explicit value Jonathan Nieder
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=1282855775-22582-1-git-send-email-alex@chmrr.net \
--to=alex@chmrr.net \
--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).