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

Passing original commit sha1(s) to prepare-commit-msg hook

From
MLMichel Lespinasse <walken@google.com>
Date
Jul 12, 2010, 10:49 UTC
Message-ID
<20100712104928.GA22305@google.com>
Hi,

I would like to use a prepare-commit-msg hook to automatically edit commit comments when a rebase is done, using information from the original commit. For example:

- Adding a commit message line indicating that the commit is a rebase of
  the original commit(s),
- Adding comments based on information stored in git notes on the original
  commit(s).

Currently (I'm using git 1.7.1) the old->new commit sha1 information is passed to the post-rewrite hook; however by then it is too late to do anything with commit messages. During "git rebase" the applypatch-msg hook is called with the original commit sha1 in .git/rebase-apply/original-commit, and during "git rebase -i" the prepare-commit-msg hook is called with current status of the rebase available in .git/rebase-merge/done; however relying on this would seem very fragile to me.

Would there be support for the idea of making the original commit sha1 information available to commit message hooks ? And if so, any advice how I should go about implementing this ? (I have little experience with git codebase).

Thanks,
-- 
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.
Message 1 of 1 in “Passing original commit sha1(s) to prepare-commit-msg hook”
  1. Michel LespinasseJul 12, 2010

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.