Re: [git-users] How to find out (fast) if a commit is on a _specific_ branch

2014-05-30 Thread Dale R. Worley
> From: Paul Smith 

> I know about "git branch --contains" but that checks ALL the branches to
> see if the commit is on any them, and with the number of branches we
> have that takes a non-trivial amount of time.  Since this is in a push
> hook I really need it to be as fast as possible, and it seems to me that
> if I could ask for just a specific branch, "is this commit on this
> specific branch" rather than "what are all the branches this commit is
> on", it would be faster.

I think this works:

$ git-rev-list HEAD..commit

The output will be empty if commit is an ancestor of HEAD and
non-empty if not (due to the definition of '..').

Dale

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[git-users] How to find out (fast) if a commit is on a _specific_ branch

2014-05-29 Thread Paul Smith
I need to write a hook that will allow merge commits ONLY if the merge
is coming from a specific branch.

I know about "git branch --contains" but that checks ALL the branches to
see if the commit is on any them, and with the number of branches we
have that takes a non-trivial amount of time.  Since this is in a push
hook I really need it to be as fast as possible, and it seems to me that
if I could ask for just a specific branch, "is this commit on this
specific branch" rather than "what are all the branches this commit is
on", it would be faster.

But I can't quite find a good way to do that.  I mean, I can list the
entire history of the branch then search it by hand, but that seems
inefficient as well.

Is there some plumbing command or similar that will check if a specific
commit exists a specific branch, fast?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.