git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / Atom feed
* Fwd: Discovering the new parents in commit hooks
       [not found] <CAOqHT5KUFOY9g-PDDq=PaXdqS41ZGYGMAUuBkU-UrPiSumqhTQ@mail.gmail.com>
@ 2019-07-05 22:01 ` scott douglass
  2019-07-08 20:09   ` brian m. carlson
  0 siblings, 1 reply; 2+ messages in thread
From: scott douglass @ 2019-07-05 22:01 UTC (permalink / raw)
  To: git

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Fwd: Discovering the new parents in commit hooks
  2019-07-05 22:01 ` Fwd: Discovering the new parents in commit hooks scott douglass
@ 2019-07-08 20:09   ` brian m. carlson
  0 siblings, 0 replies; 2+ messages in thread
From: brian m. carlson @ 2019-07-08 20:09 UTC (permalink / raw)
  To: scott douglass; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 1404 bytes --]

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 868 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAOqHT5KUFOY9g-PDDq=PaXdqS41ZGYGMAUuBkU-UrPiSumqhTQ@mail.gmail.com>
2019-07-05 22:01 ` Fwd: Discovering the new parents in commit hooks scott douglass
2019-07-08 20:09   ` brian m. carlson

git@vger.kernel.org list mirror (unofficial, one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox