summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2011-05-24 22:49:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-05-24 23:20:56 (GMT)
commit5a0c9eeb89a19a05cbc2bf570f69f1724ef873dd (patch)
tree2fec7cb617ed76289978bea5876fecde13060619 /config.c
parent3ddf0968c2f64a9f9fa6880d9c22d40459c88335 (diff)
downloadgit-5a0c9eeb89a19a05cbc2bf570f69f1724ef873dd.zip
git-5a0c9eeb89a19a05cbc2bf570f69f1724ef873dd.tar.gz
git-5a0c9eeb89a19a05cbc2bf570f69f1724ef873dd.tar.bz2
git_config: don't peek at global config_parameters
The config_parameters list in config.c is an implementation detail of git_config_from_parameters; instead, that function should tell us whether it found anything. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/config.c b/config.c
index 230fe2c..065c5b7 100644
--- a/config.c
+++ b/config.c
@@ -832,7 +832,7 @@ int git_config_from_parameters(config_fn_t fn, void *data)
for (ct = config_parameters; ct; ct = ct->next)
if (fn(ct->name, ct->value, data) < 0)
return -1;
- return 0;
+ return config_parameters != NULL;
}
int git_config_early(config_fn_t fn, void *data, const char *repo_config)
@@ -864,9 +864,16 @@ int git_config_early(config_fn_t fn, void *data, const char *repo_config)
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;