git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: "Fabrício Nascimento" <fabricio@tailorbirds.com.br>
Cc: Michael Witten <mfwitten@gmail.com>, git@vger.kernel.org
Subject: [PATCH] commit: clarify "could not read 'template'" message
Date: Fri, 19 Aug 2011 00:07:33 -0500	[thread overview]
Message-ID: <20110819050714.GA21697@elie.gateway.2wire.net> (raw)
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:

> 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

  parent reply	other threads:[~2011-08-19  5:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-12 17:13 [BUG] Git won't commit Fabricio Nascimento
2011-08-12 17:20 ` Fabricio Nascimento
2011-08-12 17:30 ` Michael Witten
     [not found]   ` <CAAC=0R66j43CqpaxXskAwHsitvRFwy7DsjguNPm+sPa4YmTWqw@mail.gmail.com>
2011-08-13 20:56     ` Michael Witten
2011-08-13 21:18       ` Jonathan Nieder
     [not found]         ` <CAAC=0R5CpJx1QOKYJDs0_ksEdyYG95fSAo3U3eU536YW=M84MA@mail.gmail.com>
2011-08-19  5:07           ` Jonathan Nieder [this message]
2011-08-19  6:04             ` [PATCH] commit: clarify "could not read 'template'" message Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110819050714.GA21697@elie.gateway.2wire.net \
    --to=jrnieder@gmail.com \
    --cc=fabricio@tailorbirds.com.br \
    --cc=git@vger.kernel.org \
    --cc=mfwitten@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).