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

Re: Git potential bug with fork-point

From
John Keeping <john@keeping.me.uk>
Date
Nov 7, 2015, 16:01 UTC
Message-ID
<20151107160120.GG19802@serenity.lan>
In-Reply-To
<a3db24afbc3247c3a8466c8d7ce0c785@SEGOTNC5113-N2.vcn.ds.volvo.net>
On Mon, Nov 02, 2015 at 06:27:52AM +0000, Stenberg Jim (2) wrote:
Show 14 quoted lines
> My problem:
> "Git merge-base --fork-point" acts unexpected when I refer to remote
> branches (typically "origin/".) With unexpected I mean that if I swap
> the position of the two references that the function takes as argument
> I get different results.  I highly suspect that this isn't a feature
> but a bug, or maybe I'm using the function in a way it wasn't intended
> to be used.
> I don't need you to fix it (swapping the arguments solves it), I just
> want you to be aware of it.
> 
> History & procedure:
> When  I was working on my automatic build script I came across the
> oddity that "Git merge-base --fork-point" behaved differently
> depending on the order in which the two references are passed.
I think this is expected.  The documentation for `--fork-point` says:
	git merge-base --fork-point <ref> [<commit>]
	Find the point at which a branch (or any history that leads to
	<commit>) forked from another branch (or any reference) <ref>.
	This does not just look for the common ancestor of the two
	commits, but also takes into account the reflog of <ref> to see
	if the history leading to <commit> forked from an earlier
	incarnation of the branch <ref> (see discussion on this mode
	below).

Clearly the order of the arguments matters because the reflog is only inspected for the `<ref>` argument. Since the reflog is involved this also means that the results are likely to be different between separate copies of the same repository.

I suspect you do not want to be using `--fork-point` in your build script; it is intended to help `git rebase` recover from history being rewritten and if you do not need that behaviour you are probably better off using the normal `git merge-base <commit> <commit>` mode, which should give consistent results regardless of the order of the commits.

Previous: Stenberg Jim (2)
Message 2 of 2 in “Git potential bug with fork-point”
  1. Stenberg Jim (2)Nov 2, 2015
  2. John KeepingNov 7, 2015

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.