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

Re: [PATCH v3 09/12] get_short_oid / peel_onion: ^{tree} should be tree, not treeish

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
May 8, 2018, 18:53 UTC
Message-ID
<87a7tax9m1.fsf@evledraar.gmail.com>
In-Reply-To
<20180508143408.GA30183@sigill.intra.peff.net>
On Tue, May 08 2018, Jeff King wrote:
Show 29 quoted lines
> On Mon, May 07, 2018 at 01:08:46PM +0900, Junio C Hamano wrote:
>
>> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>>
>> > Right, and I'm with you so far, this makes sense to me for all existing
>> > uses of the peel syntax, otherwise v2.17.0^{tree} wouldn't be the same
>> > as rev-parse v2.17.0^{tree}^{tree}...
>>
>> More importantly, you could spell v2.17.0 part of the above with a
>> short hexadecimal string.  And that string should be naming some
>> tree-ish, the most important thing being that it is *NOT* required
>> to be a tree (and practically, it is likely that the user has a
>> tree-ish that is *NOT* a tree).
>>
>> I guess I have a reaction to the title
>>
>>     "get_short_oid/peel_onion: ^{tree} should be tree"
>>
>> "X^{tree}" should *RESULT* in a tree, but it should *REQUIRE* X to
>> be a tree-ish.  It is unclear "should be tree" is about the former
>> and I read (perhaps mis-read) it as saying "it should require X to
>> be a tree"---that statement is utterly incorrect as we agreed above.
>
> FWIW, I had the same feeling as you when reading this, that this commit
> (and the one after) are doing the wrong thing. And these paragraphs sum
> it up. The "^{tree}" is about asking us to peel to a tree, not about
> resolving X in the first place. We can use it as a _hint_ when resolving
> X, but the correct hint is "something that can be peeled to a tree", not
> "is definitely a tree".

Maybe I'm just being dense, but I still don't get from this & Junio's E-Mails what the general rule should be.

