Skip to content

Commit 5fb0e08

Browse files
committed
Merge branch 'jl/some-submodule-config-are-not-boolean'
* jl/some-submodule-config-are-not-boolean: avoid segfault on submodule.*.path set to an empty "true"
2 parents baa8d42 + 4b05440 commit 5fb0e08

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

submodule.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ int parse_submodule_config_option(const char *var, const char *value)
134134
return 0;
135135

136136
if (!strcmp(key, "path")) {
137+
if (!value)
138+
return config_error_nonbool(var);
139+
137140
config = unsorted_string_list_lookup(&config_name_for_path, value);
138141
if (config)
139142
free(config->util);
@@ -151,6 +154,9 @@ int parse_submodule_config_option(const char *var, const char *value)
151154
} else if (!strcmp(key, "ignore")) {
152155
char *name_cstr;
153156

157+
if (!value)
158+
return config_error_nonbool(var);
159+
154160
if (strcmp(value, "untracked") && strcmp(value, "dirty") &&
155161
strcmp(value, "all") && strcmp(value, "none")) {
156162
warning("Invalid parameter \"%s\" for config option \"submodule.%s.ignore\"", value, var);

t/t7400-submodule-basic.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ test_expect_success 'setup - initial commit' '
1818
git branch initial
1919
'
2020

21+
test_expect_success 'configuration parsing' '
22+
test_when_finished "rm -f .gitmodules" &&
23+
cat >.gitmodules <<-\EOF &&
24+
[submodule "s"]
25+
path
26+
ignore
27+
EOF
28+
test_must_fail git status
29+
'
30+
2131
test_expect_success 'setup - repository in init subdirectory' '
2232
mkdir init &&
2333
(

0 commit comments

Comments
 (0)