author | Junio C Hamano <gitster@pobox.com> | |
Wed, 1 Jun 2011 21:05:22 +0000 (14:05 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 1 Jun 2011 21:05:22 +0000 (14:05 -0700) |
* 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
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
1 | 2 | |||
---|---|---|---|---|
cache.h | patch | | diff1 | | diff2 | | blob | history |
config.c | patch | | diff1 | | diff2 | | blob | history |
git.c | patch | | diff1 | | diff2 | | blob | history |
t/t1300-repo-config.sh | patch | | diff1 | | diff2 | | blob | history |
diff --cc cache.h
Simple merge
diff --cc config.c
index d06fb19d511c29e92aa840c664618ca4a6f73fe6,8220c0cbf70bccf67659220908ba7046e13d50fe..61de4d6a178ec8c2886331daefead68e762362db
+++ b/config.c
return !git_env_bool("GIT_CONFIG_NOSYSTEM", 0);
}
- int git_config_from_parameters(config_fn_t fn, void *data)
-int git_config_global(void)
--{
- static int loaded_environment;
- const struct config_item *ct;
-
- if (!loaded_environment) {
- if (git_config_parse_environment() < 0)
- return -1;
- loaded_environment = 1;
- }
- for (ct = config_parameters; ct; ct = ct->next)
- if (fn(ct->name, ct->value, data) < 0)
- return -1;
- return 0;
- return !git_env_bool("GIT_CONFIG_NOGLOBAL", 0);
--}
--
int git_config_early(config_fn_t fn, void *data, const char *repo_config)
{
int ret = 0, found = 0;
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 git.c
Simple merge
diff --cc t/t1300-repo-config.sh
index 53fb8228cf18e2b58f3ea63e98a0220fa0fd39f2,de2a014d8fade18d8e8f666c502e584a57473d28..3db56267ee89e1b585a548f7bee13386e47395f4
+++ b/t/t1300-repo-config.sh
"
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