Re: git commit -v does not removes the patch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 20, 2008 at 02:09:28PM +0100, SZEDER Gábor wrote:

> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux