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

Re: git-name-rev off-by-one bug

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Nov 30, 2005, 21:06 UTC
Message-ID
<Pine.LNX.4.64.0511301514500.25300@iabervon.org>
In-Reply-To
<7vsltdsxzb.fsf@assigned-by-dhcp.cox.net>
On Wed, 30 Nov 2005, Junio C Hamano wrote:
Show 16 quoted lines
> Daniel Barkalow <barkalow@iabervon.org> writes:
> 
> > On Mon, 28 Nov 2005, Junio C Hamano wrote:
> >
> >> *1* It is a shame that the most comprehensive definition of
> >> 3-way read-tree semantics is in t/t1000-read-tree-m-3way.sh test
> >> script.
> >
> > Isn't Documentation/technical/trivial-merge.txt more comprehensive?
> 
> It describes the multi-base extention while the old one was done
> before the multi-base, so content-wise it may be more up to date.
> 
> One thing I have most trouble with is that it is not obvious if
> the table is covering all the cases.  You have to read from top
> to bottom and consider the first match as its fate [*1*]. 

I actually had that problem with the original tables; there isn't a canonical order in which to list a table of all of the possible matches and non-matches between items so as to be complete.

Perhaps it ought to list, on each line, which previous cases would match, so that you could see that case 2 is really the conditions of 2 minus the conditions for 2ALT, which is "all of the ancestors are empty, the head has a directory/file conflict, and remote exists."

It can't fall off the table, because 1, 2, 3, 4, 6, 7, 9, and 11 cover all of the possibilities with respect to inputs being empty, and do not care about matching between the inputs.

Show 18 quoted lines
> I was about to write "with no match resulting in no merge", but it is
> not even obvious if there are cases that would fall off at the
> end from the table by just looking at it.  Even worse, if we add
> "no match results in no merge" at the end, by definition it
> covers all the cases, but it is not obvious what those fall-off
> cases are (IOW, what kinds of conflict they are and why they are
> not handled).
> 
> Another thing, perhaps more important, is taht it does not seem
> to talk about index and up-to-dateness requirements much; it
> says something about what happens when "no merge" result is
> taken, but it is not clear about other cases.  The table in
> t1000 test marks the case with "must match X" when index and
> tree X must agree at the path, and with "must match X and be
> up-to-date" when in addition the file in the working tree must
> match what is recorded in the index at the path (i.e. the former
> can have local modification in the working tree as long as index
> entry and tree match).

But that is redundant information. I was actually confused by that part of the table for a long time, because it was not clear that it followed a couple of simple rules (which I give above the table), and weren't actually chosen on a case-by-case basis.

