Re: git commit -v does not removes the patch
- From
Jeff King <peff@peff.net>
- Date
- Nov 20, 2008, 15:20 UTC
- Message-ID
- <20081120152015.GA6283@coredump.intra.peff.net>
- In-Reply-To
- <20081120130851.GA17608@neumann>
On Thu, Nov 20, 2008 at 02:09:28PM +0100, SZEDER Gábor wrote:
Show 7 quoted lines
> I always want to see the diff while editing a commit message, even if > it's the commit message of a merge, a revert, a squash in rebase. > Since these commands do not have an option equivalent to 'git commit > -v', I wrote a little prepare-commit-msg hook to always append the > appropriate diff to the end of the appropriate commit message file. > This worked pretty well for the last couple of months, until 5/5 got > into maint.
Hmm. I am sad that this change has broken somebody's existing workflow. OTOH, I'm not convinced that workflow wasn't a little crazy to begin with, depending on this undocumented munging.
> So, what is the/is there a preferred way to always include the diff in > the commit message template and get it removed automatically? Are > there any workarounds other than revert that commit locally?
How about:
$ cat .git/hooks/prepare-commit-msg
#!/bin/sh
git diff --cached >>"$1" $ cat .git/hooks/commit-msg
#!/bin/sh
sed -i '/^diff --git/Q' "$1"which is more or less the original behavior. The only downside I see is that "--no-verify" will turn off the commit-msg hook, but not the prepare-commit-msg hook.
-Peff