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

[PATCH] commit: clarify "could not read 'template'" message

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Aug 19, 2011, 05:07 UTC
Message-ID
<20110819050714.GA21697@elie.gateway.2wire.net>
In-Reply-To
<CAAC=0R5CpJx1QOKYJDs0_ksEdyYG95fSAo3U3eU536YW=M84MA@mail.gmail.com>

Fabrício noticed that when the "[commit] template" configuration is misconfigured to point to a nonexistent file, ever since v1.7.4.2 (see 2140b140, 2011-02-25), "git commit" fails in a seemingly mysterious way:

	$ git commit
	fatal: could not read 'template': No such file or directory
In olden times, the message instead said
	Commit template file does not exist.

which makes it a little clearer that the --template option or corresponding configuration item is being misused. Let's move a little in that direction, by saying "could not read commit message template 'template'".

Note that the origin of the setting in the motivating ~/.gitignore is still unknown. Depending on the answer, it might be nice to start ignoring nonexistent commit templates again; if the problem is widespread, hopefully there will be more reports soon.

Noticed-by: Fabrício Nascimento <fabriciosn@gmail.com>
Analysis-by: Michael Witten <mfwitten@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Hi again,
Fabrício Nascimento wrote:
Show 5 quoted lines
> I have no idea what could have set the variable. Time Machine tells me the
> only changes on the .gitconfig file happened on August 12th, the day I've
> flagged the bug. I know I've made a brew upgrade on all my packages (that
> included git) the night before, and then the bug appeared the day after. I
> should have done only git stats, commit, pull and push.

Thanks for these details. I looked through the packages in brew, but no obvious clues.

At least the problem could have been easier to debug. How about this patch, to start?

 builtin/commit.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index cb738574..d029ec03 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -703,7 +703,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		hook_arg1 = "squash";
 	} else if (template_file) {
 		if (strbuf_read_file(&sb, template_file, 0) < 0)
-			die_errno(_("could not read '%s'"), template_file);
+			die_errno(_("could not read commit message template '%s'"),
+				  template_file);
 		hook_arg1 = "template";
 		clean_message_contents = 0;
 	}
-- 
1.7.6
Previous: Jonathan NiederNext: Junio C Hamano
Message 6 of 7 in “[BUG] Git won't commit”
  1. Fabricio NascimentoAug 12, 2011
  2. Fabricio NascimentoAug 12, 2011
  3. Michael WittenAug 12, 2011
  4. Michael WittenAug 13, 2011
  5. Jonathan NiederAug 13, 2011
  6. commit: clarify "could not read 'template'" messageJonathan Nieder, Aug 19, 2011
  7. Junio C HamanoAug 19, 2011

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.