I think a response to the part after "leaving that aside" of my upthread E-Mail (https://public-inbox.org/git/87lgczyfq6.fsf@evledraar.gmail.com/) would help me out.

Not to belabor the point, but here's a patch I came up with to revisions.txt that's a WIP version of something that would describe the worldview after this v3:

    diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt
    index dfcc49c72c..0bf68f4ad2 100644
    --- a/Documentation/revisions.txt
    +++ b/Documentation/revisions.txt
    @@ -143,29 +143,52 @@ thing no matter the case.
       '<rev>{caret}1{caret}1{caret}1'.  See below for an illustration of
       the usage of this form.
     '<rev>{caret}{<type>}', e.g. 'v0.99.8{caret}\{commit\}'::
       A suffix '{caret}' followed by an object type name enclosed in
       brace pair means dereference the object at '<rev>' recursively until
       an object of type '<type>' is found or the object cannot be
    -  dereferenced anymore (in which case, barf).
    +  dereferenced anymore (in which case either return that object type, or barf).
       For example, if '<rev>' is a commit-ish, '<rev>{caret}\{commit\}'
       describes the corresponding commit object.
       Similarly, if '<rev>' is a tree-ish, '<rev>{caret}\{tree\}'
       describes the corresponding tree object.
       '<rev>{caret}0'
       is a short-hand for '<rev>{caret}\{commit\}'.
     +
     'rev{caret}\{object\}' can be used to make sure 'rev' names an
     object that exists, without requiring 'rev' to be a tag, and
     without dereferencing 'rev'; because a tag is already an object,
     it does not have to be dereferenced even once to get to an object.
     +
     'rev{caret}\{tag\}' can be used to ensure that 'rev' identifies an
     existing tag object.
    ++
    +Object types that don't have a 1=1 mapping to other object types
    +cannot be dereferenced with the peel syntax, and will return an
    +error. E.g. '<treeid>{caret}{commit}' or '<treeid>{caret}{tree}' is
    +allowed because a tag can only point to one commit, and a commit can
    +only point to one tree. But '<treeid>{caret}{blob}' will always
    +produce an error since trees in general don't 1=1 map to blobs, even
    +though the specific '<treeid>' in question might only contain one
    +blob. Note that '<tagid>{caret}{blob}' is not an error if '<tagid>' is
    +a tag that points directly to a blob, since that again becomes
    +unambiguous.
    ++
    +'<rev>{caret}{<type>}' takes on a different meaning when '<rev>' is a
    +SHA-1 that's ambiguous within the object store. In that case we don't
    +have a 1=1 mapping anymore. E.g. e8f2 in git.git can refer to multiple
    +objects of all the different object types. In that case
    +{caret}{<type>} should always be an error to be consistent with the
    +logic above, but that wouldn't be useful to anybody. Instead it'll
    +fall back to being selector syntax for the given object types,
    +e.g. e8f2{caret}{tag} will (as of writing this) return the v2.17.0
    +tag, and {caret}{commit}, {caret}{tree} and {caret}{blob} will return
    +commit, tree and blob objects, respectively.
    +
    [...]

My understanding of what you two are saying is that somehow the peel semantics should be preserved when we take this beyond the 1=1 mapping case, but I don't see how if we run with that how we wouldn't need to introduce the concept of blobish for consistency as I noted upthread.

So it would be very useful to me if you or someone who understands the behavior you & Junio seem to want could write a version of the patch I have above where the last paragraph is different, and describes the desired semantics, because I still don't get it. Why would we 1=many peel commits to trees as a special case, but not 1=many do the same for trees & blobs?

Previous: Jeff KingNext: Jeff King
Message 66 of 99 in “get_short_oid UI improvements”
  1. 0/9 get_short_oid UI improvementsÆvar Arnfjörð Bjarmason, Apr 30, 2018
  2. 1/9 sha1-name.c: remove stray newlineÆvar Arnfjörð Bjarmason, Apr 30, 2018
  3. 2/9 sha1-array.h: align function argumentsÆvar Arnfjörð Bjarmason, Apr 30, 2018
  4. 3/9 sha1-name.c: move around the collect_ambiguous() functionÆvar Arnfjörð Bjarmason, Apr 30, 2018
  5. 4/9 get_short_oid: sort ambiguous objects by type, then SHA-1Ævar Arnfjörð Bjarmason, Apr 30, 2018
  6. Derrick StoleeMay 1, 2018
  7. Ævar Arnfjörð BjarmasonMay 1, 2018
  8. Derrick StoleeMay 1, 2018
  9. Ævar Arnfjörð BjarmasonMay 1, 2018
  10. Derrick StoleeMay 1, 2018
  11. 6/9 get_short_oid: learn to disambiguate by ^{blob}Ævar Arnfjörð Bjarmason, Apr 30, 2018
  12. 7/9 get_short_oid / peel_onion: ^{tree} should mean tree, not treeishÆvar Arnfjörð Bjarmason, Apr 30, 2018
  13. brian m. carlsonMay 1, 2018
  14. 5/9 get_short_oid: learn to disambiguate by ^{tag}Ævar Arnfjörð Bjarmason, Apr 30, 2018
  15. 9/9 config doc: document core.disambiguateÆvar Arnfjörð Bjarmason, Apr 30, 2018
  16. 8/9 get_short_oid / peel_onion: ^{tree} should mean commit, not commitishÆvar Arnfjörð Bjarmason, Apr 30, 2018
  17. Eric SunshineApr 30, 2018
  18. Stefan BellerApr 30, 2018
  19. brian m. carlsonMay 1, 2018
  20. Derrick StoleeMay 1, 2018
  21. 00/12 get_short_oid UI improvementsÆvar Arnfjörð Bjarmason, May 1, 2018
  22. 01/12 sha1-name.c: remove stray newlineÆvar Arnfjörð Bjarmason, May 1, 2018
  23. 02/12 sha1-array.h: align function argumentsÆvar Arnfjörð Bjarmason, May 1, 2018
  24. 03/12 git-p4: change "commitish" typo to "committish"Ævar Arnfjörð Bjarmason, May 1, 2018
  25. 04/12 cache.h: add comment explaining the order in object_typeÆvar Arnfjörð Bjarmason, May 1, 2018
  26. 05/12 sha1-name.c: move around the collect_ambiguous() functionÆvar Arnfjörð Bjarmason, May 1, 2018
  27. 07/12 get_short_oid: learn to disambiguate by ^{tag}Ævar Arnfjörð Bjarmason, May 1, 2018
  28. 06/12 get_short_oid: sort ambiguous objects by type, then SHA-1Ævar Arnfjörð Bjarmason, May 1, 2018
  29. 09/12 get_short_oid / peel_onion: ^{tree} should be tree, not treeishÆvar Arnfjörð Bjarmason, May 1, 2018
  30. 10/12 get_short_oid / peel_onion: ^{commit} should be commit, not committishÆvar Arnfjörð Bjarmason, May 1, 2018
  31. 12/12 get_short_oid: document & warn if we ignore the type selectorÆvar Arnfjörð Bjarmason, May 1, 2018
  32. 11/12 config doc: document core.disambiguateÆvar Arnfjörð Bjarmason, May 1, 2018
  33. 08/12 get_short_oid: learn to disambiguate by ^{blob}Ævar Arnfjörð Bjarmason, May 1, 2018
  34. 06/11 get_short_oid: sort ambiguous objects by type, then SHA-1Derrick Stolee, May 1, 2018
  35. Ævar Arnfjörð BjarmasonMay 1, 2018
  36. Derrick StoleeMay 1, 2018
  37. Ævar Arnfjörð BjarmasonMay 1, 2018
  38. Derrick StoleeMay 1, 2018
  39. 00/12 get_short_oid UI improvementsÆvar Arnfjörð Bjarmason, May 1, 2018
  40. 01/12 sha1-name.c: remove stray newlineÆvar Arnfjörð Bjarmason, May 1, 2018
  41. 02/12 sha1-array.h: align function argumentsÆvar Arnfjörð Bjarmason, May 1, 2018
  42. 04/12 cache.h: add comment explaining the order in object_typeÆvar Arnfjörð Bjarmason, May 1, 2018
  43. Junio C HamanoMay 3, 2018
  44. Duy NguyenMay 8, 2018
  45. pack-format.txt: more details on pack file formatNguyễn Thái Ngọc Duy, May 8, 2018
  46. Stefan BellerMay 8, 2018
  47. Duy NguyenMay 8, 2018
  48. Stefan BellerMay 8, 2018
  49. Ævar Arnfjörð BjarmasonMay 8, 2018
  50. Duy NguyenMay 8, 2018
  51. pack-format.txt: more details on pack file formatNguyễn Thái Ngọc Duy, May 10, 2018
  52. Stefan BellerMay 10, 2018
  53. Duy NguyenMay 11, 2018
  54. Junio C HamanoMay 11, 2018
  55. pack-format.txt: more details on pack file formatNguyễn Thái Ngọc Duy, May 11, 2018
  56. 03/12 git-p4: change "commitish" typo to "committish"Ævar Arnfjörð Bjarmason, May 1, 2018
  57. 05/12 sha1-name.c: move around the collect_ambiguous() functionÆvar Arnfjörð Bjarmason, May 1, 2018
  58. 08/12 get_short_oid: learn to disambiguate by ^{blob}Ævar Arnfjörð Bjarmason, May 1, 2018
  59. 09/12 get_short_oid / peel_onion: ^{tree} should be tree, not treeishÆvar Arnfjörð Bjarmason, May 1, 2018
  60. Junio C HamanoMay 3, 2018
  61. Ævar Arnfjörð BjarmasonMay 3, 2018
  62. Junio C HamanoMay 4, 2018
  63. Ævar Arnfjörð BjarmasonMay 4, 2018
  64. Junio C HamanoMay 7, 2018
  65. Jeff KingMay 8, 2018
  66. Ævar Arnfjörð BjarmasonMay 8, 2018
  67. Jeff KingMay 9, 2018
  68. Ævar Arnfjörð BjarmasonMay 9, 2018
  69. Junio C HamanoMay 10, 2018
  70. Jeff KingMay 10, 2018
  71. 0/6 get_short_oid UI improvementsÆvar Arnfjörð Bjarmason, May 10, 2018
  72. 1/6 sha1-name.c: remove stray newlineÆvar Arnfjörð Bjarmason, May 10, 2018
  73. 2/6 sha1-array.h: align function argumentsÆvar Arnfjörð Bjarmason, May 10, 2018
  74. Jeff KingMay 10, 2018
  75. Junio C HamanoMay 11, 2018
  76. Junio C HamanoMay 11, 2018
  77. 3/6 git-p4: change "commitish" typo to "committish"Ævar Arnfjörð Bjarmason, May 10, 2018
  78. Luke DiamandMay 10, 2018
  79. 4/6 sha1-name.c: move around the collect_ambiguous() functionÆvar Arnfjörð Bjarmason, May 10, 2018
  80. 5/6 get_short_oid: sort ambiguous objects by type, then SHA-1Ævar Arnfjörð Bjarmason, May 10, 2018
  81. Jeff KingMay 10, 2018
  82. Junio C HamanoMay 11, 2018
  83. 6/6 get_short_oid: document & warn if we ignore the type selectorÆvar Arnfjörð Bjarmason, May 10, 2018
  84. Martin ÅgrenMay 10, 2018
  85. Jeff KingMay 10, 2018
  86. Jeff KingMay 10, 2018
  87. Jeff KingMay 10, 2018
  88. Jeff KingMay 10, 2018
  89. 10/12 get_short_oid / peel_onion: ^{commit} should be commit, not committishÆvar Arnfjörð Bjarmason, May 1, 2018
  90. 11/12 config doc: document core.disambiguateÆvar Arnfjörð Bjarmason, May 1, 2018
  91. Jeff KingMay 8, 2018
  92. 12/12 get_short_oid: document & warn if we ignore the type selectorÆvar Arnfjörð Bjarmason, May 1, 2018
  93. 06/12 get_short_oid: sort ambiguous objects by type, then SHA-1Ævar Arnfjörð Bjarmason, May 1, 2018
  94. Junio C HamanoMay 3, 2018
  95. Jeff KingMay 8, 2018
  96. 07/12 get_short_oid: learn to disambiguate by ^{tag}Ævar Arnfjörð Bjarmason, May 1, 2018
  97. Derrick StoleeMay 2, 2018
  98. Derrick StoleeMay 2, 2018
  99. Jacob KellerMay 3, 2018

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.