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 [off-list ref]
Analysis-by: Michael Witten [off-list ref]
Signed-off-by: Jonathan Nieder <redacted>
---
Hi again,
Fabrício Nascimento wrote:
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