From: Thomas Bachem via GitGitGadget Date: Wed, 11 Nov 2026 22:49:09 GMT Subject: [PATCH v3 09/15] remote: handle NULL value for remotes. Message-ID: In-Reply-To: From: Thomas Bachem A remotes. without a value makes "git fetch " and "git push " segfault: get_remote_group() dereferences the NULL value as it splits the list of remotes. Reject a missing value with config_error_nonbool(), and keep the whole key for its message by skipping the "remotes." prefix into a separate variable. Assisted-by: Claude Opus 5.5 Signed-off-by: Thomas Bachem --- remote.c | 5 ++++- t/t5506-remote-groups.sh | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/remote.c b/remote.c index d3164fee69..80be49acb4 100644 --- a/remote.c +++ b/remote.c @@ -2200,8 +2200,11 @@ int get_remote_group(const char *key, const char *value, void *priv) { struct remote_group_data *g = priv; + const char *group; - if (skip_prefix(key, "remotes.", &key) && !strcmp(key, g->name)) { + if (skip_prefix(key, "remotes.", &group) && !strcmp(group, g->name)) { + if (!value) + return config_error_nonbool(key); /* split list by white space */ while (*value) { size_t wordlen = strcspn(value, " \t\n"); diff --git a/t/t5506-remote-groups.sh b/t/t5506-remote-groups.sh index 16e9a1bc2f..f11eb8511e 100755 --- a/t/t5506-remote-groups.sh +++ b/t/t5506-remote-groups.sh @@ -54,6 +54,11 @@ test_expect_success 'nonexistent group produces error' ' ! repo_fetched two ' +test_expect_success 'remotes. without a value is rejected' ' + test_must_fail git -c remotes.valueless fetch valueless 2>err && + test_grep "missing value for .remotes.valueless." err +' + test_expect_success 'updating group updates all members (remote update)' ' mark group-all && update_repos && -- gitgitgadget