[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