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 <gitster@pobox.com>
Junio C Hamano committed
Mar 30, 2012 at 11:30 UTC
010c7dbcbe2e55c1dcc85f23fbe55be6d7e931f0
2 files changed
+8
builtin/commit.c
+2
@@ -1049,6 +1049,8 @@ static int parse_and_validate_options(int argc, const char *argv[],
1049
die(_("Only one of -c/-C/-F/--fixup can be used."));
1050
if (message.len && f > 0)
1051
die((_("Option -m cannot be combined with -c/-C/-F/--fixup.")));
1052
+ if (f || message.len)
1053
+ template_file = NULL;
1054
if (edit_message)
1055
use_message = edit_message;
1056
if (amend && !use_message && !fixup_message)
t/t7501-commit.sh
+6
@@ -81,7 +81,13 @@ test_expect_success 'empty commit message' '
81
test_must_fail git commit -F msg -a
82
'
83
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
+
89
test_expect_success 'setup: commit message from file' '
90
+ git checkout HEAD file && echo >>file && git add file &&
91
echo this is the commit message, coming from a file >msg &&
92
git commit -F msg -a
93
'