Skip to content

Commit 2b9cbc6

Browse files
committed
Merge branch 'jk/implicit-true'
Some codepaths did not correctly parse configuration variables specified with valueless "true", which has been corrected. * jk/implicit-true: fsck: handle NULL value when parsing message config trailer: handle NULL value when parsing trailer-specific config submodule: handle NULL value when parsing submodule.*.branch help: handle NULL value for alias.* config trace2: handle NULL values in tr2_sysenv config callback setup: handle NULL value when parsing extensions config: handle NULL value when parsing non-bools
2 parents 67dfb89 + d49cb16 commit 2b9cbc6

18 files changed

+85
-17
lines changed

builtin/blame.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,8 @@ static int git_blame_config(const char *var, const char *value,
748748
}
749749

750750
if (!strcmp(var, "blame.coloring")) {
751+
if (!value)
752+
return config_error_nonbool(var);
751753
if (!strcmp(value, "repeatedLines")) {
752754
coloring_mode |= OUTPUT_COLOR_LINE;
753755
} else if (!strcmp(value, "highlightRecent")) {

builtin/checkout.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,8 @@ static int git_checkout_config(const char *var, const char *value,
12021202
struct checkout_opts *opts = cb;
12031203

12041204
if (!strcmp(var, "diff.ignoresubmodules")) {
1205+
if (!value)
1206+
return config_error_nonbool(var);
12051207
handle_ignore_submodules_arg(&opts->diff_options, value);
12061208
return 0;
12071209
}

builtin/clone.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,8 @@ static int git_clone_config(const char *k, const char *v,
791791
const struct config_context *ctx, void *cb)
792792
{
793793
if (!strcmp(k, "clone.defaultremotename")) {
794+
if (!v)
795+
return config_error_nonbool(k);
794796
free(remote_name);
795797
remote_name = xstrdup(v);
796798
}

builtin/log.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,11 @@ static int git_log_config(const char *var, const char *value,
594594
decoration_style = 0; /* maybe warn? */
595595
return 0;
596596
}
597-
if (!strcmp(var, "log.diffmerges"))
597+
if (!strcmp(var, "log.diffmerges")) {
598+
if (!value)
599+
return config_error_nonbool(var);
598600
return diff_merges_config(value);
601+
}
599602
if (!strcmp(var, "log.showroot")) {
600603
default_show_root = git_config_bool(var, value);
601604
return 0;

builtin/pack-objects.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3204,14 +3204,18 @@ static int git_pack_config(const char *k, const char *v,
32043204
return 0;
32053205
}
32063206
if (!strcmp(k, "uploadpack.blobpackfileuri")) {
3207-
struct configured_exclusion *ex = xmalloc(sizeof(*ex));
3207+
struct configured_exclusion *ex;
32083208
const char *oid_end, *pack_end;
32093209
/*
32103210
* Stores the pack hash. This is not a true object ID, but is
32113211
* of the same form.
32123212
*/
32133213
struct object_id pack_hash;
32143214

3215+
if (!v)
3216+
return config_error_nonbool(k);
3217+
3218+
ex = xmalloc(sizeof(*ex));
32153219
if (parse_oid_hex(v, &ex->e.oid, &oid_end) ||
32163220
*oid_end != ' ' ||
32173221
parse_oid_hex(oid_end + 1, &pack_hash, &pack_end) ||

builtin/receive-pack.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ static enum deny_action parse_deny_action(const char *var, const char *value)
142142
static int receive_pack_config(const char *var, const char *value,
143143
const struct config_context *ctx, void *cb)
144144
{
145+
const char *msg_id;
145146
int status = parse_hide_refs_config(var, value, "receive", &hidden_refs);
146147

147148
if (status)
@@ -178,12 +179,14 @@ static int receive_pack_config(const char *var, const char *value,
178179
return 0;
179180
}
180181

181-
if (skip_prefix(var, "receive.fsck.", &var)) {
182-
if (is_valid_msg_type(var, value))
182+
if (skip_prefix(var, "receive.fsck.", &msg_id)) {
183+
if (!value)
184+
return config_error_nonbool(var);
185+
if (is_valid_msg_type(msg_id, value))
183186
strbuf_addf(&fsck_msg_types, "%c%s=%s",
184-
fsck_msg_types.len ? ',' : '=', var, value);
187+
fsck_msg_types.len ? ',' : '=', msg_id, value);
185188
else
186-
warning("skipping unknown msg id '%s'", var);
189+
warning("skipping unknown msg id '%s'", msg_id);
187190
return 0;
188191
}
189192

compat/mingw.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ int mingw_core_config(const char *var, const char *value,
255255
}
256256

257257
if (!strcmp(var, "core.unsetenvvars")) {
258+
if (!value)
259+
return config_error_nonbool(var);
258260
free(unset_environment_variables);
259261
unset_environment_variables = xstrdup(value);
260262
return 0;

config.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,8 @@ static int git_default_core_config(const char *var, const char *value,
13861386
return 0;
13871387
}
13881388
if (!strcmp(var, "core.checkstat")) {
1389+
if (!value)
1390+
return config_error_nonbool(var);
13891391
if (!strcasecmp(value, "default"))
13901392
check_stat = 1;
13911393
else if (!strcasecmp(value, "minimal"))
@@ -1547,11 +1549,15 @@ static int git_default_core_config(const char *var, const char *value,
15471549
}
15481550

15491551
if (!strcmp(var, "core.checkroundtripencoding")) {
1552+
if (!value)
1553+
return config_error_nonbool(var);
15501554
check_roundtrip_encoding = xstrdup(value);
15511555
return 0;
15521556
}
15531557

15541558
if (!strcmp(var, "core.notesref")) {
1559+
if (!value)
1560+
return config_error_nonbool(var);
15551561
notes_ref_name = xstrdup(value);
15561562
return 0;
15571563
}
@@ -1619,6 +1625,8 @@ static int git_default_core_config(const char *var, const char *value,
16191625
}
16201626

16211627
if (!strcmp(var, "core.createobject")) {
1628+
if (!value)
1629+
return config_error_nonbool(var);
16221630
if (!strcmp(value, "rename"))
16231631
object_creation_mode = OBJECT_CREATION_USES_RENAMES;
16241632
else if (!strcmp(value, "link"))

diff.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,10 @@ int git_diff_ui_config(const char *var, const char *value,
372372
return 0;
373373
}
374374
if (!strcmp(var, "diff.colormovedws")) {
375-
unsigned cm = parse_color_moved_ws(value);
375+
unsigned cm;
376+
if (!value)
377+
return config_error_nonbool(var);
378+
cm = parse_color_moved_ws(value);
376379
if (cm & COLOR_MOVED_WS_ERROR)
377380
return -1;
378381
diff_color_moved_ws_default = cm;
@@ -426,10 +429,15 @@ int git_diff_ui_config(const char *var, const char *value,
426429
if (!strcmp(var, "diff.orderfile"))
427430
return git_config_pathname(&diff_order_file_cfg, var, value);
428431

429-
if (!strcmp(var, "diff.ignoresubmodules"))
432+
if (!strcmp(var, "diff.ignoresubmodules")) {
433+
if (!value)
434+
return config_error_nonbool(var);
430435
handle_ignore_submodules_arg(&default_diff_options, value);
436+
}
431437

432438
if (!strcmp(var, "diff.submodule")) {
439+
if (!value)
440+
return config_error_nonbool(var);
433441
if (parse_submodule_params(&default_diff_options, value))
434442
warning(_("Unknown value for 'diff.submodule' config variable: '%s'"),
435443
value);
@@ -473,7 +481,10 @@ int git_diff_basic_config(const char *var, const char *value,
473481
}
474482

475483
if (!strcmp(var, "diff.wserrorhighlight")) {
476-
int val = parse_ws_error_highlight(value);
484+
int val;
485+
if (!value)
486+
return config_error_nonbool(var);
487+
val = parse_ws_error_highlight(value);
477488
if (val < 0)
478489
return -1;
479490
ws_error_highlight_default = val;
@@ -490,6 +501,8 @@ int git_diff_basic_config(const char *var, const char *value,
490501

491502
if (!strcmp(var, "diff.dirstat")) {
492503
struct strbuf errmsg = STRBUF_INIT;
504+
if (!value)
505+
return config_error_nonbool(var);
493506
default_diff_options.dirstat_permille = diff_dirstat_permille_default;
494507
if (parse_dirstat_params(&default_diff_options, value, &errmsg))
495508
warning(_("Found errors in 'diff.dirstat' config variable:\n%s"),

fetch-pack.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,6 +1862,8 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
18621862
static int fetch_pack_config_cb(const char *var, const char *value,
18631863
const struct config_context *ctx, void *cb)
18641864
{
1865+
const char *msg_id;
1866+
18651867
if (strcmp(var, "fetch.fsck.skiplist") == 0) {
18661868
const char *path;
18671869

@@ -1873,12 +1875,14 @@ static int fetch_pack_config_cb(const char *var, const char *value,
18731875
return 0;
18741876
}
18751877

1876-
if (skip_prefix(var, "fetch.fsck.", &var)) {
1877-
if (is_valid_msg_type(var, value))
1878+
if (skip_prefix(var, "fetch.fsck.", &msg_id)) {
1879+
if (!value)
1880+
return config_error_nonbool(var);
1881+
if (is_valid_msg_type(msg_id, value))
18781882
strbuf_addf(&fsck_msg_types, "%c%s=%s",
1879-
fsck_msg_types.len ? ',' : '=', var, value);
1883+
fsck_msg_types.len ? ',' : '=', msg_id, value);
18801884
else
1881-
warning("Skipping unknown msg id '%s'", var);
1885+
warning("Skipping unknown msg id '%s'", msg_id);
18821886
return 0;
18831887
}
18841888

fsck.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,8 @@ int git_fsck_config(const char *var, const char *value,
14031403
const struct config_context *ctx, void *cb)
14041404
{
14051405
struct fsck_options *options = cb;
1406+
const char *msg_id;
1407+
14061408
if (strcmp(var, "fsck.skiplist") == 0) {
14071409
const char *path;
14081410
struct strbuf sb = STRBUF_INIT;
@@ -1416,8 +1418,10 @@ int git_fsck_config(const char *var, const char *value,
14161418
return 0;
14171419
}
14181420

1419-
if (skip_prefix(var, "fsck.", &var)) {
1420-
fsck_set_msg_type(options, var, value);
1421+
if (skip_prefix(var, "fsck.", &msg_id)) {
1422+
if (!value)
1423+
return config_error_nonbool(var);
1424+
fsck_set_msg_type(options, msg_id, value);
14211425
return 0;
14221426
}
14231427

help.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,11 @@ static int get_alias(const char *var, const char *value,
464464
{
465465
struct string_list *list = data;
466466

467-
if (skip_prefix(var, "alias.", &var))
467+
if (skip_prefix(var, "alias.", &var)) {
468+
if (!value)
469+
return config_error_nonbool(var);
468470
string_list_append(list, var)->util = xstrdup(value);
471+
}
469472

470473
return 0;
471474
}

mailinfo.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,8 @@ static int git_mailinfo_config(const char *var, const char *value,
12531253
return 0;
12541254
}
12551255
if (!strcmp(var, "mailinfo.quotedcr")) {
1256+
if (!value)
1257+
return config_error_nonbool(var);
12561258
if (mailinfo_parse_quoted_cr_action(value, &mi->quoted_cr) != 0)
12571259
return error(_("bad action '%s' for '%s'"), value, var);
12581260
return 0;

notes-utils.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ static int notes_rewrite_config(const char *k, const char *v,
112112
}
113113
return 0;
114114
} else if (!c->refs_from_env && !strcmp(k, "notes.rewriteref")) {
115+
if (!v)
116+
return config_error_nonbool(k);
115117
/* note that a refs/ prefix is implied in the
116118
* underlying for_each_glob_ref */
117119
if (starts_with(v, "refs/notes/"))

setup.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,8 @@ static enum extension_result handle_extension_v0(const char *var,
559559
data->precious_objects = git_config_bool(var, value);
560560
return EXTENSION_OK;
561561
} else if (!strcmp(ext, "partialclone")) {
562+
if (!value)
563+
return config_error_nonbool(var);
562564
data->partial_clone = xstrdup(value);
563565
return EXTENSION_OK;
564566
} else if (!strcmp(ext, "worktreeconfig")) {

submodule-config.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,9 @@ static int parse_config(const char *var, const char *value,
516516
submodule->recommend_shallow =
517517
git_config_bool(var, value);
518518
} else if (!strcmp(item.buf, "branch")) {
519-
if (!me->overwrite && submodule->branch)
519+
if (!value)
520+
ret = config_error_nonbool(var);
521+
else if (!me->overwrite && submodule->branch)
520522
warn_multiple_config(me->treeish_name, submodule->name,
521523
"branch");
522524
else {

trace2/tr2_sysenv.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ static int tr2_sysenv_cb(const char *key, const char *value,
6868

6969
for (k = 0; k < ARRAY_SIZE(tr2_sysenv_settings); k++) {
7070
if (!strcmp(key, tr2_sysenv_settings[k].git_config_name)) {
71+
if (!value)
72+
return config_error_nonbool(key);
7173
free(tr2_sysenv_settings[k].value);
7274
tr2_sysenv_settings[k].value = xstrdup(value);
7375
return 0;

trailer.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,8 @@ static int git_trailer_default_config(const char *conf_key, const char *value,
507507
warning(_("unknown value '%s' for key '%s'"),
508508
value, conf_key);
509509
} else if (!strcmp(trailer_item, "separators")) {
510+
if (!value)
511+
return config_error_nonbool(conf_key);
510512
separators = xstrdup(value);
511513
}
512514
}
@@ -551,16 +553,22 @@ static int git_trailer_config(const char *conf_key, const char *value,
551553
case TRAILER_KEY:
552554
if (conf->key)
553555
warning(_("more than one %s"), conf_key);
556+
if (!value)
557+
return config_error_nonbool(conf_key);
554558
conf->key = xstrdup(value);
555559
break;
556560
case TRAILER_COMMAND:
557561
if (conf->command)
558562
warning(_("more than one %s"), conf_key);
563+
if (!value)
564+
return config_error_nonbool(conf_key);
559565
conf->command = xstrdup(value);
560566
break;
561567
case TRAILER_CMD:
562568
if (conf->cmd)
563569
warning(_("more than one %s"), conf_key);
570+
if (!value)
571+
return config_error_nonbool(conf_key);
564572
conf->cmd = xstrdup(value);
565573
break;
566574
case TRAILER_WHERE:

0 commit comments

Comments
 (0)