submodule: warn on valueless active config
PATCH 1/1 submodule: warn on valueless active config
Hi everyone,
My name is Tilak (he/him), and I am a second-year Electronics and Instrumentation Engineering student at NIT Rourkela. I am preparing to apply for GSoC 2027 and am starting my contributions to Git.
Regarding my background with Git: I have built Git from source, successfully
navigated the codebase, and tackled the NEEDSWORK comment regarding valueless 'submodule.active' configurations in submodule.c.
Below is my microproject patch resolving this issue by switching from repo_config_get_string_multi() to repo_config_get_value_multi() and adding an automated test case in t7400-submodule-basic.sh.
I look forward to your feedback!
Thanks,
Tilak
From 08a2f244efab6e4cf21638d87a721ca664ed9433 Mon Sep 17 00:00:00 2001
From: tilak-raaz <[email protected]>
Date: Fri, 14 Aug 2026 22:50:11 +0530
Subject: [GSoC PATCH] submodule: warn on valueless active config
The config parser previously threw a hard error if 'submodule.active' was provided without a value, causing commands to abort.
Swap repo_config_get_string_multi() to repo_config_get_value_multi() to parse valueless keys safely, and emit a warning to the user rather than crashing.
This resolves a NEEDSWORK comment in submodule.c.
--- submodule.c | 16 ++++++++-------- t/t7400-submodule-basic.sh | 11 +++++++++++ 2 files changed, 19 insertions(+), 8 deletions(-)
submodule.c +8 -8
@@ -231,11 +231,7 @@ int option_parse_recurse_submodules_worktree_updater(const struct option *opt,/* * Determine if a submodule has been initialized at a given 'path' */ -/* -* NEEDSWORK: Emit a warning if submodule.active exists, but is valueless, -* ie, the config looks like: "[submodule] active\n". -* Since that is an invalid pathspec, we should inform the user. -*/ +int is_tree_submodule_active (struct repository *repo,const struct object_id *treeish_name,const char *path)
@@ -261,14 +257,18 @@ int is_tree_submodule_active(struct repository *repo,free (key);/* submodule.active is set */ -if (!repo_config_get_string_multi (repo,"submodule.active" , &sl)) { +if (!repo_config_get_value_multi (repo,"submodule.active" , &sl)) {struct pathspec ps;struct strvec args =STRVEC_INIT ;const struct string_list_item *item;for_each_string_list_item (item, sl) { -strvec_push (&args, item->string); - } +if (!item->string) { +warning (_ ("submodule.active is present but has no value" )); +continue ; + } +strvec_push (&args, item->string); + }parse_pathspec (&ps,0 ,0 ,NULL , args.v); ret =match_pathspec (repo->index, &ps, path,strlen (path),0 ,NULL ,1 );
t/t7400-submodule-basic.sh +11 -0
@@ -1549,4 +1549,15 @@ test_expect_success 'submodule add fails when name is reused' ' ) ' + +test_expect_success 'warn on valueless submodule.active' ' + test_when_finished "rm -rf empty-active" && + git init empty-active && + test_commit -C empty-active initial && + git -c protocol.file.allow=always -C empty-active submodule add ../empty-active sub && + git -C empty-active config --unset submodule.sub.active && + printf "[submodule]\n\tactive\n" >>empty-active/.git/config && + git -C empty-active submodule status 2>err && + grep "submodule.active is present but has no value" err +' test_done
Signature · 1 line
2.50.1 (Apple Git-155)
Quoted 11 lines · Tilak Raaz
Hi everyone,
My name is Tilak (he/him), and I am a second-year Electronics and Instrumentation Engineering student at NIT Rourkela. I am preparing to apply for GSoC 2027 and am starting my contributions to Git.
Regarding my background with Git: I have built Git from source, successfully
navigated the codebase, and tackled the NEEDSWORK comment regarding valueless 'submodule.active' configurations insubmodule.c.
Quoted 5 lines
Below is my microproject patch resolving this issue by switching from
repo_config_get_string_multi()torepo_config_get_value_multi()and adding an automated test case int7400-submodule-basic.sh.I look forward to your feedback!
Thanks!
However, my suggestion is that it would be better to place your patch in the main body of the email text rather than in the attachment. Please take a look at Documentation/SubmittingPatches [[attachment]]
And it also seems that the automated program 'b4' is unable to recognize your patch, which may make the development process less convenient for the developers and the maintainer.
$ b4 am https://lore.kernel.org/git/CABB4Jh3UUXvmAJpefaiP-xVRQfGRdTF2jW8GkdhbA1BXe6Okdw@mail.gmail.com/ Looking up CABB4Jh3UUXvmAJpefaiP-xVRQfGRdTF2jW8GkdhbA1BXe6Okdw@mail.gmail.com Analyzing 1 messages in the thread No patches found.
Please correct me if I'm wrong.
Thanks.
Quoted 9 lines · On Fri, Aug 14, 2026 Weijie Yuan <[email protected]> wrote:
Thanks!
However, my suggestion is that it would be better to place your patch in the main body of the email text rather than in the attachment. Please take a look at
Documentation/SubmittingPatchesAnd it also seems that the automated program 'b4' is unable to recognize your patch, which may make the development process less convenient for the developers and the maintainer.
Hi Weijie,
Thank you for the quick feedback and for pointing me to the documentation! I apologize for using an attachment; I am still getting my mailing list workflow configured.
Here is the patch provided inline as plain text so that b4 can parse it correctly:
From 08a2f244efab6e4cf21638d87a721ca664ed9433 Mon Sep 17 00:00:00 2001
From: tilak-raaz <[email protected]>
Date: Fri, 14 Aug 2026 22:50:11 +0530
Subject: [GSoC PATCH] submodule: warn on valueless active config
The config parser previously threw a hard error if 'submodule.active' was provided without a value, causing commands to abort.
Swap repo_config_get_string_multi() to repo_config_get_value_multi() to parse valueless keys safely, and emit a warning to the user rather than crashing.
This resolves a NEEDSWORK comment in submodule.c.
--- submodule.c | 16 ++++++++-------- t/t7400-submodule-basic.sh | 11 +++++++++++ 2 files changed, 19 insertions(+), 8 deletions(-)
submodule.c +0 -0
@@ -231,11 +231,7 @@ int
option_parse_recurse_submodules_worktree_updater(const struct option *opt,
/*
* Determine if a submodule has been initialized at a given 'path' */
-/*
- * NEEDSWORK: Emit a warning if submodule.active exists, but is valueless,
- * ie, the config looks like: "[submodule] active\n".
- * Since that is an invalid pathspec, we should inform the user.
- */
+
int is_tree_submodule_active(struct repository *repo,
const struct object_id *treeish_name,
const char *path)
@@ -261,14 +257,18 @@ int is_tree_submodule_active(struct repository *repo,
free(key);
/* submodule.active is set */
- if (!repo_config_get_string_multi(repo, "submodule.active", &sl)) {
+ if (!repo_config_get_value_multi(repo, "submodule.active", &sl)) { struct pathspec ps;
struct strvec args = STRVEC_INIT;
const struct string_list_item *item;
for_each_string_list_item(item, sl) {
- strvec_push(&args, item->string);
- }
+ if (!item->string) {
+ warning(_("submodule.active is present but
has no value"));
+ continue;
+ }
+ strvec_push(&args, item->string);
+ }
parse_pathspec(&ps, 0, 0, NULL, args.v);
ret = match_pathspec(repo->index, &ps, path, strlen(path), 0, NULL, 1);
t/t7400-submodule-basic.sh +0 -0
@@ -1549,4 +1549,15 @@ test_expect_success 'submodule add fails when
name is reused' '
)
'
+
+test_expect_success 'warn on valueless submodule.active' '
+ test_when_finished "rm -rf empty-active" && + git init empty-active && + test_commit -C empty-active initial && + git -c protocol.file.allow=always -C empty-active submodule add ../empty-active sub && + git -C empty-active config --unset submodule.sub.active && + printf "[submodule]\n\tactive\n" >>empty-active/.git/config && + git -C empty-active submodule status 2>err && + grep "submodule.active is present but has no value" err
+'
test_done
Signature · 1 line
2.50.1 (Apple Git-155)
Quoted 37 lines · Weijie Yuan
Quoted 11 lines · Tilak Raaz
Hi everyone,
My name is Tilak (he/him), and I am a second-year Electronics and Instrumentation Engineering student at NIT Rourkela. I am preparing to apply for GSoC 2027 and am starting my contributions to Git.
Regarding my background with Git: I have built Git from source, successfully
navigated the codebase, and tackled the NEEDSWORK comment regarding valueless 'submodule.active' configurations insubmodule.c.Quoted 5 lines
Below is my microproject patch resolving this issue by switching from
repo_config_get_string_multi()torepo_config_get_value_multi()and adding an automated test case int7400-submodule-basic.sh.I look forward to your feedback!
Thanks!
However, my suggestion is that it would be better to place your patch in the main body of the email text rather than in the attachment. Please take a look at
Documentation/SubmittingPatches[[attachment]]And it also seems that the automated program 'b4' is unable to recognize your patch, which may make the development process less convenient for the developers and the maintainer.
$ b4 am https://lore.kernel.org/git/CABB4Jh3UUXvmAJpefaiP-xVRQfGRdTF2jW8GkdhbA1BXe6Okdw@mail.gmail.com/ Looking up CABB4Jh3UUXvmAJpefaiP-xVRQfGRdTF2jW8GkdhbA1BXe6Okdw@mail.gmail.com Analyzing 1 messages in the thread No patches found.Please correct me if I'm wrong.
Thanks.
Quoted 63 lines · Tilak Raaz
Quoted 9 lines · On Fri, Aug 14, 2026 Weijie Yuan <[email protected]> wrote:
Thanks!
However, my suggestion is that it would be better to place your patch in the main body of the email text rather than in the attachment. Please take a look at
Documentation/SubmittingPatchesAnd it also seems that the automated program 'b4' is unable to recognize your patch, which may make the development process less convenient for the developers and the maintainer.
Hi Weijie,
Thank you for the quick feedback and for pointing me to the documentation! I apologize for using an attachment; I am still getting my mailing list workflow configured.
Here is the patch provided inline as plain text so that
b4can parse it correctly:From
08a2f244efab6e4cf21638d87a721ca664ed9433Mon Sep 17 00:00:00 2001
From: tilak-raaz <[email protected]>
Date: Fri, 14 Aug 2026 22:50:11 +0530
Subject: [GSoC PATCH] submodule: warn on valueless active configThe config parser previously threw a hard error if 'submodule.active' was provided without a value, causing commands to abort.
Swap
repo_config_get_string_multi()torepo_config_get_value_multi()to parse valueless keys safely, and emit a warning to the user rather than crashing.This resolves a NEEDSWORK comment in
submodule.c.Signed-off-by tilak-raaz <[email protected]>--- submodule.c | 16 ++++++++-------- t/t7400-submodule-basic.sh | 11 +++++++++++ 2 files changed, 19 insertions(+), 8 deletions(-)submodule.c +0
-0@@ -231,11 +231,7 @@ intoption_parse_recurse_submodules_worktree_updater(const struct option *opt,
/*
* Determine if a submodule has been initialized at a given 'path' */submodule.c +1
-5-/* -* NEEDSWORK: Emit a warning if submodule.active exists, but is valueless, -* ie, the config looks like: "[submodule] active\n". -* Since that is an invalid pathspec, we should inform the user. -*/ +int is_tree_submodule_active (struct repository *repo,const struct object_id *treeish_name,const char *path)@@ -261,14 +257,18 @@ int is_tree_submodule_active(struct repository *repo,free (key);
submodule.c int is_tree_submodule_active(struct repository *repo, · line 271
Quoted 10 lines
submodule.c +1
-3/* submodule.active is set */ -if (!repo_config_get_string_multi (repo,"submodule.active" , &sl)) { +if (!repo_config_get_value_multi (repo,"submodule.active" , &sl)) {struct pathspec ps;struct strvec args =STRVEC_INIT ;const struct string_list_item *item;for_each_string_list_item (item, sl) { -strvec_push (&args, item->string); - }
It's hard to tell, but I think (depending on _how_ you sent this patch with GMail) the indentation has become corrupted, and the patch won't apply.
Give the tips in git-send-email.io a try; especially with GMail, I've found the safest way to send patches is with git-send-email. (I reply to conversations from just about any mail client, though.)
Quoted 2 lines · Tilak Raaz
The config parser previously threw a hard error if 'submodule.active' was provided without a value, causing commands to abort.
The standard helper to use is config_error_nonbool() when you need to report a section.variable defined this way
[section]
variable
without "= value", and section.variable cannot be a Boolean true.
The patch seems to be heavily whitespace damaged, and cannot be used, though.
Thanks.
PATCH v2 1/1 submodule: warn on valueless active config
In reply to Tilak RaazThe config parser previously threw a hard error if 'submodule.active' was provided without a value, causing commands to abort.
Swap repo_config_get_string_multi() to repo_config_get_value_multi() to parse valueless keys safely. Use the standard config_error_nonbool() helper to emit a warning to the user rather than crashing.
This resolves a NEEDSWORK comment in submodule.c.
---
Thank you Ben and Weijie for the guidance on git-send-email. I have properly configured my terminal to prevent the whitespace damage caused by the Gmail web client.
Junio, thank you for pointing me to the correct helper function.
Changes in v2:
- Use config_error_nonbool() to report valueless submodule.active.
- Add a regression test for the valueless configuration.
- Fix whitespace/indentation issues from v1.
submodule.c | 12 ++++++------ t/t7400-submodule-basic.sh | 11 +++++++++++ 2 files changed, 17 insertions(+), 6 deletions(-)
submodule.c +6 -6
@@ -231,11 +231,7 @@ int option_parse_recurse_submodules_worktree_updater(const struct option *opt,/* * Determine if a submodule has been initialized at a given 'path' */ -/* -* NEEDSWORK: Emit a warning if submodule.active exists, but is valueless, -* ie, the config looks like: "[submodule] active\n". -* Since that is an invalid pathspec, we should inform the user. -*/ +int is_tree_submodule_active (struct repository *repo,const struct object_id *treeish_name,const char *path)
@@ -261,12 +257,16 @@ int is_tree_submodule_active(struct repository *repo,free (key);/* submodule.active is set */ -if (!repo_config_get_string_multi (repo,"submodule.active" , &sl)) { +if (!repo_config_get_value_multi (repo,"submodule.active" , &sl)) {struct pathspec ps;struct strvec args =STRVEC_INIT ;const struct string_list_item *item;for_each_string_list_item (item, sl) { +if (!item->string) { +config_error_nonbool ("submodule.active" ); +continue ; + }strvec_push (&args, item->string); }
t/t7400-submodule-basic.sh +11 -0
@@ -1549,4 +1549,15 @@ test_expect_success 'submodule add fails when name is reused' ' ) ' + +test_expect_success 'warn on valueless submodule.active' ' +test_when_finished "rm -rf empty-active" && +git init empty-active && +test_commit -C empty-active initial && +git -c protocol.file.allow=always -C empty-active submodule add ../empty-active sub && +git -C empty-active config --unset submodule.sub.active && +printf "[submodule]\n\tactive\n" >>empty-active/.git/config && +git -C empty-active submodule status 2>err && +grep "missing value for .submodule.active." err +' test_done
Signature · 1 line
2.50.1 (Apple Git-155)
Quoted 2 lines · tilak-raaz
The config parser previously threw a hard error if 'submodule.active' was provided without a value, causing commands to abort.
An exerpt from Documentation/SubmittingPatches:
[[present-tense]]
The problem statement that describes the status quo is written in the present tense. Write "The code does X when it is given input Y", instead of "The code used to do Y when given input X". You do not have to say "Currently"---the status quo in the problem statement is about the code _without_ your change, by project convention.
Quoted 2 lines
Swap
repo_config_get_string_multi()torepo_config_get_value_multi()to parse valueless keys safely. Use the standardconfig_error_nonbool()
"valueless true", I think.
Quoted 1 line
helper to emit a warning to the user rather than crashing.
Good.
Quoted 1 line
This resolves a NEEDSWORK comment in
submodule.c.
Good. Resolving an existing NEEDSWORK is a two step process, (1) to determine if it still does make sense to do what it suggests to do, and then (2) do it. The early part of the proposed log message solves a half of step (1), in a sense that crashing is bad. The other half is what we should do instead of crashing.
Quoted 16 lines
submodule.c +2
-6-/* -* NEEDSWORK: Emit a warning if submodule.active exists, but is valueless, -* ie, the config looks like: "[submodule] active\n". -* Since that is an invalid pathspec, we should inform the user. -*/ +int is_tree_submodule_active (struct repository *repo,const struct object_id *treeish_name,const char *path)@@ -261,12 +257,16 @@ int is_tree_submodule_active(struct repository *repo,free (key);/* submodule.active is set */ -if (!repo_config_get_string_multi (repo,"submodule.active" , &sl)) { +if (!repo_config_get_value_multi (repo,"submodule.active" , &sl)) {struct pathspec ps;
submodule.c int is_tree_submodule_active(struct repository *repo, · line 271
Quoted 10 lines
submodule.c +4
-0struct strvec args =STRVEC_INIT ;const struct string_list_item *item;for_each_string_list_item (item, sl) { +if (!item->string) { +config_error_nonbool ("submodule.active" ); +continue ; + }strvec_push (&args, item->string); }
And we do warn, but I am not sure if "continue" is sensible, though.
Since we know that the configuration is broken, we should cause the command to fail (i.e., exit with a non-zero status), shouldn't we?
Quoted 8 lines
t/t7400-submodule-basic.sh +0
-0@@ -1549,4 +1549,15 @@ test_expect_success 'submodule add fails when name is reused' ' ) '
t/t7400-submodule-basic.sh test_expect_success 'submodule add fails when name is reused' ' · line 1560
Quoted 10 lines
t/t7400-submodule-basic.sh +9
-0+ +test_expect_success 'warn on valueless submodule.active' ' +test_when_finished "rm -rf empty-active" && +git init empty-active && +test_commit -C empty-active initial && +git -c protocol.file.allow=always -C empty-active submodule add ../empty-active sub && +git -C empty-active config --unset submodule.sub.active && +printf "[submodule]\n\tactive\n" >>empty-active/.git/config && +git -C empty-active submodule status 2>err &&
In other words, shouldn't this say
test_must_fail git submodule status &&
t/t7400-submodule-basic.sh test_expect_success 'submodule add fails when name is reused' ' · line 1562
Quoted 2 lines
t/t7400-submodule-basic.sh +2
-0+grep "missing value for .submodule.active." err +'
Curiously, the test part of your patch is severely whitespace-damaged, even though the C part looked OK. This is quite puzzling.