[PATCH] config: Print the delimeter of intuited --bool values under --get-regexp

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Alex Vandiver <alex@xxxxxxxxx>

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@xxxxxxxxx>
---

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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]