mirror of
https://github.com/git/git
synced 2024-08-24 18:26:02 +00:00
Merge branch 'jk/config-get-urlmatch'
"git config --get-urlmatch", unlike other variants of the "git config --get" family, did not signal error with its exit status when there was no matching configuration. * jk/config-get-urlmatch: Documentation/git-config: fix --get-all description Documentation/git-config: use bulleted list for exit codes config: fail if --get-urlmatch finds no value
This commit is contained in:
commit
c832cef8aa
|
@ -58,13 +58,13 @@ that location (you can say '--local' but that is the default).
|
|||
This command will fail with non-zero status upon error. Some exit
|
||||
codes are:
|
||||
|
||||
. The config file is invalid (ret=3),
|
||||
. can not write to the config file (ret=4),
|
||||
. no section or name was provided (ret=2),
|
||||
. the section or key is invalid (ret=1),
|
||||
. you try to unset an option which does not exist (ret=5),
|
||||
. you try to unset/set an option for which multiple lines match (ret=5), or
|
||||
. you try to use an invalid regexp (ret=6).
|
||||
- The config file is invalid (ret=3),
|
||||
- can not write to the config file (ret=4),
|
||||
- no section or name was provided (ret=2),
|
||||
- the section or key is invalid (ret=1),
|
||||
- you try to unset an option which does not exist (ret=5),
|
||||
- you try to unset/set an option for which multiple lines match (ret=5), or
|
||||
- you try to use an invalid regexp (ret=6).
|
||||
|
||||
On success, the command returns the exit code 0.
|
||||
|
||||
|
@ -86,8 +86,7 @@ OPTIONS
|
|||
found and the last value if multiple key values were found.
|
||||
|
||||
--get-all::
|
||||
Like get, but does not fail if the number of values for the key
|
||||
is not exactly one.
|
||||
Like get, but returns all values for a multi-valued key.
|
||||
|
||||
--get-regexp::
|
||||
Like --get-all, but interprets the name as a regular expression and
|
||||
|
@ -102,7 +101,7 @@ OPTIONS
|
|||
given URL is returned (if no such key exists, the value for
|
||||
section.key is used as a fallback). When given just the
|
||||
section as name, do so for all the keys in the section and
|
||||
list them.
|
||||
list them. Returns error code 1 if no value is found.
|
||||
|
||||
--global::
|
||||
For writing options: write to global `~/.gitconfig` file
|
||||
|
|
|
@ -417,6 +417,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 };
|
||||
|
@ -443,6 +444,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;
|
||||
|
@ -459,7 +462,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)
|
||||
|
|
|
@ -1144,6 +1144,9 @@ test_expect_success 'urlmatch' '
|
|||
cookieFile = /tmp/cookie.txt
|
||||
EOF
|
||||
|
||||
test_expect_code 1 git config --bool --get-urlmatch doesnt.exist https://good.example.com >actual &&
|
||||
test_must_be_empty actual &&
|
||||
|
||||
echo true >expect &&
|
||||
git config --bool --get-urlmatch http.SSLverify https://good.example.com >actual &&
|
||||
test_cmp expect actual &&
|
||||
|
|
Loading…
Reference in a new issue