{"thread":{"id":"47459","subject":"commit-msg hook possible bad behavior with -F <file>","startedAt":"2017-12-18T16:44:19Z","lastAt":"2017-12-18T21:34:58Z","messageCount":3,"participants":["Seth Raymond","Eric Sunshine"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"334970","messageId":"CAJ4+5mHMD+yW1ZDD6KJSnMtyygLUGiHzNPgPDZUi7+KUvOczkg@mail.gmail.com","threadId":"47459","inReplyTo":null,"subject":"commit-msg hook possible bad behavior with -F <file>","fromName":"Seth Raymond","fromEmail":"seth.c.raymond@gmail.com","sentAt":"2017-12-18T16:43:38Z","receivedAt":"2017-12-18T16:44:19Z","isPatch":false,"sender":{"key":"seth.c.raymond@gmail.com","avatar":null},"body":"If a commit is invoked with -F <file>, indicating that the commit\nmessage should be read from an existing file, the the\nprepare-commit-msg and commit-msg hooks do not operate on <file>. The\nfirst argument to the hook is always <git_repo>/COMMIT_EDITMSG, rather\nthan <file>.\n\nAm I wrong in this line of thinking?\n\n-Seth\n"},{"id":"334980","messageId":"CAPig+cTmRiSfY9+DsvEB7X_cL4AiAmq0FUb-CoDyc3HNDJLtow@mail.gmail.com","threadId":"47459","inReplyTo":"CAJ4+5mHMD+yW1ZDD6KJSnMtyygLUGiHzNPgPDZUi7+KUvOczkg@mail.gmail.com","subject":"Re: commit-msg hook possible bad behavior with -F <file>","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2017-12-18T18:31:10Z","receivedAt":"2017-12-18T18:31:22Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Dec 18, 2017 at 11:43 AM, Seth Raymond <seth.c.raymond@gmail.com> wrote:\n> If a commit is invoked with -F <file>, indicating that the commit\n> message should be read from an existing file, the the\n> prepare-commit-msg and commit-msg hooks do not operate on <file>. The\n> first argument to the hook is always <git_repo>/COMMIT_EDITMSG, rather\n> than <file>.\n>\n> Am I wrong in this line of thinking?\n\nThe content of <file> gets copied into COMMIT_EDITMSG, so the hook\ndoes see the supplied message, as expected. Given that the hook is\nallowed to edit the message, it makes sense that it works on\nCOMMIT_EDITMSG rather than on <file> directly.\n"},{"id":"334991","messageId":"CAJ4+5mHt-oJTYEeRUeTynbZ5MRNT_CXWQSHoTUP_i-gWeqvmuA@mail.gmail.com","threadId":"47459","inReplyTo":"CAPig+cTmRiSfY9+DsvEB7X_cL4AiAmq0FUb-CoDyc3HNDJLtow@mail.gmail.com","subject":"Re: commit-msg hook possible bad behavior with -F <file>","fromName":"Seth Raymond","fromEmail":"seth.c.raymond@gmail.com","sentAt":"2017-12-18T21:34:23Z","receivedAt":"2017-12-18T21:34:58Z","isPatch":false,"sender":{"key":"seth.c.raymond@gmail.com","avatar":null},"body":"I see that line of thinking, and agree that it makes sense. I'm having\nproblems with an IDE (Qt Creator) and I think I know where the problem\nlies now. I believe Qt Creator doesn't actually call git commit until\nafter the user generates a message in the message box, meaning my\nprepare-commit-msg hook is run after I've already written a message\nout to <file>.\n\nI don't think there's a fix to it due to the IDE's seemingly-poor\nimplementation of the git plugin. Thanks for the clarification!\n\nOn Mon, Dec 18, 2017 at 1:31 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> On Mon, Dec 18, 2017 at 11:43 AM, Seth Raymond <seth.c.raymond@gmail.com> wrote:\n>> If a commit is invoked with -F <file>, indicating that the commit\n>> message should be read from an existing file, the the\n>> prepare-commit-msg and commit-msg hooks do not operate on <file>. The\n>> first argument to the hook is always <git_repo>/COMMIT_EDITMSG, rather\n>> than <file>.\n>>\n>> Am I wrong in this line of thinking?\n>\n> The content of <file> gets copied into COMMIT_EDITMSG, so the hook\n> does see the supplied message, as expected. Given that the hook is\n> allowed to edit the message, it makes sense that it works on\n> COMMIT_EDITMSG rather than on <file> directly.\n"}]}