Skip to content

Commit 8957661

Browse files
Martin Ågrengitster
authored andcommitted
treewide: deprecate git_config_maybe_bool, use git_parse_maybe_bool
The only difference between these is that the former takes an argument `name` which it ignores completely. Still, the callers are quite careful to provide reasonable values for it. Once in-flight topics have landed, we should be able to remove git_config_maybe_bool. In the meantime, document it as deprecated in the technical documentation. While at it, document git_parse_maybe_bool. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 4666741 commit 8957661

10 files changed

Lines changed: 17 additions & 13 deletions

File tree

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct line_opt_callback_data {
5454

5555
static int parse_decoration_style(const char *var, const char *value)
5656
{
57-
switch (git_config_maybe_bool(var, value)) {
57+
switch (git_parse_maybe_bool(value)) {
5858
case 1:
5959
return DECORATE_SHORT_REFS;
6060
case 0:
@@ -809,7 +809,7 @@ static int git_format_config(const char *var, const char *value, void *cb)
809809
return 0;
810810
}
811811
if (!strcmp(var, "format.from")) {
812-
int b = git_config_maybe_bool(var, value);
812+
int b = git_parse_maybe_bool(value);
813813
free(from);
814814
if (b < 0)
815815
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")) {
@@ -959,7 +959,7 @@ static int default_edit_option(void)
959959
return 0;
960960

961961
if (e) {
962-
int v = git_config_maybe_bool(name, e);
962+
int v = git_parse_maybe_bool(e);
963963
if (v < 0)
964964
die(_("Bad value '%s' in environment '%s'"), e, name);
965965
return v;

builtin/pull.c

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

4141
if (!v)
4242
return REBASE_FALSE;
@@ -271,7 +271,7 @@ static const char *config_get_ff(void)
271271
if (git_config_get_value("pull.ff", &value))
272272
return NULL;
273273

274-
switch (git_config_maybe_bool("pull.ff", value)) {
274+
switch (git_parse_maybe_bool(value)) {
275275
case 0:
276276
return "--no-ff";
277277
case 1:

builtin/push.c

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

builtin/remote.c

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

builtin/send-pack.c

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

config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ int git_configset_get_maybe_bool(struct config_set *cs, const char *key, int *de
16171617
{
16181618
const char *value;
16191619
if (!git_configset_get_value(cs, key, &value)) {
1620-
*dest = git_config_maybe_bool(key, value);
1620+
*dest = git_parse_maybe_bool(value);
16211621
if (*dest == -1)
16221622
return -1;
16231623
return 0;

pager.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ static int pager_command_config(const char *var, const char *value, void *vdata)
226226
const char *cmd;
227227

228228
if (skip_prefix(var, "pager.", &cmd) && !strcmp(cmd, data->cmd)) {
229-
int b = git_config_maybe_bool(var, value);
229+
int b = git_parse_maybe_bool(value);
230230
if (b >= 0)
231231
data->want = b;
232232
else {

submodule-config.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ static struct submodule *lookup_or_create_by_name(struct submodule_cache *cache,
213213
static int parse_fetch_recurse(const char *opt, const char *arg,
214214
int die_on_error)
215215
{
216-
switch (git_config_maybe_bool(opt, arg)) {
216+
switch (git_parse_maybe_bool(arg)) {
217217
case 1:
218218
return RECURSE_SUBMODULES_ON;
219219
case 0:
@@ -237,7 +237,7 @@ int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg)
237237
static int parse_push_recurse(const char *opt, const char *arg,
238238
int die_on_error)
239239
{
240-
switch (git_config_maybe_bool(opt, arg)) {
240+
switch (git_parse_maybe_bool(arg)) {
241241
case 1:
242242
/* There's no simple "on" value when pushing */
243243
if (die_on_error)

0 commit comments

Comments
 (0)