Skip to content

Commit 010c7db

Browse files
committed
commit: do not trigger bogus "has templated message edited" check
When "-t template" and "-F msg" options are both given (or worse yet, there is "commit.template" configuration but a message is given in some other way), the documentation says that template is ignored. However, the "has the user edited the message?" check still used the contents of the template file as the basis of the emptyness check. Signed-off-by: Junio C Hamano <[email protected]>
1 parent c65dc35 commit 010c7db

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

builtin/commit.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,8 @@ static int parse_and_validate_options(int argc, const char *argv[],
10491049
die(_("Only one of -c/-C/-F/--fixup can be used."));
10501050
if (message.len && f > 0)
10511051
die((_("Option -m cannot be combined with -c/-C/-F/--fixup.")));
1052+
if (f || message.len)
1053+
template_file = NULL;
10521054
if (edit_message)
10531055
use_message = edit_message;
10541056
if (amend && !use_message && !fixup_message)

t/t7501-commit.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ test_expect_success 'empty commit message' '
8181
test_must_fail git commit -F msg -a
8282
'
8383

84+
test_expect_success 'template "emptyness" check does not kick in with -F' '
85+
git checkout HEAD file && echo >>file && git add file &&
86+
git commit -t file -F file
87+
'
88+
8489
test_expect_success 'setup: commit message from file' '
90+
git checkout HEAD file && echo >>file && git add file &&
8591
echo this is the commit message, coming from a file >msg &&
8692
git commit -F msg -a
8793
'

0 commit comments

Comments
 (0)