{"thread":{"id":"28082","subject":"[BUG] Git won't commit","startedAt":"2011-08-12T17:13:45Z","lastAt":"2011-08-19T06:04:09Z","messageCount":7,"participants":["Fabricio Nascimento","Michael Witten","Jonathan Nieder","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"173407","messageId":"1313169225059-6681082.post@n2.nabble.com","threadId":"28082","inReplyTo":null,"subject":"[BUG] Git won't commit","fromName":"Fabricio Nascimento","fromEmail":"fabriciosn@gmail.com","sentAt":"2011-08-12T17:13:45Z","receivedAt":"2011-08-12T17:13:45Z","isPatch":false,"sender":{"key":"fabriciosn@gmail.com","avatar":null},"body":"Hello Everybody,\n\nHope this is the right place to send this bug report.\n\nIt just appeared today, last time I've made a successful commit was 3 days\nago. Now every commit, in no matter which repository I have (I've tried old\nones, cloned today, github ones etc) fails with the following message.\n\n[master 09-mapas] git commit\nfatal: could not read 'template': No such file or directory\n\nIt happens both with the stock git binary that came with Xcode 4.1 on OSX\nLion (1.7.4.4) [/usr/local/bin/git], and the homebrew version (1.7.6)\n[/usr/bin/git].\n\nI haven't changed much of my system during those days besides installing\nmacports and tinycdb (with ports). Don't see any close relation, both\ntinycdb and macports were removed.\n\nCuriously, it works well with the git binary that comes with Github.app for\nmac, whose version is 1.7.4.\n\n\n\n--\nView this message in context: http://git.661346.n2.nabble.com/BUG-Git-won-t-commit-tp6681082p6681082.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"173408","messageId":"1313169648463-6681098.post@n2.nabble.com","threadId":"28082","inReplyTo":"1313169225059-6681082.post@n2.nabble.com","subject":"Re: [BUG] Git won't commit","fromName":"Fabricio Nascimento","fromEmail":"fabriciosn@gmail.com","sentAt":"2011-08-12T17:20:48Z","receivedAt":"2011-08-12T17:20:48Z","isPatch":false,"sender":{"key":"fabriciosn@gmail.com","avatar":null},"body":"I have installed an stock version of git 1.7.6 from here, and I've got the\nsame problem.\n\nhttp://code.google.com/p/git-osx-installer/downloads/detail?name=git-1.7.6-x86_64-snow-leopard.dmg&can=3&q=\n\nI've forgot to mention but I've updated all homebrew formulas during this\npast days too, so it might be that previously I had a homebrew version of\ngit whose version where below or equal 1.4, and that something changed\ncausing this error now. \n\n--\nView this message in context: http://git.661346.n2.nabble.com/BUG-Git-won-t-commit-tp6681082p6681098.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"173410","messageId":"CAMOZ1BtxNSnncEJ6frEY0STgfS478krkpxXStP401WLPovb2Gw@mail.gmail.com","threadId":"28082","inReplyTo":"1313169225059-6681082.post@n2.nabble.com","subject":"Re: [BUG] Git won't commit","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2011-08-12T17:30:21Z","receivedAt":"2011-08-12T17:30:21Z","isPatch":false,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"On Fri, Aug 12, 2011 at 17:13, Fabricio Nascimento <fabriciosn@gmail.com> wrote:\n> Hello Everybody,\n>\n> Hope this is the right place to send this bug report.\n>\n> It just appeared today, last time I've made a successful commit was 3 days\n> ago. Now every commit, in no matter which repository I have (I've tried old\n> ones, cloned today, github ones etc) fails with the following message.\n>\n> [master 09-mapas] git commit\n> fatal: could not read 'template': No such file or directory\n>\n> It happens both with the stock git binary that came with Xcode 4.1 on OSX\n> Lion (1.7.4.4) [/usr/local/bin/git], and the homebrew version (1.7.6)\n> [/usr/bin/git].\n>\n> I haven't changed much of my system during those days besides installing\n> macports and tinycdb (with ports). Don't see any close relation, both\n> tinycdb and macports were removed.\n>\n> Curiously, it works well with the git binary that comes with Github.app for\n> mac, whose version is 1.7.4.\n\nWhat does the following output for you?\n\n  git config --get commit.template\n"},{"id":"173465","messageId":"CAMOZ1Bu3AoQb330hkL+8hDTCvKX+amRfPE3PBxDHUZR17N344Q@mail.gmail.com","threadId":"28082","inReplyTo":"CAAC=0R66j43CqpaxXskAwHsitvRFwy7DsjguNPm+sPa4YmTWqw@mail.gmail.com","subject":"Re: [BUG] Git won't commit","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2011-08-13T20:56:04Z","receivedAt":"2011-08-13T20:56:04Z","isPatch":false,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"2011/8/12 Fabrício Nascimento <fabricio@tailorbirds.com.br>:\n> Where git is the 1.7.6 that does not work, and git2 is the 1.7.4 that does\n> work.\n> [master 09-mapas] git config --get commit.template\n> template\n> [master 09-mapas] git2 config --get commit.template\n> template\n\nDid you get this problem figured out? If not, run:\n\n  git config --unset commit.template\n\nand then try making a commit as usual.\n\nAs for why one version works but the other does not, I'm not sure.\n"},{"id":"173467","messageId":"20110813211852.GA17228@elie.gateway.2wire.net","threadId":"28082","inReplyTo":"CAMOZ1Bu3AoQb330hkL+8hDTCvKX+amRfPE3PBxDHUZR17N344Q@mail.gmail.com","subject":"Re: [BUG] Git won't commit","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-08-13T21:18:52Z","receivedAt":"2011-08-13T21:18:52Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nMichael Witten wrote:\n\n> As for why one version works but the other does not, I'm not sure.\n\nIt's my fault, I'm afraid:\n\n $ git log v1.7.4..v1.7.4.4 --grep=template --no-merges\n commit 2140b140\n Author: Jonathan Nieder <jrnieder@gmail.com>\n Date:   Fri Feb 25 03:07:57 2011 -0600\n\n     commit: error out for missing commit message template\n\n     When \"git commit\" was rewritten in C (v1.5.4-rc0~78^2~30,\n     2007-11-08), a subtle bug in --template was introduced.  If the\n     file named by a --template parameter is missing, previously git\n     would error out with a message:\n\n         Commit template file does not exist.\n\n     but in the C version the --template parameter gets ignored and\n     the default template is used.\n\n     t7500 has two tests for this case which would have caught it, except\n     that with the default $EDITOR, the commit message template is left\n     unmodified, causing 'git commit' to error out and the test to\n     succeed.\n\n     Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n     Signed-off-by: Junio C Hamano <gitster@pobox.com>\n\nFabricio, do you remember what you were trying to do when the\n\"[commit] template\" configuration got set?  Currently the error\nmessage says\n\n\tfatal: could not read '<path>'\n\nwhere <path> is the configured template filename; probably this\nshould be changed to mention (1) that the file we were expecting to\nfind is a commit message template and (2) whether we got it from the\ncommandline or configuration.\n\nWhat I'm trying to figure out is whether other people were relying on\nthe accidental \"optional template\" behavior or if there is some case\nwhere it is more useful.  If so, it should be brought back.\n"},{"id":"173831","messageId":"20110819050714.GA21697@elie.gateway.2wire.net","threadId":"28082","inReplyTo":"CAAC=0R5CpJx1QOKYJDs0_ksEdyYG95fSAo3U3eU536YW=M84MA@mail.gmail.com","subject":"[PATCH] commit: clarify \"could not read 'template'\" message","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-08-19T05:07:33Z","receivedAt":"2011-08-19T05:07:33Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Fabrício noticed that when the \"[commit] template\" configuration is\nmisconfigured to point to a nonexistent file, ever since v1.7.4.2\n(see 2140b140, 2011-02-25), \"git commit\" fails in a seemingly\nmysterious way:\n\n\t$ git commit\n\tfatal: could not read 'template': No such file or directory\n\nIn olden times, the message instead said\n\n\tCommit template file does not exist.\n\nwhich makes it a little clearer that the --template option or\ncorresponding configuration item is being misused.  Let's move a\nlittle in that direction, by saying \"could not read commit message\ntemplate 'template'\".\n\nNote that the origin of the setting in the motivating ~/.gitignore is\nstill unknown.  Depending on the answer, it might be nice to start\nignoring nonexistent commit templates again; if the problem is\nwidespread, hopefully there will be more reports soon.\n\nNoticed-by: Fabrício Nascimento <fabriciosn@gmail.com>\nAnalysis-by: Michael Witten <mfwitten@gmail.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nHi again,\n\nFabrício Nascimento wrote:\n\n> I have no idea what could have set the variable. Time Machine tells me the\n> only changes on the .gitconfig file happened on August 12th, the day I've\n> flagged the bug. I know I've made a brew upgrade on all my packages (that\n> included git) the night before, and then the bug appeared the day after. I\n> should have done only git stats, commit, pull and push.\n\nThanks for these details.  I looked through the packages in brew, but no\nobvious clues.\n\nAt least the problem could have been easier to debug.  How about this\npatch, to start?\n\n builtin/commit.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex cb738574..d029ec03 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -703,7 +703,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\thook_arg1 = \"squash\";\n \t} else if (template_file) {\n \t\tif (strbuf_read_file(&sb, template_file, 0) < 0)\n-\t\t\tdie_errno(_(\"could not read '%s'\"), template_file);\n+\t\t\tdie_errno(_(\"could not read commit message template '%s'\"),\n+\t\t\t\t  template_file);\n \t\thook_arg1 = \"template\";\n \t\tclean_message_contents = 0;\n \t}\n-- \n1.7.6\n"},{"id":"173836","messageId":"7v4o1e544m.fsf@alter.siamese.dyndns.org","threadId":"28082","inReplyTo":"20110819050714.GA21697@elie.gateway.2wire.net","subject":"Re: [PATCH] commit: clarify \"could not read 'template'\" message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-08-19T06:04:09Z","receivedAt":"2011-08-19T06:04:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> At least the problem could have been easier to debug.  How about this\n> patch, to start?\n\nIt is a good start, but at this point do we know where the template_file\ncame from? It does not seem rocket surgery to update git_commit_config()\nso that it stores the value taken from configuration file in a separate\nvariable so that we can tell the difference in order to tweak the message.\n\nAre there only these three kinds of \"pathname\" variables that can be\nconfigured?\n\n - Those to be always used (it is an error if missing);\n - Those to be always used (the calling code creat(2)s if missing); and\n - Those to be used only if already exist (otherwise ignored).\n\nIf so, a good way forward might be to update git_config_pathname() and\ntell it which kind of path we are talking about. For the first and the\nthird kind, it would (after ~ expansion and other magic) stat the string\nand error out for the first kind and return NULL for the third kind. For\nthe second kind, we do not need to do anything special. We may need to\ndistinguish between files and dirs, so we might need 6 variations, not\njust 3, but that is a minor implementation detail.\n\nThis is one of the reasons that I tend to resist applying patches that add\nuseless configuration variables \"just because it seems useful\".\n\n>  builtin/commit.c |    3 ++-\n>  1 files changed, 2 insertions(+), 1 deletions(-)\n>\n> diff --git a/builtin/commit.c b/builtin/commit.c\n> index cb738574..d029ec03 100644\n> --- a/builtin/commit.c\n> +++ b/builtin/commit.c\n> @@ -703,7 +703,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n>  \t\thook_arg1 = \"squash\";\n>  \t} else if (template_file) {\n>  \t\tif (strbuf_read_file(&sb, template_file, 0) < 0)\n> -\t\t\tdie_errno(_(\"could not read '%s'\"), template_file);\n> +\t\t\tdie_errno(_(\"could not read commit message template '%s'\"),\n> +\t\t\t\t  template_file);\n>  \t\thook_arg1 = \"template\";\n>  \t\tclean_message_contents = 0;\n>  \t}\n"}]}