{"thread":{"id":"51438","subject":"Fwd: Discovering the new parents in commit hooks","startedAt":"2019-07-05T22:02:12Z","lastAt":"2019-07-08T20:09:14Z","messageCount":2,"participants":["scott douglass","brian m. carlson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"378656","messageId":"CAOqHT5K_JZDZ1agEL4ceVdYY=4YYO715v+j_bNbJWOoV=KNqQQ@mail.gmail.com","threadId":"51438","inReplyTo":"CAOqHT5KUFOY9g-PDDq=PaXdqS41ZGYGMAUuBkU-UrPiSumqhTQ@mail.gmail.com","subject":"Fwd: Discovering the new parents in commit hooks","fromName":"scott douglass","fromEmail":"scott0douglass@gmail.com","sentAt":"2019-07-05T22:01:59Z","receivedAt":"2019-07-05T22:02:12Z","isPatch":false,"sender":{"key":"scott0douglass@gmail.com","avatar":null},"body":"Hi,\n\nI’d like to be able to discover the new parents-to-be SHA-1s during\nthe hooks that run before a commit*.  Essentially I’d like be able to\ndistinguish the ‘git commit’ case from ‘git commit —amend’. Is there\nalready a way to do this that I have overlooked? (I’ve read ‘man\ngithooks’ and searched the wiki and various other places.)\n\nIf not, I would propose that perhaps the hooks could be passed a\nGIT_PARENTS (or perhaps GIT_NEW_PARENTS) environment variable which in\nthe ‘not amend’ case would contain the SHA-1 for HEAD and MERGE_HEAD\n(if appropriate) and in the ‘—amend' case would contain HEAD^@ (all of\nthe parents of HEAD).\n\n[*] Specifically, it seems a useful thing to be able to find out in\nthese hooks:  applypatch-msg, pre-applypatch, commit-msg,\nprepare-commit-msg, commit-msg\n\nThanks.\n"},{"id":"378704","messageId":"20190708200906.GF9224@genre.crustytoothpaste.net","threadId":"51438","inReplyTo":"CAOqHT5K_JZDZ1agEL4ceVdYY=4YYO715v+j_bNbJWOoV=KNqQQ@mail.gmail.com","subject":"Re: Fwd: Discovering the new parents in commit hooks","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-07-08T20:09:06Z","receivedAt":"2019-07-08T20:09:14Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2019-07-05 at 22:01:59, scott douglass wrote:\n> Hi,\n> \n> I’d like to be able to discover the new parents-to-be SHA-1s during\n> the hooks that run before a commit*.  Essentially I’d like be able to\n> distinguish the ‘git commit’ case from ‘git commit —amend’. Is there\n> already a way to do this that I have overlooked? (I’ve read ‘man\n> githooks’ and searched the wiki and various other places.)\n\nI'm not aware of a way to distinguish this currently, although I agree\nhaving a way would be valuable. There are of course heuristic ways, but\nthey can be fooled.\n\n> If not, I would propose that perhaps the hooks could be passed a\n> GIT_PARENTS (or perhaps GIT_NEW_PARENTS) environment variable which in\n> the ‘not amend’ case would contain the SHA-1 for HEAD and MERGE_HEAD\n> (if appropriate) and in the ‘—amend' case would contain HEAD^@ (all of\n> the parents of HEAD).\n\nI think we'd probably skip such functionality in favor of exposing\nwhether a commit is to be amended or not and let you script the parents\nyourself.\n\nThere are a lot of cases where one might want to know whether a commit\nwas amended, but knowing that, you can determine the parents and\nanything else without much difficulty, so the amended option seems like\nthe more general feature to implement.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"}]}