@matheusbsbs / matheus-bagliano / commits / b69ba460bb
Fork 0

config: Change output of --get-regexp for valueless keys

Print no space after the name of a key without value. Otherwise keys without values are printed exactly the same as keys with empty values. Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Frank Lichtenheld committed Jun 25, 2007 at 16:03 UTC b69ba460bb0710b2af8a20b4b0d62233f29401ec
2 files changed +12 -2
builtin-config.c
+6 -2
@@ -38,8 +38,12 @@ static int show_config(const char* key_, const char* value_)
38 regexec(regexp, (value_?value_:""), 0, NULL, 0)))
39 return 0;
40
41 - if (show_keys)
42 - printf("%s ", key_);
41 + if (show_keys) {
42 + if (value_)
43 + printf("%s ", key_);
44 + else
45 + printf("%s", key_);
46 + }
47 if (seen && !do_all)
48 dup_error = 1;
49 if (type == T_INT)
t/t1300-repo-config.sh
+6
@@ -283,6 +283,12 @@ EOF
283 test_expect_success 'get variable with no value' \
284 'git-config --get novalue.variable ^$'
285
286 +echo novalue.variable > expect
287 +
288 +test_expect_success 'get-regexp variable with no value' \
289 + 'git-config --get-regexp novalue > output &&
290 + cmp output expect'
291 +
292 git-config > output 2>&1
293
294 test_expect_success 'no arguments, but no crash' \