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

Re: Moved files and merges

From
Junio C Hamano <junkio@cox.net>
Date
Sep 4, 2005, 08:27 UTC
Message-ID
<7vfysli6g3.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20050903220355.GA1895@mars.ravnborg.org>
Junio C Hamano <junkio@cox.net> writes:
> All true.  Let's redraw that simplified scenario, and see if
> what I said still holds.  It may be interesting to store my
> previous message and this one in a file and run diff between
> them.

There are a couple of things worth mentioning about the two examples (one that I resolved favoring non-rename and non-addition, and the other I resolved favoring rename and addition) I gave tonight.

1. When I said "the principles are the same", I was primarily
   referring to the part that detects the 'previous' merge,
   which of its parents is 'ours' and which is 'theirs'.
   Although I handwaved that part in both examples, my gut
   feeling is that this part is probably harder than the part
   that adjusts trees before merging.  klibc vs klibc-kbuild
   case had a clear distinction between which commit is ours and
   which is theirs, but I am not sure if things are that black
   and white in real projects when a lot of criss-crossing
   merges are involved.
2. When adjusting trees, I treated removals and additions a bit
   differently, but there is no fundamental reason to do so.
   In the first example which had a removal, I adjusted the tree
   #2 and #6 by removing the path involved.  In the second
   example which had an addition, I did not adjust the tree #2
   and #6 to add that path.  But you _could_ do nothing to
   adjust for removal; i.e. leaving K in tree #2-adjusted and
   #6-adjusted in the first example. Also you _could_ adjust for
   the addition by copying K from #3 into #2-adjusted and
   copying K from #5 into #6-adjusted in the second example.
   If you did the former, merging the resulting #6-adjusted into
   #5 pivoting at #2-adjusted would leave a non-trivial conflict
   for you to resolve by hand.  #6-adjusted changes K from
   #2-adjusted while #5 would remove it from #2-adjusted.  This
   would be a remove-modify conflict (case 7 in the 3-way merge
   case table in t/t1000-read-tree-m-3way.sh).  But this is only
   non-trivial to git and what you want is obvious to you as the
   maintainer of the line of development that removed the file
   at #3.  You removed it the last time, and you remove it this
   time again.  I adjusted #2 and #6 to remove the path only to
   save you from this tedium upfront before the read-tree phase.
   Similarly, in the second example, if #2 and #6 are adjusted
   for the addition of K by copying K from #3 and #5 into them,
   the resulting merge would see that one line #2-adjusted to
   #6-adjusted changes K (whose contents is that of
   #3) to that of #5, while the other line #2-adjusted to #5
   changes K (whose contents is again that of #3) to that of
   #5.  Since this is both-change-identically (case 12 in the
   3-way merge table), it trivially resolves to keep K from #5,
   and the result is the same as what you would get from my
   second example which did nothing about additions.
   
Previous: H. Peter AnvinNext: Fredrik Kuivinen
Message 21 of 23 in “Moved files and merges”
  1. H. Peter AnvinSep 2, 2005
  2. Martin LanghoffSep 3, 2005
  3. H. Peter AnvinSep 4, 2005
  4. Junio C HamanoSep 3, 2005
  5. Junio C HamanoSep 3, 2005
  6. Fredrik KuivinenSep 3, 2005
  7. Junio C HamanoSep 3, 2005
  8. Junio C HamanoSep 3, 2005
  9. Sam RavnborgSep 3, 2005
  10. Junio C HamanoSep 3, 2005
  11. Sam RavnborgSep 3, 2005
  12. Junio C HamanoSep 4, 2005
  13. Daniel BarkalowSep 4, 2005
  14. Junio C HamanoSep 4, 2005
  15. H. Peter AnvinSep 5, 2005
  16. Linus TorvaldsSep 5, 2005
  17. H. Peter AnvinSep 5, 2005
  18. Junio C HamanoSep 5, 2005
  19. Junio C HamanoSep 5, 2005
  20. H. Peter AnvinSep 5, 2005
  21. Junio C HamanoSep 4, 2005
  22. Fredrik KuivinenSep 3, 2005
  23. Sam RavnborgSep 3, 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.