Git development
 help / color / mirror / Atom feed
* Determining if two commits are on a separate branch
@ 2008-06-27 14:55 Adr3nal D0S
  2008-06-27 15:13 ` Michael J Gruber
  2008-06-27 15:17 ` Santi Béjar
  0 siblings, 2 replies; 3+ messages in thread
From: Adr3nal D0S @ 2008-06-27 14:55 UTC (permalink / raw)
  To: git

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?

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

* Re: Determining if two commits are on a separate branch
  2008-06-27 14:55 Determining if two commits are on a separate branch Adr3nal D0S
@ 2008-06-27 15:13 ` Michael J Gruber
  2008-06-27 15:17 ` Santi Béjar
  1 sibling, 0 replies; 3+ messages in thread
From: Michael J Gruber @ 2008-06-27 15:13 UTC (permalink / raw)
  To: git

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

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

* Re: Determining if two commits are on a separate branch
  2008-06-27 14:55 Determining if two commits are on a separate branch Adr3nal D0S
  2008-06-27 15:13 ` Michael J Gruber
@ 2008-06-27 15:17 ` Santi Béjar
  1 sibling, 0 replies; 3+ messages in thread
From: Santi Béjar @ 2008-06-27 15:17 UTC (permalink / raw)
  To: Adr3nal D0S; +Cc: git

On Fri, Jun 27, 2008 at 16:55, Adr3nal D0S <adr3nald0s@gmail.com> wrote:
[...]

> 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?

You can compute the merge-base of these two commits and if the base is
one of them then it is a fast-forward.

For example, in git.git:

$ git merge-base origin/next origin/master
d54467b8c319571b5dc433b1f7e471c4b0f21caf

$ git rev-parse origin/next origin/master
3e7d305293ce93d00d5e0e6371311f7caa94f497
d54467b8c319571b5dc433b1f7e471c4b0f21caf

The merge-base is origin/master so it is an ancestor of origin/next.

HTH

Santi

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

end of thread, other threads:[~2008-06-27 15:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-27 14:55 Determining if two commits are on a separate branch Adr3nal D0S
2008-06-27 15:13 ` Michael J Gruber
2008-06-27 15:17 ` Santi Béjar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox