diff --git a/builtin/commit.c b/builtin/commit.c index eba1377eb3..7141766ba9 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1049,6 +1049,8 @@ static int parse_and_validate_options(int argc, const char *argv[], die(_("Only one of -c/-C/-F/--fixup can be used.")); if (message.len && f > 0) die((_("Option -m cannot be combined with -c/-C/-F/--fixup."))); + if (f || message.len) + template_file = NULL; if (edit_message) use_message = edit_message; if (amend && !use_message && !fixup_message) diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh index 45446b186e..e59cc4e861 100755 --- a/t/t7501-commit.sh +++ b/t/t7501-commit.sh @@ -81,7 +81,13 @@ test_expect_success 'empty commit message' ' test_must_fail git commit -F msg -a ' +test_expect_success 'template "emptyness" check does not kick in with -F' ' + git checkout HEAD file && echo >>file && git add file && + git commit -t file -F file +' + test_expect_success 'setup: commit message from file' ' + git checkout HEAD file && echo >>file && git add file && echo this is the commit message, coming from a file >msg && git commit -F msg -a '