Git development
 help / color / mirror / Atom feed
From: Michael J Gruber <michaeljgruber+gmane@fastmail.fm>
To: git@vger.kernel.org
Subject: Re: Determining if two commits are on a separate branch
Date: Fri, 27 Jun 2008 17:13:29 +0200	[thread overview]
Message-ID: <g4302r$ms9$1@ger.gmane.org> (raw)
In-Reply-To: <308083c30806270755t4316be67u1f468b51bf475d28@mail.gmail.com>

Adr3nal D0S venit, vidit, dixit 27.06.2008 16:55:
> We are making extensive use of submodules at work and we have created
> a number of extra scripts to simplify our usage.  For example, there
> is git-rstatus, which recursively reports status of all submodules.
> 
> I am working on another script to check whether or not a change to any
> submodules jump branches.  If we have commits like this:
> 
> A--B--C
>    \--D
> 
> I don't care if a submodule moves from A to C or B to C, but I do care
> if a commit of the super-project would cause a jump from D to C or
> revert from C to B, effectively dropping previously committed code on
> the floor.
> 
> So, is there a "correct" or "best" way to determine if one commit's
> SHA follows directly from another's SHA in the commit history?

"Directly" as in "is child of", or as in "connected by the DAG"?

"git rev-list C..B" lists all commits which are not in C but in B. If 
this list is empty then B is "contained" in C. This is how you can test 
for being connected by the DAG. For the graph above, all of the 
following refspecs would return an empty list, indicating connectedness:

C..B
C..A
B..A
D..B
D..A

Are those the "good ones" in your case? Then you know how to test for 
the bad guys ;)

Michael

  reply	other threads:[~2008-06-27 15:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-27 14:55 Determining if two commits are on a separate branch Adr3nal D0S
2008-06-27 15:13 ` Michael J Gruber [this message]
2008-06-27 15:17 ` Santi Béjar

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='g4302r$ms9$1@ger.gmane.org' \
    --to=michaeljgruber+gmane@fastmail.fm \
    --cc=git@vger.kernel.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