git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: SZEDER GáborNext: SZEDER Gábor
Message 19 of 22 in “git commit -v does not removes the patch”
  1. Santi BéjarNov 10, 2008
  2. Jeff KingNov 10, 2008
  3. Santi BéjarNov 10, 2008
  4. Junio C HamanoNov 10, 2008
  5. Jeff KingNov 11, 2008
  6. Santi BéjarNov 11, 2008
  7. Jeff KingNov 11, 2008
  8. Santi BéjarNov 11, 2008
  9. Junio C HamanoNov 11, 2008
  10. Jeff KingNov 12, 2008
  11. 1/5 define empty tree sha1 as a macroJeff King, Nov 12, 2008
  12. 2/5 wt-status: refactor initial commit printingJeff King, Nov 12, 2008
  13. 3/5 status: show "-v" diff even for initial commitJeff King, Nov 12, 2008
  14. 4/5 commit: loosen pattern for matching "-v" diffJeff King, Nov 12, 2008
  15. 5/5 commit: only strip diff from message in verbose modeJeff King, Nov 12, 2008
  16. Jeff KingNov 12, 2008
  17. Junio C HamanoNov 13, 2008
  18. SZEDER GáborNov 20, 2008
  19. Jeff KingNov 20, 2008
  20. SZEDER GáborNov 22, 2008
  21. Jeff KingNov 22, 2008
  22. Junio C HamanoNov 22, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.