Skip to content

Commit bdfcdef

Browse files
committed
Merge branch 'ma/parse-maybe-bool'
Code clean-up. * ma/parse-maybe-bool: parse_decoration_style: drop unused argument `var` treewide: deprecate git_config_maybe_bool, use git_parse_maybe_bool config: make git_{config,parse}_maybe_bool equivalent config: introduce git_parse_maybe_bool_text t5334: document that git push --signed=1 does not work Doc/git-{push,send-pack}: correct --sign= to --signed=
2 parents 6cb3822 + f094b89 commit bdfcdef

File tree

13 files changed

+41
-25
lines changed

13 files changed

+41
-25
lines changed

Documentation/git-push.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ SYNOPSIS
1212
'git push' [--all | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>]
1313
[--repo=<repository>] [-f | --force] [-d | --delete] [--prune] [-v | --verbose]
1414
[-u | --set-upstream] [--push-option=<string>]
15-
[--[no-]signed|--sign=(true|false|if-asked)]
15+
[--[no-]signed|--signed=(true|false|if-asked)]
1616
[--force-with-lease[=<refname>[:<expect>]]]
1717
[--no-verify] [<repository> [<refspec>...]]
1818

@@ -141,7 +141,7 @@ already exists on the remote side.
141141
information, see `push.followTags` in linkgit:git-config[1].
142142

143143
--[no-]signed::
144-
--sign=(true|false|if-asked)::
144+
--signed=(true|false|if-asked)::
145145
GPG-sign the push request to update refs on the receiving
146146
side, to allow it to be checked by the hooks and/or be
147147
logged. If `false` or `--no-signed`, no signing will be

Documentation/git-send-pack.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ SYNOPSIS
1111
[verse]
1212
'git send-pack' [--all] [--dry-run] [--force] [--receive-pack=<git-receive-pack>]
1313
[--verbose] [--thin] [--atomic]
14-
[--[no-]signed|--sign=(true|false|if-asked)]
14+
[--[no-]signed|--signed=(true|false|if-asked)]
1515
[<host>:]<directory> [<ref>...]
1616

1717
DESCRIPTION
@@ -71,7 +71,7 @@ be in a separate packet, and the list must end with a flush packet.
7171
refs.
7272

7373
--[no-]signed::
74-
--sign=(true|false|if-asked)::
74+
--signed=(true|false|if-asked)::
7575
GPG-sign the push request to update refs on the receiving
7676
side, to allow it to be checked by the hooks and/or be
7777
logged. If `false` or `--no-signed`, no signing will be

Documentation/technical/api-config.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ Same as `git_config_bool`, except that integers are returned as-is, and
187187
an `is_bool` flag is unset.
188188

189189
`git_config_maybe_bool`::
190+
Deprecated. Use `git_parse_maybe_bool` instead. They are exactly the
191+
same, except this function takes an unused argument `name`.
192+
193+
`git_parse_maybe_bool`::
190194
Same as `git_config_bool`, except that it returns -1 on error rather
191195
than dying.
192196

builtin/log.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ static int auto_decoration_style(void)
5858
return (isatty(1) || pager_in_use()) ? DECORATE_SHORT_REFS : 0;
5959
}
6060

61-
static int parse_decoration_style(const char *var, const char *value)
61+
static int parse_decoration_style(const char *value)
6262
{
63-
switch (git_config_maybe_bool(var, value)) {
63+
switch (git_parse_maybe_bool(value)) {
6464
case 1:
6565
return DECORATE_SHORT_REFS;
6666
case 0:
@@ -82,7 +82,7 @@ static int decorate_callback(const struct option *opt, const char *arg, int unse
8282
if (unset)
8383
decoration_style = 0;
8484
else if (arg)
85-
decoration_style = parse_decoration_style("command line", arg);
85+
decoration_style = parse_decoration_style(arg);
8686
else
8787
decoration_style = DECORATE_SHORT_REFS;
8888

@@ -412,7 +412,7 @@ static int git_log_config(const char *var, const char *value, void *cb)
412412
if (!strcmp(var, "log.date"))
413413
return git_config_string(&default_date_mode, var, value);
414414
if (!strcmp(var, "log.decorate")) {
415-
decoration_style = parse_decoration_style(var, value);
415+
decoration_style = parse_decoration_style(value);
416416
if (decoration_style < 0)
417417
decoration_style = 0; /* maybe warn? */
418418
return 0;
@@ -824,7 +824,7 @@ static int git_format_config(const char *var, const char *value, void *cb)
824824
return 0;
825825
}
826826
if (!strcmp(var, "format.from")) {
827-
int b = git_config_maybe_bool(var, value);
827+
int b = git_parse_maybe_bool(value);
828828
free(from);
829829
if (b < 0)
830830
from = xstrdup(value);

builtin/merge.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ static int git_merge_config(const char *k, const char *v, void *cb)
566566
else if (!strcmp(k, "merge.renormalize"))
567567
option_renormalize = git_config_bool(k, v);
568568
else if (!strcmp(k, "merge.ff")) {
569-
int boolval = git_config_maybe_bool(k, v);
569+
int boolval = git_parse_maybe_bool(v);
570570
if (0 <= boolval) {
571571
fast_forward = boolval ? FF_ALLOW : FF_NO;
572572
} else if (v && !strcmp(v, "only")) {
@@ -940,7 +940,7 @@ static int default_edit_option(void)
940940
return 0;
941941

942942
if (e) {
943-
int v = git_config_maybe_bool(name, e);
943+
int v = git_parse_maybe_bool(e);
944944
if (v < 0)
945945
die(_("Bad value '%s' in environment '%s'"), e, name);
946946
return v;

builtin/pull.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ enum rebase_type {
3939
static enum rebase_type parse_config_rebase(const char *key, const char *value,
4040
int fatal)
4141
{
42-
int v = git_config_maybe_bool("pull.rebase", value);
42+
int v = git_parse_maybe_bool(value);
4343

4444
if (!v)
4545
return REBASE_FALSE;
@@ -274,7 +274,7 @@ static const char *config_get_ff(void)
274274
if (git_config_get_value("pull.ff", &value))
275275
return NULL;
276276

277-
switch (git_config_maybe_bool("pull.ff", value)) {
277+
switch (git_parse_maybe_bool(value)) {
278278
case 0:
279279
return "--no-ff";
280280
case 1:

builtin/push.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ static int git_push_config(const char *k, const char *v, void *cb)
481481
} else if (!strcmp(k, "push.gpgsign")) {
482482
const char *value;
483483
if (!git_config_get_value("push.gpgsign", &value)) {
484-
switch (git_config_maybe_bool("push.gpgsign", value)) {
484+
switch (git_parse_maybe_bool(value)) {
485485
case 0:
486486
set_push_cert_flags(flags, SEND_PACK_PUSH_CERT_NEVER);
487487
break;

builtin/remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ static int config_read_branches(const char *key, const char *value, void *cb)
301301
}
302302
string_list_append(&info->merge, xstrdup(value));
303303
} else {
304-
int v = git_config_maybe_bool(orig_key, value);
304+
int v = git_parse_maybe_bool(value);
305305
if (v >= 0)
306306
info->rebase = v;
307307
else if (!strcmp(value, "preserve"))

builtin/send-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static int send_pack_config(const char *k, const char *v, void *cb)
105105
if (!strcmp(k, "push.gpgsign")) {
106106
const char *value;
107107
if (!git_config_get_value("push.gpgsign", &value)) {
108-
switch (git_config_maybe_bool("push.gpgsign", value)) {
108+
switch (git_parse_maybe_bool(value)) {
109109
case 0:
110110
args.push_cert = SEND_PACK_PUSH_CERT_NEVER;
111111
break;

config.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ ssize_t git_config_ssize_t(const char *name, const char *value)
929929
return ret;
930930
}
931931

932-
int git_parse_maybe_bool(const char *value)
932+
static int git_parse_maybe_bool_text(const char *value)
933933
{
934934
if (!value)
935935
return 1;
@@ -946,19 +946,24 @@ int git_parse_maybe_bool(const char *value)
946946
return -1;
947947
}
948948

949-
int git_config_maybe_bool(const char *name, const char *value)
949+
int git_parse_maybe_bool(const char *value)
950950
{
951-
int v = git_parse_maybe_bool(value);
951+
int v = git_parse_maybe_bool_text(value);
952952
if (0 <= v)
953953
return v;
954954
if (git_parse_int(value, &v))
955955
return !!v;
956956
return -1;
957957
}
958958

959+
int git_config_maybe_bool(const char *name, const char *value)
960+
{
961+
return git_parse_maybe_bool(value);
962+
}
963+
959964
int git_config_bool_or_int(const char *name, const char *value, int *is_bool)
960965
{
961-
int v = git_parse_maybe_bool(value);
966+
int v = git_parse_maybe_bool_text(value);
962967
if (0 <= v) {
963968
*is_bool = 1;
964969
return v;
@@ -1852,7 +1857,7 @@ int git_configset_get_maybe_bool(struct config_set *cs, const char *key, int *de
18521857
{
18531858
const char *value;
18541859
if (!git_configset_get_value(cs, key, &value)) {
1855-
*dest = git_config_maybe_bool(key, value);
1860+
*dest = git_parse_maybe_bool(value);
18561861
if (*dest == -1)
18571862
return -1;
18581863
return 0;

0 commit comments

Comments
 (0)