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>
Jeff King committed
May 24, 2011 at 18:49 UTC
5a0c9eeb89a19a05cbc2bf570f69f1724ef873dd
1 file changed
+11
-4
config.c
+11
-4
@@ -832,7 +832,7 @@ int git_config_from_parameters(config_fn_t fn, void *data)
832
for (ct = config_parameters; ct; ct = ct->next)
833
if (fn(ct->name, ct->value, data) < 0)
834
return -1;
835
- return 0;
835
+ return config_parameters != NULL;
836
}
837
838
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)
864
found += 1;
865
}
866
867
- ret += git_config_from_parameters(fn, data);
868
- if (config_parameters)
869
- found += 1;
867
+ switch (git_config_from_parameters(fn, data)) {
868
+ case -1: /* error */
869
+ ret--;
870
+ break;
871
+ case 0: /* found nothing */
872
+ break;
873
+ default: /* found at least one item */
874
+ found++;
875
+ break;
876
+ }
877
878
if (found == 0)
879
return -1;