X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin%2Fconfig.c;h=0315ad76f881aab9a64084f8d2fdd2019907e4cb;hb=9b55aa03daebf43067021b7d58abea249229987b;hp=0b4ecac855dce9b70878de4d15f4d317254d9ef3;hpb=3197bd850b193a0d182674ab9705cf4acdc313e3;p=git.git diff --git a/builtin/config.c b/builtin/config.c index 0b4ecac85..0315ad76f 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -99,6 +99,7 @@ static int show_config(const char *key_, const char *value_, void *cb) const char *vptr = value; int must_free_vptr = 0; int dup_error = 0; + int must_print_delim = 0; if (!use_key_regexp && strcmp(key_, key)) return 0; @@ -109,10 +110,8 @@ static int show_config(const char *key_, const char *value_, void *cb) return 0; if (show_keys) { - if (value_) - printf("%s%c", key_, key_delim); - else - printf("%s", key_); + printf("%s", key_); + must_print_delim = 1; } if (seen && !do_all) dup_error = 1; @@ -130,16 +129,23 @@ static int show_config(const char *key_, const char *value_, void *cb) } else if (types == TYPE_PATH) { git_config_pathname(&vptr, key_, value_); must_free_vptr = 1; + } else if (value_) { + vptr = value_; + } else { + /* Just show the key name */ + vptr = ""; + must_print_delim = 0; } - else - vptr = value_?value_:""; seen++; if (dup_error) { error("More than one value for the key %s: %s", key_, vptr); } - else + else { + if (must_print_delim) + printf("%c", key_delim); printf("%s%c", vptr, 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