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

Re: [PATCH] git-commit: add a prepare-commit-msg hook

From
Paolo Bonzini <bonzini@gnu.org>
Date
Jan 19, 2008, 09:32 UTC
Message-ID
<4791C3A8.7000308@gnu.org>
In-Reply-To
<7vbq7ibxhh.fsf@gitster.siamese.dyndns.org>
> On the other hand, if you want to always cause an action before
> running a git opeation locally, you do not have to have a hook.
> You can just prepare such a message based on GNU ChangeLog and
> then run git-commit with -F, both inside your wrapper.
I see two other possibilities:
1) Would you prefer allowing to run a command by setting commit.template 
to something starting with an exclamation mark, i.e. something like 
"!git diff --cached --name-status -r"?
2) The pre-commit could receive a file name on the command line.  If it 
creates that file, it would be used as a template for the commit 
message.  The default implementation of pre-commit could include, 
commented out, a reimplementation of prepare_log_message.  I like this 
the least.
3) Consider that the patch, as I implemented it, does not act solely on 
local data, because the index could be modified by the pre-commit hook. 
  This possibility is contemplated explicitly in builtin-commit.c:
         /*
          * Re-read the index as pre-commit hook could have updated it,
          * and write it out as a tree.
          */
Paolo
Previous: Junio C HamanoNext: Johannes Schindelin
Message 13 of 23 in “git-commit: add a prepare-commit-msg hook”
  1. git-commit: add a prepare-commit-msg hookPaolo Bonzini, Jan 18, 2008
  2. Johannes SchindelinJan 18, 2008
  3. Paolo BonziniJan 18, 2008
  4. Johannes SchindelinJan 18, 2008
  5. Paolo BonziniJan 18, 2008
  6. Johannes SchindelinJan 18, 2008
  7. Paolo BonziniJan 18, 2008
  8. Benoit SigoureJan 18, 2008
  9. Alex RiesenJan 18, 2008
  10. Paolo BonziniJan 18, 2008
  11. Alex RiesenJan 18, 2008
  12. Junio C HamanoJan 18, 2008
  13. Paolo BonziniJan 19, 2008
  14. Johannes SchindelinJan 19, 2008
  15. Benoit SigoureJan 19, 2008
  16. Paolo BonziniJan 19, 2008
  17. Junio C HamanoJan 20, 2008
  18. Paolo BonziniJan 21, 2008
  19. Johannes SchindelinJan 21, 2008
  20. Paolo BonziniJan 21, 2008
  21. Johannes SchindelinJan 21, 2008
  22. Paolo BonziniJan 21, 2008
  23. Junio C HamanoJan 21, 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.