[PATCH v2 08/15] merge: handle NULL value for branch.<name>.mergeOptions
- From
Thomas Bachem via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Nov 10, 2026, 07:36 UTC
- Message-ID
- <d8681a8560c6e5185f66df372f65c9b9dee99cc3.1794296205.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.2297.v2.git.1794296205.gitgitgadget@gmail.com>
From: Thomas Bachem <mail@thomasbachem.com>
A branch.<name>.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 <mail@thomasbachem.com> --- 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