git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] commit: do not trigger bogus "has templated message edited" check

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 30, 2012, 19:45 UTC
Message-ID
<1333136719-12657-3-git-send-email-gitster@pobox.com>
In-Reply-To
<1333136719-12657-1-git-send-email-gitster@pobox.com>

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>
---
 builtin/commit.c  |    2 ++
 t/t7501-commit.sh |    6 ++++++
 2 files changed, 8 insertions(+)
diff --git a/builtin/commit.c b/builtin/commit.c
index eba1377..7141766 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 45446b1..e59cc4e 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
 '
-- 
1.7.10.rc3.55.g06e99
Previous: Junio C HamanoNext: Junio C Hamano
Message 13 of 19 in “git-commit doc: say -t requires editing commit message”
  1. git-commit doc: say -t requires editing commit messageAdam Monsen, Mar 29, 2012
  2. Ivan HeffnerMar 29, 2012
  3. git-commit.txt: clarify -t requires editing messageAdam Monsen, Mar 29, 2012
  4. Junio C HamanoMar 30, 2012
  5. Adam MonsenMar 30, 2012
  6. Junio C HamanoMar 30, 2012
  7. Adam MonsenMar 30, 2012
  8. Junio C HamanoMar 30, 2012
  9. Adam MonsenMar 30, 2012
  10. Junio C HamanoMar 30, 2012
  11. 0/3 "commit --template" fixesJunio C Hamano, Mar 30, 2012
  12. 1/3 t7501: test the right kind of breakageJunio C Hamano, Mar 30, 2012
  13. 2/3 commit: do not trigger bogus "has templated message edited" checkJunio C Hamano, Mar 30, 2012
  14. 3/3 commit: rephrase the error when user did not touch templated log messageJunio C Hamano, Mar 30, 2012
  15. Adam MonsenMar 31, 2012
  16. Junio C HamanoApr 1, 2012
  17. Adam MonsenApr 3, 2012
  18. Junio C HamanoApr 3, 2012
  19. Adam MonsenApr 5, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.