Skip to content

Commit 5a0c9ee

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3ddf096 commit 5a0c9ee

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

config.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ int git_config_from_parameters(config_fn_t fn, void *data)
832832
for (ct = config_parameters; ct; ct = ct->next)
833833
if (fn(ct->name, ct->value, data) < 0)
834834
return -1;
835-
return 0;
835+
return config_parameters != NULL;
836836
}
837837

838838
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)
864864
found += 1;
865865
}
866866

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+
}
870877

871878
if (found == 0)
872879
return -1;

0 commit comments

Comments
 (0)