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

Re: Getting an actuallt useful merge base?

From
Elijah Newren <newren@gmail.com>
Date
Feb 25, 2021, 20:16 UTC
Message-ID
<CABPp-BFDmDvaUq4gNBQvBa1AgD8RKmcwHLM-cD+_qeLG1f7FSg@mail.gmail.com>
In-Reply-To
<xmqqv9afud75.fsf@gitster.g>
On Thu, Feb 25, 2021 at 12:04 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 33 quoted lines
>
> Elijah Newren <newren@gmail.com> writes:
>
> >> It's like this
> >>
> >> T
> >> ----o----o----o----o----o----o----o----o----o----o----o----o---(t)---o----o----
> >>      \             \     \                                      \\\
> >>       \             \     \                                      \\\
> >>        \             \     \                                      \\\
> >>         \        o----o----o\̶---o---(s)---o----o----o----o----o----o\̶\̶-(a)
> >>          \      /            \      /                                \\
> >> S+T  o----o----o----o----o----o----o----o----o----o----o----o----o----o\̶--(b)
> >>     /                                       /                           \
> >> ---o----o----o----o----o----o----o----o----o----o----o----o----o----o----o---(m)
> >>
> >> So (t) is common ancestor for (a) and (b) that merge-base reports but it is
> >> only ancestor for files in set T, and does not have files from set S at all.
> >> The common ancestor I am insterested in is (s) which is merge base for both
> >> sets of files.
> >
> > From git-merge-base(1):
> >
> > "When the history involves criss-cross merges, there can be more than
> > one best common ancestor for two commits...When the --all option is
> > not given, it is unspecified which best one is output."
> >
> > Perhaps you want to specify --all to git merge-base, and then perform
> > additional checks on the output to select one yourself?
>
> Ignore me, as it is likely I am just confused, but if we are merging
> (a) and (b), I do not think (s) could be usable as a merge base; it
> may be an ancestor of (a) but is not an ancestor of (b), no?

No, I think you're totally right; I was looking at (t) and (a) rather than (a) and (b) for some reason. As you point out, (s) isn't a merge-base of (a) and (b), so it wouldn't be printed by `git merge-base --all` either.

Previous: Junio C HamanoNext: Michal Suchánek
Message 6 of 7 in “Getting an actuallt useful merge base?”
  1. Michal SuchánekFeb 24, 2021
  2. brian m. carlsonFeb 25, 2021
  3. Michal SuchánekFeb 25, 2021
  4. Elijah NewrenFeb 25, 2021
  5. Junio C HamanoFeb 25, 2021
  6. Elijah NewrenFeb 25, 2021
  7. Michal SuchánekFeb 25, 2021

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.