Skip to content

Commit 5b26a7e

Browse files
committed
SQUASH???
1 parent 6571d82 commit 5b26a7e

File tree

4 files changed

+17
-36
lines changed

4 files changed

+17
-36
lines changed

builtin/config.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static int show_scope;
6565
#define TYPE_PATH 4
6666
#define TYPE_EXPIRY_DATE 5
6767
#define TYPE_COLOR 6
68-
#define TYPE_BOOL_OR_STR 7
68+
#define TYPE_BOOL_OR_STR 7
6969

7070
#define OPT_CALLBACK_VALUE(s, l, v, h, i) \
7171
{ OPTION_CALLBACK, (s), (l), (v), NULL, (h), PARSE_OPT_NOARG | \
@@ -255,12 +255,11 @@ static int format_config(struct strbuf *buf, const char *key_, const char *value
255255
else
256256
strbuf_addf(buf, "%d", v);
257257
} else if (type == TYPE_BOOL_OR_STR) {
258-
int is_bool, v;
259-
v = git_config_bool_or_str(NULL, key_, value_, &is_bool);
260-
if (is_bool)
261-
strbuf_addstr(buf, v ? "true" : "false");
262-
else
258+
int v = git_parse_maybe_bool(value_);
259+
if (v < 0)
263260
strbuf_addstr(buf, value_);
261+
else
262+
strbuf_addstr(buf, v ? "true" : "false");
264263
} else if (type == TYPE_PATH) {
265264
const char *v;
266265
if (git_config_pathname(&v, key_, value_) < 0)
@@ -423,9 +422,8 @@ static char *normalize_value(const char *key, const char *value)
423422
return xstrdup(v ? "true" : "false");
424423
}
425424
if (type == TYPE_BOOL_OR_STR) {
426-
int is_bool, v;
427-
v = git_config_bool_or_str(NULL, key, value, &is_bool);
428-
if (!is_bool)
425+
int v = git_parse_maybe_bool(value);
426+
if (v < 0)
429427
return xstrdup(value);
430428
else
431429
return xstrdup(v ? "true" : "false");

config.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,20 +1100,6 @@ int git_config_bool_or_int(const char *name, const char *value, int *is_bool)
11001100
return git_config_int(name, value);
11011101
}
11021102

1103-
int git_config_bool_or_str(const char **dest, const char *name, const char *value, int *is_bool)
1104-
{
1105-
int v = git_parse_maybe_bool_text(value);
1106-
if (0 <= v) {
1107-
*is_bool = 1;
1108-
return v;
1109-
}
1110-
*is_bool = 0;
1111-
if (dest != NULL)
1112-
return git_config_string(dest, name, value);
1113-
else
1114-
return 0;
1115-
}
1116-
11171103
int git_config_bool(const char *name, const char *value)
11181104
{
11191105
int discard;

config.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,6 @@ ssize_t git_config_ssize_t(const char *, const char *);
217217
*/
218218
int git_config_bool_or_int(const char *, const char *, int *);
219219

220-
/**
221-
* Same as `git_config_bool`, except that `is_bool` flag is unset, then if
222-
* `dest` parameter is non-NULL, it allocates and copies the value string
223-
* into the `dest`, if `dest` is NULL and `is_bool` flag is unset it return 0.
224-
*/
225-
int git_config_bool_or_str(const char **, const char *, const char *, int *);
226-
227220
/**
228221
* Parse a string into a boolean value, respecting keywords like "true" and
229222
* "false". Integer values are converted into true/false values (when they

mergetools/meld

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ check_meld_for_features () {
3636
then
3737
meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)
3838
case "$meld_has_output_option" in
39-
true|false)
39+
true | false)
4040
: use configured value
4141
;;
4242
*)
4343
: empty or invalid configured value, detecting "--output" automatically
4444
init_meld_help_msg
4545

4646
case "$meld_help_msg" in
47-
*"--output="*|*'[OPTION...]'*)
47+
*"--output="* | *'[OPTION...]'*)
4848
# All version that has [OPTION...] supports --output
4949
meld_has_output_option=true
5050
;;
@@ -59,27 +59,31 @@ check_meld_for_features () {
5959
if test -z "$meld_use_auto_merge_option"
6060
then
6161
meld_use_auto_merge_option=$(
62-
git config --bool-or-str mergetool.meld.useAutoMerge)
62+
git config --bool-or-str mergetool.meld.useAutoMerge
63+
)
6364
case "$meld_use_auto_merge_option" in
64-
true|false)
65+
true | false)
6566
: use well formatted boolean value
6667
;;
6768
auto)
6869
# testing the "--auto-merge" option only if config is "auto"
6970
init_meld_help_msg
7071

7172
case "$meld_help_msg" in
72-
*"--auto-merge"*|*'[OPTION...]'*)
73+
*"--auto-merge"* | *'[OPTION...]'*)
7374
meld_use_auto_merge_option=true
7475
;;
7576
*)
7677
meld_use_auto_merge_option=false
7778
;;
7879
esac
7980
;;
80-
*)
81+
"")
8182
meld_use_auto_merge_option=false
8283
;;
84+
*)
85+
die "unknown mergetool.meld.useAutoMerge: $meld_use_auto_merge_option"
86+
;;
8387
esac
8488
fi
8589
}

0 commit comments

Comments
 (0)