From: Thomas Bachem via GitGitGadget Date: Wed, 11 Nov 2026 22:49:08 GMT Subject: [PATCH v3 08/15] merge: handle NULL value for branch..mergeOptions Message-ID: <90209dc754de398aa150459d7b324fb41f974a22.1794437355.git.gitgitgadget@gmail.com> In-Reply-To: From: Thomas Bachem A branch..mergeOptions without a value makes "git merge" segfault on that branch: git_merge_config() passes the NULL value to xstrdup(). Reject a missing value with config_error_nonbool(), as git_config_string() already does for the other strings that git_merge_config() reads. Assisted-by: Claude Opus 5.5 Signed-off-by: Thomas Bachem --- builtin/merge.c | 2 ++ t/t7600-merge.sh | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/builtin/merge.c b/builtin/merge.c index d7bf209114..c6f9356ccb 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -668,6 +668,8 @@ static int git_merge_config(const char *k, const char *v, skip_prefix(k, "branch.", &str) && skip_prefix(str, branch, &str) && !strcmp(str, ".mergeoptions")) { + if (!v) + return config_error_nonbool(k); free(branch_mergeoptions); branch_mergeoptions = xstrdup(v); return 0; diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index 8f6109fb91..2da12d6662 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -552,6 +552,12 @@ test_expect_success 'merge c1 with c2 (squash in config)' ' test_cmp squash.1-5 .git/SQUASH_MSG ' +test_expect_success 'merge rejects branch.main.mergeOptions without a value' ' + git reset --hard c1 && + test_must_fail git -c branch.main.mergeOptions merge c2 2>err && + test_grep "missing value for .branch.main.mergeoptions." err +' + test_debug 'git log --graph --decorate --oneline --all' test_expect_success 'override config option -n with --summary' ' -- gitgitgadget