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>

Martin Ågren committed Aug 7, 2017 at 20:20 UTC 8957661378b073b49875059d6426614facb0d7f0
10 files changed +17 -13
Documentation/technical/api-config.txt
+4
@@ -187,6 +187,10 @@ Same as `git_config_bool`, except that integers are returned as-is, and
187 an `is_bool` flag is unset.
188
189 `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`::
194 Same as `git_config_bool`, except that it returns -1 on error rather
195 than dying.
196
builtin/log.c
+2 -2
@@ -54,7 +54,7 @@ struct line_opt_callback_data {
54
55 static int parse_decoration_style(const char *var, const char *value)
56 {
57 - switch (git_config_maybe_bool(var, value)) {
57 + switch (git_parse_maybe_bool(value)) {
58 case 1:
59 return DECORATE_SHORT_REFS;
60 case 0:
@@ -809,7 +809,7 @@ static int git_format_config(const char *var, const char *value, void *cb)
809 return 0;
810 }
811 if (!strcmp(var, "format.from")) {
812 - int b = git_config_maybe_bool(var, value);
812 + int b = git_parse_maybe_bool(value);
813 free(from);
814 if (b < 0)
815 from = xstrdup(value);
builtin/merge.c
+2 -2
@@ -566,7 +566,7 @@ static int git_merge_config(const char *k, const char *v, void *cb)
566 else if (!strcmp(k, "merge.renormalize"))
567 option_renormalize = git_config_bool(k, v);
568 else if (!strcmp(k, "merge.ff")) {
569 - int boolval = git_config_maybe_bool(k, v);
569 + int boolval = git_parse_maybe_bool(v);
570 if (0 <= boolval) {
571 fast_forward = boolval ? FF_ALLOW : FF_NO;
572 } else if (v && !strcmp(v, "only")) {
@@ -959,7 +959,7 @@ static int default_edit_option(void)
959 return 0;
960
961 if (e) {
962 - int v = git_config_maybe_bool(name, e);
962 + int v = git_parse_maybe_bool(e);
963 if (v < 0)
964 die(_("Bad value '%s' in environment '%s'"), e, name);
965 return v;
builtin/pull.c
+2 -2
@@ -36,7 +36,7 @@ enum rebase_type {
36 static enum rebase_type parse_config_rebase(const char *key, const char *value,
37 int fatal)
38 {
39 - int v = git_config_maybe_bool("pull.rebase", value);
39 + int v = git_parse_maybe_bool(value);
40
41 if (!v)
42 return REBASE_FALSE;
@@ -271,7 +271,7 @@ static const char *config_get_ff(void)
271 if (git_config_get_value("pull.ff", &value))
272 return NULL;
273
274 - switch (git_config_maybe_bool("pull.ff", value)) {
274 + switch (git_parse_maybe_bool(value)) {
275 case 0:
276 return "--no-ff";
277 case 1:
builtin/push.c
+1 -1
@@ -480,7 +480,7 @@ static int git_push_config(const char *k, const char *v, void *cb)
480 } else if (!strcmp(k, "push.gpgsign")) {
481 const char *value;
482 if (!git_config_get_value("push.gpgsign", &value)) {
483 - switch (git_config_maybe_bool("push.gpgsign", value)) {
483 + switch (git_parse_maybe_bool(value)) {
484 case 0:
485 set_push_cert_flags(flags, SEND_PACK_PUSH_CERT_NEVER);
486 break;
builtin/remote.c
+1 -1
@@ -300,7 +300,7 @@ static int config_read_branches(const char *key, const char *value, void *cb)
300 }
301 string_list_append(&info->merge, xstrdup(value));
302 } else {
303 - int v = git_config_maybe_bool(orig_key, value);
303 + int v = git_parse_maybe_bool(value);
304 if (v >= 0)
305 info->rebase = v;
306 else if (!strcmp(value, "preserve"))
builtin/send-pack.c
+1 -1
@@ -104,7 +104,7 @@ static int send_pack_config(const char *k, const char *v, void *cb)
104 if (!strcmp(k, "push.gpgsign")) {
105 const char *value;
106 if (!git_config_get_value("push.gpgsign", &value)) {
107 - switch (git_config_maybe_bool("push.gpgsign", value)) {
107 + switch (git_parse_maybe_bool(value)) {
108 case 0:
109 args.push_cert = SEND_PACK_PUSH_CERT_NEVER;
110 break;
config.c
+1 -1
@@ -1617,7 +1617,7 @@ int git_configset_get_maybe_bool(struct config_set *cs, const char *key, int *de
1617 {
1618 const char *value;
1619 if (!git_configset_get_value(cs, key, &value)) {
1620 - *dest = git_config_maybe_bool(key, value);
1620 + *dest = git_parse_maybe_bool(value);
1621 if (*dest == -1)
1622 return -1;
1623 return 0;
pager.c
+1 -1
@@ -226,7 +226,7 @@ static int pager_command_config(const char *var, const char *value, void *vdata)
226 const char *cmd;
227
228 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);
230 if (b >= 0)
231 data->want = b;
232 else {
submodule-config.c
+2 -2
@@ -213,7 +213,7 @@ static struct submodule *lookup_or_create_by_name(struct submodule_cache *cache,
213 static int parse_fetch_recurse(const char *opt, const char *arg,
214 int die_on_error)
215 {
216 - switch (git_config_maybe_bool(opt, arg)) {
216 + switch (git_parse_maybe_bool(arg)) {
217 case 1:
218 return RECURSE_SUBMODULES_ON;
219 case 0:
@@ -237,7 +237,7 @@ int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg)
237 static int parse_push_recurse(const char *opt, const char *arg,
238 int die_on_error)
239 {
240 - switch (git_config_maybe_bool(opt, arg)) {
240 + switch (git_parse_maybe_bool(arg)) {
241 case 1:
242 /* There's no simple "on" value when pushing */
243 if (die_on_error)