]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git_config: don't peek at global config_parameters
authorJeff King <peff@peff.net>
Tue, 24 May 2011 22:49:45 +0000 (18:49 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 24 May 2011 23:20:56 +0000 (16:20 -0700)
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>
config.c

index 230fe2c0a2f779fd20ba1730349c0fc7bb0d1bef..065c5b7d571a82ba36d3f260d20376c649c5b7a0 100644 (file)
--- 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;