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

Re: More gitweb queries..

From
Junio C Hamano <junkio@cox.net>
Date
May 30, 2005, 17:54 UTC
Message-ID
<7v3bs438gc.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20050530121100.GS12290@cip.informatik.uni-erlangen.de>
>>>>> "TG" == Thomas Glanzmann <sithglan@stud.uni-erlangen.de> writes:

Disregard my last MB(A,A)===A thing. I really was not thinking, but in N-way merge I think rev-tree is your friend. Unlike merge-base which always does two heads at a time, rev-tree works N-way. You should be able to give many heads to it and have it help you figure out the ancestory relationship across them.

TG> But I still don't know how to handle the following scenario:

TG> /----- A TG> / TG> -GCA#1---GCA#2--- B TG> \---- C

TG> MERGES_HEAD = (A B C). I think the best way would be introduce a TG> temporary commit object otherwise C into AB merge would have merge_base TG> on the first GCA which is suboptimal and maybe wrong isn't it?

I think you can run the same algorithm for those pairwise ancestors and favor the less common ones. In the above drawing, you would first find out the three common pair-wise ancestors.

In your drawing,
    GCA(A,B) = GCA#1
    GCA(B,C) = GCA#2
    GCA(C,A) = GCA#1
    GCA(GCA#1,GCA#2) = GCA#1

Then you notice that GCA#2 is less common than GCA#1 (indeed GCA#1 is contained in GCA#2). So favoring the GCA#2, you do the merge pair that uses it as the merge base, namely B and C, first.

You scan the pairwise list again and find the pair that have not merged and uses the least common GCA as merge base and keep going. For the definition of less common, in many cases those GCA#n would not be related at all and cannot be compared by topology only, so you would probably need to come up with a heuristics to break such ties. Off the top of my head, you could compare commit timestamps (prefer younger), sum of commit chain length from GCA#n to its two head pairs (prefer shorter), sum of number of changed files from GCA#n to its two head pairs (prefer smaller).

TG> /----- A -------D---E TG> / / / TG> -GCA------GCA---- B / TG> \------- C

TG> Where D is a temporary COMMIT obeject to use the second GCA to merge C TG> with D and gets E.

Yes, if you ended up merging A and B first you would have something like that. I think you should not do that in the first place, and try to merge the "most recently diverged" pair first, like this:

         /----- A -----------Y
        /                   / 
     -GCA#1---GCA#2--- B --X
                 \---- C -/

If we are still talking about Octopus (Tripus in this case), you would not want to actually make a commit X. When you merge B and C, you consider that such a resulting tree resides at GCA#2 (merge base of B and C) for the purposes of further merge computation. Then you merge that resulting tree with A, using GCA#1.

Previous: Thomas GlanzmannNext: Thomas Glanzmann
Message 30 of 42 in “More gitweb queries..”
  1. Linus TorvaldsMay 27, 2005
  2. Thomas GlanzmannMay 27, 2005
  3. Junio C HamanoMay 27, 2005
  4. Thomas GlanzmannMay 27, 2005
  5. Junio C HamanoMay 27, 2005
  6. Linus TorvaldsMay 27, 2005
  7. Junio C HamanoMay 27, 2005
  8. Thomas GlanzmannMay 27, 2005
  9. Linus TorvaldsMay 27, 2005
  10. Junio C HamanoMay 27, 2005
  11. Thomas GlanzmannMay 27, 2005
  12. Junio C HamanoMay 27, 2005
  13. Linus TorvaldsMay 27, 2005
  14. Thomas GlanzmannMay 27, 2005
  15. Junio C HamanoMay 28, 2005
  16. Thomas GlanzmannMay 29, 2005
  17. Thomas GlanzmannMay 29, 2005
  18. Thomas GlanzmannMay 29, 2005
  19. Thomas GlanzmannMay 29, 2005
  20. Thomas GlanzmannMay 29, 2005
  21. Junio C HamanoMay 30, 2005
  22. Junio C HamanoMay 30, 2005
  23. Thomas GlanzmannMay 30, 2005
  24. Thomas GlanzmannMay 30, 2005
  25. Junio C HamanoMay 30, 2005
  26. Thomas GlanzmannMay 30, 2005
  27. Thomas GlanzmannMay 30, 2005
  28. Junio C HamanoMay 30, 2005
  29. Thomas GlanzmannMay 30, 2005
  30. Junio C HamanoMay 30, 2005
  31. Thomas GlanzmannMay 27, 2005
  32. Junio C HamanoMay 27, 2005
  33. Linus TorvaldsMay 27, 2005
  34. Benjamin HerrenschmidtMay 27, 2005
  35. Kay SieversMay 27, 2005
  36. Daniel SerpellMay 28, 2005
  37. David LangMay 28, 2005
  38. Kay SieversMay 28, 2005
  39. Kay SieversMay 28, 2005
  40. Benjamin HerrenschmidtMay 28, 2005
  41. Paul MackerrasMay 30, 2005
  42. Jeff EplerMay 31, 2005

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.