Re: Fwd: Discovering the new parents in commit hooks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2019-07-05 at 22:01:59, scott douglass wrote:
> 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.)

I'm not aware of a way to distinguish this currently, although I agree
having a way would be valuable. There are of course heuristic ways, but
they can be fooled.

> 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).

I think we'd probably skip such functionality in favor of exposing
whether a commit is to be amended or not and let you script the parents
yourself.

There are a lot of cases where one might want to know whether a commit
was amended, but knowing that, you can determine the parents and
anything else without much difficulty, so the amended option seems like
the more general feature to implement.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux