Skip to content

Commit db6195e

Browse files
peffgitster
authored andcommitted
handle arbitrary ints in git_config_maybe_bool
This function recently gained the ability to recognize the documented "0" and "1" values as false/true. However, unlike regular git_config_bool, it did not treat arbitrary non-zero numbers as true. While this is undocumented and probably ridiculous for somebody to rely on, it is safer to behave exactly as git_config_bool would. Because git_config_maybe_bool can be used to retrofit new non-bool values onto existing bool options, not behaving in exactly the same way is technically a regression. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b2be2f6 commit db6195e

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

config.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -429,13 +429,11 @@ static int git_config_maybe_bool_text(const char *name, const char *value)
429429

430430
int git_config_maybe_bool(const char *name, const char *value)
431431
{
432-
int v = git_config_maybe_bool_text(name, value);
432+
long v = git_config_maybe_bool_text(name, value);
433433
if (0 <= v)
434434
return v;
435-
if (!strcmp(value, "0"))
436-
return 0;
437-
if (!strcmp(value, "1"))
438-
return 1;
435+
if (git_parse_long(value, &v))
436+
return !!v;
439437
return -1;
440438
}
441439

0 commit comments

Comments
 (0)