The implementation I did is actually much easier to verify, because it doesn't go into each case for the index requirements, but checks the actual rules: the index must match either the head or (if there is one) the merge result, and the index must not be dirty if there is a "no merge" result. Therefore, you can't lose any work in the index (either you didn't have any, or you did the same thing), and you can't lose any work in the working tree (either you didn't have any, or we're not going to use the working tree).

Last time we discussed it ("Multi-ancestor read-tree notes"), you said:
  I like the second sentence in three-way merge description.  That
  is a very easy-to-understand description of what the index
  requirements are.
Show 7 quoted lines
> This is vital in making sure that read-tree 3-way merge does not
> lose information from the working tree.  I am sure your updated
> *code* is doing the right thing, but the documentation is not
> clear about it.  E.g. case 3ALT in the table says "take our
> branch if the path does not exist in one or more of common
> ancestors and the other branch does not have it" without saying
> anything about index nor up-to-dateness requirements. 
"If the index exists, it is an error for it not to match either the
 head or (if the merge is trivial) the result."
"A result of "no merge" is an error if the index is not empty and not
 up-to-date."

So the index is permitted to not exist (you missed this case), but if it exists, it must match HEAD (or, well, HEAD, which is the result). The index need not be up-to-date (since the result is not "no merge"), so the working tree doesn't matter.

Show 7 quoted lines
> > Probably the tables in various other places should be replaced with 
> > references to this document.
> 
> I agree 100% that having them scattered all over is bad and the
> trivial-merge.txt is the logical place to consolidate them, but
> I do not think simply removing others and pointing at
> trivial-merge.txt without updating it is good enough.

Certainly, your complaints about the table should be addressed first. I think I'd addressed all your complaints from last time, but at that point, we got sidetracked into a discussion of the details of case #16.

	-Daniel
*This .sig left intentionally blank*
Previous: Junio C HamanoNext: Junio C Hamano
Message 58 of 64 in “git-name-rev off-by-one bug”
  1. linux@horizon.comNov 28, 2005
  2. Junio C HamanoNov 29, 2005
  3. linux@horizon.comNov 29, 2005
  4. Junio C HamanoNov 29, 2005
  5. Junio C HamanoNov 30, 2005
  6. Petr BaudisNov 29, 2005
  7. Junio C HamanoNov 29, 2005
  8. Petr BaudisDec 4, 2005
  9. as promised, docs: git for the confusedlinux@horizon.com, Dec 8, 2005
  10. Junio C HamanoDec 8, 2005
  11. H. Peter AnvinDec 8, 2005
  12. Alan ChandlerDec 9, 2005
  13. Petr BaudisDec 9, 2005
  14. Josef WeidendorferDec 9, 2005
  15. linux@horizon.comNov 29, 2005
  16. Junio C HamanoNov 29, 2005
  17. linux@horizon.comNov 30, 2005
  18. Junio C HamanoNov 30, 2005
  19. Junio C HamanoNov 30, 2005
  20. Linus TorvaldsNov 30, 2005
  21. Junio C HamanoNov 30, 2005
  22. Junio C HamanoNov 30, 2005
  23. Linus TorvaldsNov 30, 2005
  24. Linus TorvaldsNov 30, 2005
  25. Junio C HamanoNov 30, 2005
  26. Junio C HamanoNov 30, 2005
  27. Linus TorvaldsNov 30, 2005
  28. Linus TorvaldsNov 30, 2005
  29. Junio C HamanoDec 2, 2005
  30. merge-one-file: make sure we create the merged file.Junio C Hamano, Dec 2, 2005
  31. merge-one-file: make sure we do not mismerge symbolic links.Junio C Hamano, Dec 2, 2005
  32. git-merge documentation: conflicting merge leaves higher stages in indexJunio C Hamano, Dec 2, 2005
  33. linux@horizon.comNov 30, 2005
  34. Junio C HamanoNov 30, 2005
  35. More merge questionslinux@horizon.com, Nov 30, 2005
  36. Daniel BarkalowNov 30, 2005
  37. Junio C HamanoNov 30, 2005
  38. linux@horizon.comDec 2, 2005
  39. Junio C HamanoDec 2, 2005
  40. Sven VerdoolaegeDec 2, 2005
  41. Junio C HamanoDec 2, 2005
  42. Sven VerdoolaegeDec 5, 2005
  43. linux@horizon.comDec 2, 2005
  44. Junio C HamanoDec 2, 2005
  45. linux@horizon.comDec 2, 2005
  46. Junio C HamanoDec 2, 2005
  47. Linus TorvaldsDec 2, 2005
  48. linux@horizon.comDec 2, 2005
  49. linux@horizon.comDec 2, 2005
  50. Linus TorvaldsNov 30, 2005
  51. Junio C HamanoNov 30, 2005
  52. Junio C HamanoNov 30, 2005
  53. Junio C HamanoNov 30, 2005
  54. linux@horizon.comNov 30, 2005
  55. Daniel BarkalowNov 30, 2005
  56. Daniel BarkalowNov 30, 2005
  57. Junio C HamanoNov 30, 2005
  58. Daniel BarkalowNov 30, 2005
  59. Junio C HamanoNov 30, 2005
  60. Daniel BarkalowNov 30, 2005
  61. Junio C HamanoDec 1, 2005
  62. Junio C HamanoDec 1, 2005
  63. Petr BaudisDec 1, 2005
  64. Randal L. SchwartzDec 1, 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.