Skip to content

Commit

Permalink
commit: do not trigger bogus "has templated message edited" check
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Mar 30, 2012
1 parent c65dc35 commit 010c7db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions builtin/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions t/t7501-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
'
Expand Down

0 comments on commit 010c7db

Please sign in to comment.