Skip to content

Commit 4666741

Browse files
Martin Ågrengitster
authored andcommitted
config: make git_{config,parse}_maybe_bool equivalent
Both of these act on a string `value` which they parse as a boolean. The "parse"-variant was introduced as a replacement for the "config"-variant which for historical reasons takes an unused argument `name`. That it was intended as a replacement is not obvious from commit 9a549d4 ("config.c: rename git_config_maybe_bool_text and export it as git_parse_maybe_bool", 2015-08-19), but that is what the background on the mailing list suggests [1]. However, these two functions do not parse `value` in exactly the same way. In particular, git_config_maybe_bool accepts integers (0 for false, non-0 for true). This means there are two slightly different definitions of "maybe_bool" in the code-base, and that every time a call to git_config_maybe_bool is changed to use git_parse_maybe_bool, it risks breaking someone's workflow. Move the implementation of "config" into "parse" and make the latter a trivial wrapper. This also fixes the only user of git_parse_maybe_bool, `git push --signed=..`. [1] https://public-inbox.org/git/xmqq7fotd71o.fsf@gitster.dls.corp.google.com/ Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 9be04d6 commit 4666741

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

config.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -727,11 +727,6 @@ static int git_parse_maybe_bool_text(const char *value)
727727
}
728728

729729
int git_parse_maybe_bool(const char *value)
730-
{
731-
return git_parse_maybe_bool_text(value);
732-
}
733-
734-
int git_config_maybe_bool(const char *name, const char *value)
735730
{
736731
int v = git_parse_maybe_bool_text(value);
737732
if (0 <= v)
@@ -741,6 +736,11 @@ int git_config_maybe_bool(const char *name, const char *value)
741736
return -1;
742737
}
743738

739+
int git_config_maybe_bool(const char *name, const char *value)
740+
{
741+
return git_parse_maybe_bool(value);
742+
}
743+
744744
int git_config_bool_or_int(const char *name, const char *value, int *is_bool)
745745
{
746746
int v = git_parse_maybe_bool_text(value);

t/t5534-push-signed.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ test_expect_success 'push --signed fails with a receiver without push certificat
7171
test_i18ngrep "the receiving end does not support" err
7272
'
7373

74-
test_expect_failure 'push --signed=1 is accepted' '
74+
test_expect_success 'push --signed=1 is accepted' '
7575
prepare_dst &&
7676
mkdir -p dst/.git/hooks &&
7777
test_must_fail git push --signed=1 dst noop ff +noff 2>err &&

0 commit comments

Comments
 (0)