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

Fwd: Discovering the new parents in commit hooks

From
SDscott douglass <scott0douglass@gmail.com>
Date
Jul 5, 2019, 22:01 UTC
Message-ID
<CAOqHT5K_JZDZ1agEL4ceVdYY=4YYO715v+j_bNbJWOoV=KNqQQ@mail.gmail.com>
In-Reply-To
<CAOqHT5KUFOY9g-PDDq=PaXdqS41ZGYGMAUuBkU-UrPiSumqhTQ@mail.gmail.com>
Hi,

I’d like to be able to discover the new parents-to-be SHA-1s during the hooks that run before a commit*. Essentially I’d like be able to distinguish the ‘git commit’ case from ‘git commit —amend’. Is there already a way to do this that I have overlooked? (I’ve read ‘man githooks’ and searched the wiki and various other places.)

If not, I would propose that perhaps the hooks could be passed a GIT_PARENTS (or perhaps GIT_NEW_PARENTS) environment variable which in the ‘not amend’ case would contain the SHA-1 for HEAD and MERGE_HEAD (if appropriate) and in the ‘—amend' case would contain HEAD^@ (all of the parents of HEAD).

[*] Specifically, it seems a useful thing to be able to find out in these hooks: applypatch-msg, pre-applypatch, commit-msg, prepare-commit-msg, commit-msg

Thanks.
Next: brian m. carlson
Message 1 of 2 in “Fwd: Discovering the new parents in commit hooks”
  1. scott douglassJul 5, 2019
  2. brian m. carlsonJul 8, 2019

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.