From: Thomas Bachem via GitGitGadget Date: Tue, 10 Nov 2026 07:36:31 GMT Subject: [PATCH v2 01/15] rebase -i: handle NULL value for rebase.missingCommitsCheck Message-ID: <47224a9893e9cf87c0ee16bd1a79cf1355694175.1794296205.git.gitgitgadget@gmail.com> In-Reply-To: From: Thomas Bachem A rebase.missingCommitsCheck without a value, as in [rebase] missingCommitsCheck or "git -c rebase.missingCommitsCheck", makes "git rebase -i" segfault as it writes the todo list: get_missing_commit_check_level() passes the NULL value to strcasecmp(). The setting takes "ignore", "warn" or "error". An unrecognized value, perhaps one meant for a newer version of Git, gets a warning and is treated as "ignore". Treat a missing value the same way. Helped-by: Phillip Wood Assisted-by: Claude Fable 5.1 Assisted-by: Claude Opus 5.5 Signed-off-by: Thomas Bachem --- rebase-interactive.c | 10 ++++++++-- t/t3404-rebase-interactive.sh | 12 ++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/rebase-interactive.c b/rebase-interactive.c index 809f76a87b..9eb70b09b3 100644 --- a/rebase-interactive.c +++ b/rebase-interactive.c @@ -30,8 +30,14 @@ static enum missing_commit_check_level get_missing_commit_check_level(void) { const char *value; - if (repo_config_get_value(the_repository, "rebase.missingcommitscheck", &value) || - !strcasecmp("ignore", value)) + if (repo_config_get_value(the_repository, "rebase.missingcommitscheck", &value)) + return MISSING_COMMIT_CHECK_IGNORE; + if (!value) { + warning(_("missing value for option " + "rebase.missingCommitsCheck. Ignoring.")); + return MISSING_COMMIT_CHECK_IGNORE; + } + if (!strcasecmp("ignore", value)) return MISSING_COMMIT_CHECK_IGNORE; if (!strcasecmp("warn", value)) return MISSING_COMMIT_CHECK_WARN; diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index b3ee96f560..5b9fc67c19 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -1562,6 +1562,18 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = error' ' test B = $(git cat-file commit HEAD^ | sed -ne \$p) ' +test_expect_success 'rebase -i warns about and ignores rebase.missingCommitsCheck without a value' ' + rebase_setup_and_clean missing-commit && + ( + set_fake_editor && + FAKE_LINES="1 2 3 4" \ + git -c rebase.missingCommitsCheck rebase -i --root 2>actual + ) && + test D = $(git cat-file commit HEAD | sed -ne \$p) && + test_grep "missing value for option rebase.missingCommitsCheck" actual && + test_grep ! "commits may have been dropped" actual +' + test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = ignore' ' test_config rebase.missingCommitsCheck ignore && rebase_setup_and_clean missing-commit && -- gitgitgadget