git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Determining if two commits are on a separate branch

From
SBSanti Béjar <sbejar@gmail.com>
Date
Jun 27, 2008, 15:17 UTC
Message-ID
<8aa486160806270817j1cab369eyc2d74996e9a3286f@mail.gmail.com>
In-Reply-To
<308083c30806270755t4316be67u1f468b51bf475d28@mail.gmail.com>

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
Previous: Michael J Gruber
Message 3 of 3 in “Determining if two commits are on a separate branch”
  1. Adr3nal D0SJun 27, 2008
  2. Michael J GruberJun 27, 2008
  3. Santi BéjarJun 27, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.