From: Junio C Hamano Date: Tue, 31 May 2011 03:19:14 +0000 (-0700) Subject: Merge branch 'jk/maint-config-alias-fix' X-Git-Tag: v1.7.6-rc0~16 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1f9a980636d39c08c1cf1c13a6e6584d9d039e0e;p=git.git Merge branch 'jk/maint-config-alias-fix' * jk/maint-config-alias-fix: handle_options(): do not miscount how many arguments were used config: always parse GIT_CONFIG_PARAMETERS during git_config git_config: don't peek at global config_parameters config: make environment parsing routines static Conflicts: config.c --- 1f9a980636d39c08c1cf1c13a6e6584d9d039e0e diff --cc config.c index 9d3684888,8220c0cbf..a8267e926 --- a/config.c +++ b/config.c @@@ -882,11 -835,20 +859,18 @@@ int git_config_early(config_fn_t fn, vo found += 1; } - ret += git_config_from_parameters(fn, data); - if (config_parameters) - found += 1; + switch (git_config_from_parameters(fn, data)) { + case -1: /* error */ + ret--; + break; + case 0: /* found nothing */ + break; + default: /* found at least one item */ + found++; + break; + } - if (found == 0) - return -1; - return ret; + return ret == 0 ? found : ret; } int git_config(config_fn_t fn, void *data) diff --cc t/t1300-repo-config.sh index 53fb8228c,de2a014d8..3db56267e --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@@ -876,25 -847,18 +876,32 @@@ test_expect_success 'check split_cmdlin " test_expect_success 'git -c "key=value" support' ' - test "z$(git -c name=value config name)" = zvalue && test "z$(git -c core.name=value config core.name)" = zvalue && - test "z$(git -c CamelCase=value config camelcase)" = zvalue && - test "z$(git -c flag config --bool flag)" = ztrue && - test_must_fail git -c core.name=value config name + test "z$(git -c foo.CamelCase=value config foo.camelcase)" = zvalue && + test "z$(git -c foo.flag config --bool foo.flag)" = ztrue && + test_must_fail git -c name=value config core.name +' + +test_expect_success 'key sanity-checking' ' + test_must_fail git config foo=bar && + test_must_fail git config foo=.bar && + test_must_fail git config foo.ba=r && + test_must_fail git config foo.1bar && + test_must_fail git config foo."ba + z".bar && + test_must_fail git config . false && + test_must_fail git config .foo false && + test_must_fail git config foo. false && + test_must_fail git config .foo. false && + git config foo.bar true && + git config foo."ba =z".bar false ' + test_expect_success 'git -c works with aliases of builtins' ' + git config alias.checkconfig "-c foo.check=bar config foo.check" && + echo bar >expect && + git checkconfig >actual && + test_cmp expect actual + ' + test_done