summaryrefslogtreecommitdiff
path: root/builtin/config.c
diff options
context:
space:
mode:
authorJohn Keeping <john@keeping.me.uk>2016-02-28 11:54:35 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-02-28 20:01:45 (GMT)
commit27b30be686e497e6ab84dc0b25623df7aba1ba2c (patch)
tree048eedeb7dc98fa1ade92fb6d1fee205de64a6ef /builtin/config.c
parent326e5bc91eecf73234ead29636207bc516573e79 (diff)
downloadgit-27b30be686e497e6ab84dc0b25623df7aba1ba2c.zip
git-27b30be686e497e6ab84dc0b25623df7aba1ba2c.tar.gz
git-27b30be686e497e6ab84dc0b25623df7aba1ba2c.tar.bz2
config: fail if --get-urlmatch finds no value
The --get, --get-all and --get-regexp options to git-config exit with status 1 if the key is not found but --get-urlmatch succeeds in this case. Change --get-urlmatch to behave in the same way as the other --get* options so that all four are consistent. --get-color is a special case because it accepts a default value to return and so should not return an error if the key is not found. Also clarify this behaviour in the documentation. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/config.c')
-rw-r--r--builtin/config.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/builtin/config.c b/builtin/config.c
index adc7727..b92abb7 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -389,6 +389,7 @@ static int urlmatch_collect_fn(const char *var, const char *value, void *cb)
static int get_urlmatch(const char *var, const char *url)
{
+ int ret;
char *section_tail;
struct string_list_item *item;
struct urlmatch_config config = { STRING_LIST_INIT_DUP };
@@ -415,6 +416,8 @@ static int get_urlmatch(const char *var, const char *url)
git_config_with_options(urlmatch_config_entry, &config,
&given_config_source, respect_includes);
+ ret = !values.nr;
+
for_each_string_list_item(item, &values) {
struct urlmatch_current_candidate_value *matched = item->util;
struct strbuf buf = STRBUF_INIT;
@@ -431,7 +434,7 @@ static int get_urlmatch(const char *var, const char *url)
free(config.url.url);
free((void *)config.section);
- return 0;
+ return ret;
}
static char *default_user_config(void)