[PATCH v3 06/15] remote: handle NULL value for remote.<name>.tagOpt
- From
Thomas Bachem via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Nov 11, 2026, 22:49 UTC
- Message-ID
- <339590cd4b8b0611f4b7ec55889238d13e2bee3b.1794437355.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.2297.v3.git.1794437355.gitgitgadget@gmail.com>
From: Thomas Bachem <mail@thomasbachem.com>
A remote.<name>.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 <phillip.wood@dunelm.org.uk> Assisted-by: Claude Fable 5.1 Assisted-by: Claude Opus 5.5 Signed-off-by: Thomas Bachem <mail@thomasbachem.com> --- 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