From: Thomas Bachem via GitGitGadget Date: Wed, 11 Nov 2026 22:49:06 GMT Subject: [PATCH v3 06/15] remote: handle NULL value for remote..tagOpt Message-ID: <339590cd4b8b0611f4b7ec55889238d13e2bee3b.1794437355.git.gitgitgadget@gmail.com> In-Reply-To: From: Thomas Bachem A remote..tagOpt without a value makes "git fetch", "git remote" and "git status" segfault: handle_config() passes the NULL value to strcmp(). The setting takes "--no-tags" or "--tags", and any other value is ignored. Ignore a missing value too, but warn about it. Helped-by: Phillip Wood Assisted-by: Claude Fable 5.1 Assisted-by: Claude Opus 5.5 Signed-off-by: Thomas Bachem --- remote.c | 4 ++++ t/t5505-remote.sh | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/remote.c b/remote.c index 49ee2ea318..d3164fee69 100644 --- a/remote.c +++ b/remote.c @@ -556,6 +556,10 @@ static int handle_config(const char *key, const char *value, else error(_("more than one uploadpack given, using the first")); } else if (!strcmp(subkey, "tagopt")) { + if (!value) { + warning(_("missing value for '%s'"), key); + return 0; + } if (!strcmp(value, "--no-tags")) remote->fetch_tags = -1; else if (!strcmp(value, "--tags")) diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index 5fbfcb0848..8b4c7006ec 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -90,6 +90,13 @@ test_expect_success 'remote information for the origin' ' ) ' +test_expect_success 'tagOpt without a value only warns' ' + git -C test -c remote.origin.tagOpt remote >actual 2>err && + echo origin >expect && + test_cmp expect actual && + test_grep "missing value for .remote.origin.tagopt." err +' + test_expect_success 'add another remote' ' ( cd test && -- gitgitgadget