mirror of
https://github.com/git/git.git
synced 2024-11-27 12:03:55 +08:00
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>
This commit is contained in:
parent
4666741823
commit
8957661378
@ -187,6 +187,10 @@ Same as `git_config_bool`, except that integers are returned as-is, and
|
|||||||
an `is_bool` flag is unset.
|
an `is_bool` flag is unset.
|
||||||
|
|
||||||
`git_config_maybe_bool`::
|
`git_config_maybe_bool`::
|
||||||
|
Deprecated. Use `git_parse_maybe_bool` instead. They are exactly the
|
||||||
|
same, except this function takes an unused argument `name`.
|
||||||
|
|
||||||
|
`git_parse_maybe_bool`::
|
||||||
Same as `git_config_bool`, except that it returns -1 on error rather
|
Same as `git_config_bool`, except that it returns -1 on error rather
|
||||||
than dying.
|
than dying.
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ struct line_opt_callback_data {
|
|||||||
|
|
||||||
static int parse_decoration_style(const char *var, const char *value)
|
static int parse_decoration_style(const char *var, const char *value)
|
||||||
{
|
{
|
||||||
switch (git_config_maybe_bool(var, value)) {
|
switch (git_parse_maybe_bool(value)) {
|
||||||
case 1:
|
case 1:
|
||||||
return DECORATE_SHORT_REFS;
|
return DECORATE_SHORT_REFS;
|
||||||
case 0:
|
case 0:
|
||||||
@ -809,7 +809,7 @@ static int git_format_config(const char *var, const char *value, void *cb)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!strcmp(var, "format.from")) {
|
if (!strcmp(var, "format.from")) {
|
||||||
int b = git_config_maybe_bool(var, value);
|
int b = git_parse_maybe_bool(value);
|
||||||
free(from);
|
free(from);
|
||||||
if (b < 0)
|
if (b < 0)
|
||||||
from = xstrdup(value);
|
from = xstrdup(value);
|
||||||
|
@ -566,7 +566,7 @@ static int git_merge_config(const char *k, const char *v, void *cb)
|
|||||||
else if (!strcmp(k, "merge.renormalize"))
|
else if (!strcmp(k, "merge.renormalize"))
|
||||||
option_renormalize = git_config_bool(k, v);
|
option_renormalize = git_config_bool(k, v);
|
||||||
else if (!strcmp(k, "merge.ff")) {
|
else if (!strcmp(k, "merge.ff")) {
|
||||||
int boolval = git_config_maybe_bool(k, v);
|
int boolval = git_parse_maybe_bool(v);
|
||||||
if (0 <= boolval) {
|
if (0 <= boolval) {
|
||||||
fast_forward = boolval ? FF_ALLOW : FF_NO;
|
fast_forward = boolval ? FF_ALLOW : FF_NO;
|
||||||
} else if (v && !strcmp(v, "only")) {
|
} else if (v && !strcmp(v, "only")) {
|
||||||
@ -959,7 +959,7 @@ static int default_edit_option(void)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (e) {
|
if (e) {
|
||||||
int v = git_config_maybe_bool(name, e);
|
int v = git_parse_maybe_bool(e);
|
||||||
if (v < 0)
|
if (v < 0)
|
||||||
die(_("Bad value '%s' in environment '%s'"), e, name);
|
die(_("Bad value '%s' in environment '%s'"), e, name);
|
||||||
return v;
|
return v;
|
||||||
|
@ -36,7 +36,7 @@ enum rebase_type {
|
|||||||
static enum rebase_type parse_config_rebase(const char *key, const char *value,
|
static enum rebase_type parse_config_rebase(const char *key, const char *value,
|
||||||
int fatal)
|
int fatal)
|
||||||
{
|
{
|
||||||
int v = git_config_maybe_bool("pull.rebase", value);
|
int v = git_parse_maybe_bool(value);
|
||||||
|
|
||||||
if (!v)
|
if (!v)
|
||||||
return REBASE_FALSE;
|
return REBASE_FALSE;
|
||||||
@ -271,7 +271,7 @@ static const char *config_get_ff(void)
|
|||||||
if (git_config_get_value("pull.ff", &value))
|
if (git_config_get_value("pull.ff", &value))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
switch (git_config_maybe_bool("pull.ff", value)) {
|
switch (git_parse_maybe_bool(value)) {
|
||||||
case 0:
|
case 0:
|
||||||
return "--no-ff";
|
return "--no-ff";
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -480,7 +480,7 @@ static int git_push_config(const char *k, const char *v, void *cb)
|
|||||||
} else if (!strcmp(k, "push.gpgsign")) {
|
} else if (!strcmp(k, "push.gpgsign")) {
|
||||||
const char *value;
|
const char *value;
|
||||||
if (!git_config_get_value("push.gpgsign", &value)) {
|
if (!git_config_get_value("push.gpgsign", &value)) {
|
||||||
switch (git_config_maybe_bool("push.gpgsign", value)) {
|
switch (git_parse_maybe_bool(value)) {
|
||||||
case 0:
|
case 0:
|
||||||
set_push_cert_flags(flags, SEND_PACK_PUSH_CERT_NEVER);
|
set_push_cert_flags(flags, SEND_PACK_PUSH_CERT_NEVER);
|
||||||
break;
|
break;
|
||||||
|
@ -300,7 +300,7 @@ static int config_read_branches(const char *key, const char *value, void *cb)
|
|||||||
}
|
}
|
||||||
string_list_append(&info->merge, xstrdup(value));
|
string_list_append(&info->merge, xstrdup(value));
|
||||||
} else {
|
} else {
|
||||||
int v = git_config_maybe_bool(orig_key, value);
|
int v = git_parse_maybe_bool(value);
|
||||||
if (v >= 0)
|
if (v >= 0)
|
||||||
info->rebase = v;
|
info->rebase = v;
|
||||||
else if (!strcmp(value, "preserve"))
|
else if (!strcmp(value, "preserve"))
|
||||||
|
@ -104,7 +104,7 @@ static int send_pack_config(const char *k, const char *v, void *cb)
|
|||||||
if (!strcmp(k, "push.gpgsign")) {
|
if (!strcmp(k, "push.gpgsign")) {
|
||||||
const char *value;
|
const char *value;
|
||||||
if (!git_config_get_value("push.gpgsign", &value)) {
|
if (!git_config_get_value("push.gpgsign", &value)) {
|
||||||
switch (git_config_maybe_bool("push.gpgsign", value)) {
|
switch (git_parse_maybe_bool(value)) {
|
||||||
case 0:
|
case 0:
|
||||||
args.push_cert = SEND_PACK_PUSH_CERT_NEVER;
|
args.push_cert = SEND_PACK_PUSH_CERT_NEVER;
|
||||||
break;
|
break;
|
||||||
|
2
config.c
2
config.c
@ -1617,7 +1617,7 @@ int git_configset_get_maybe_bool(struct config_set *cs, const char *key, int *de
|
|||||||
{
|
{
|
||||||
const char *value;
|
const char *value;
|
||||||
if (!git_configset_get_value(cs, key, &value)) {
|
if (!git_configset_get_value(cs, key, &value)) {
|
||||||
*dest = git_config_maybe_bool(key, value);
|
*dest = git_parse_maybe_bool(value);
|
||||||
if (*dest == -1)
|
if (*dest == -1)
|
||||||
return -1;
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
|
2
pager.c
2
pager.c
@ -226,7 +226,7 @@ static int pager_command_config(const char *var, const char *value, void *vdata)
|
|||||||
const char *cmd;
|
const char *cmd;
|
||||||
|
|
||||||
if (skip_prefix(var, "pager.", &cmd) && !strcmp(cmd, data->cmd)) {
|
if (skip_prefix(var, "pager.", &cmd) && !strcmp(cmd, data->cmd)) {
|
||||||
int b = git_config_maybe_bool(var, value);
|
int b = git_parse_maybe_bool(value);
|
||||||
if (b >= 0)
|
if (b >= 0)
|
||||||
data->want = b;
|
data->want = b;
|
||||||
else {
|
else {
|
||||||
|
@ -213,7 +213,7 @@ static struct submodule *lookup_or_create_by_name(struct submodule_cache *cache,
|
|||||||
static int parse_fetch_recurse(const char *opt, const char *arg,
|
static int parse_fetch_recurse(const char *opt, const char *arg,
|
||||||
int die_on_error)
|
int die_on_error)
|
||||||
{
|
{
|
||||||
switch (git_config_maybe_bool(opt, arg)) {
|
switch (git_parse_maybe_bool(arg)) {
|
||||||
case 1:
|
case 1:
|
||||||
return RECURSE_SUBMODULES_ON;
|
return RECURSE_SUBMODULES_ON;
|
||||||
case 0:
|
case 0:
|
||||||
@ -237,7 +237,7 @@ int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg)
|
|||||||
static int parse_push_recurse(const char *opt, const char *arg,
|
static int parse_push_recurse(const char *opt, const char *arg,
|
||||||
int die_on_error)
|
int die_on_error)
|
||||||
{
|
{
|
||||||
switch (git_config_maybe_bool(opt, arg)) {
|
switch (git_parse_maybe_bool(arg)) {
|
||||||
case 1:
|
case 1:
|
||||||
/* There's no simple "on" value when pushing */
|
/* There's no simple "on" value when pushing */
|
||||||
if (die_on_error)
|
if (die_on_error)
|
||||||
|
Loading…
Reference in New Issue
Block a user