git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Brown <davidb@codeaurora.org>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: Brian Foster <brian.foster@maxim-ic.com>,
	git mailing list <git@vger.kernel.org>
Subject: Re: [Q] Determing if a commit is reachable from the HEAD ?
Date: Fri, 20 Jan 2012 10:06:20 -0800	[thread overview]
Message-ID: <20120120180620.GA8504@codeaurora.org> (raw)
In-Reply-To: <m2ehuu8nrt.fsf@igel.home>

On Fri, Jan 20, 2012 at 03:13:58PM +0100, Andreas Schwab wrote:
> Brian Foster <brian.foster@maxim-ic.com> writes:
> 
> >  In a script, how can I determine commit Y is reachable
> >  from the current HEAD ?
> 
> test $(git merge-base HEAD Y) = $(git rev-parse Y)

Almost.  It works as long as there is only one merge base.  You really
need to check if $(git rev-parse Y) is one of $(git merge-base --all
HEAD Y)

if HEAD is a named branch, you can do

  git name-rev --refs=refs/heads/branchname Y

which will give you Y relative to branchname if it is contained within
it.

David

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

  reply	other threads:[~2012-01-20 18:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-20 13:33 [Q] Determing if a commit is reachable from the HEAD ? Brian Foster
2012-01-20 14:13 ` Andreas Schwab
2012-01-20 18:06   ` David Brown [this message]
2012-01-20 19:18     ` Junio C Hamano
2012-01-20 23:33       ` David Brown
2012-01-21  0:04         ` Junio C Hamano
2012-01-21  4:58           ` David Brown
2012-01-20 22:50 ` Sitaram Chamarty
2012-01-23  9:20   ` Brian Foster
2012-01-23 16:09     ` Junio C Hamano
2012-01-24  8:16       ` Brian Foster
2012-01-24  8:56       ` Brian Foster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120120180620.GA8504@codeaurora.org \
    --to=davidb@codeaurora.org \
    --cc=brian.foster@maxim-ic.com \
    --cc=git@vger.kernel.org \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).