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

Re: [PATCH 6/6] Teach core object handling functions about gitlinks

From
Martin Waitz <tali@admingilde.org>
Date
Apr 11, 2007, 11:31 UTC
Message-ID
<20070411113150.GL21701@admingilde.org>
In-Reply-To
<200704111047.01271.andyparkins@gmail.com>
hoi :)
On Wed, Apr 11, 2007 at 10:47:00AM +0100, Andy Parkins wrote:
Show 11 quoted lines
> On Wednesday 2007 April 11 09:06, Martin Waitz wrote:
> 
> > The only thing I disagree with you is in using HEAD of the submodule:
> 
> I know we've had this discussion before, but I'm going to bring it up again - 
> mainly because Linus's implementation exactly matches what I envisaged when 
> we originally spoke of this.  I think in your "Updating the branch which HEAD 
> points to is dangerous" section, the main thing you're not taking into 
> account is that git can make detached checkouts.  Updating HEAD is not 
> dangerous - updating refs is; and I don't think anyone is proposing that a 
> submodule ref should ever be updated by a supermodule.

Then we already agree on the most important part. My argument is mostly against updating the ref which is behind HEAD, not HEAD per se. And I haven't thought about using detached HEADs until I wrote the mail.

Show 5 quoted lines
> I think you're also too strongly focussed on the idea that the supermodule 
> tracks submodule branches - it cannot branches are not part of "the" 
> repository they point at "a" repository.  References are outside the 
> repository pointing in, and hence the supermodule cannot refer to them at its 
> core.

No, that may be an misunderstanding because my very first prototype really did track branches. In the meantime I changed my mind, my current prototypes all track submodule commits directly. But in doing so we create a branch of its own: remember, a branch in git is just a moving reference into the history. Such a reference can be stored in .git/refs/heads or it can be stored in the index/tree of the supermodule. The difference is not really big. So we do not track a branch, but we create a branch by tracking.

Show 13 quoted lines
> Now, if you check out a revision in the supermodule, that's going to look up 
> the submodule revision stored in the DIRLINK tree entry which will recurse 
> into the submodule and checkout that revision - almost certainly as a 
> detached HEAD.  There are three possibilities then:
>  - The submodule revision is in the past and no submodule branch points at it
>  - The submodule revision is current and a submodule branch points at it
>  - The submodule revision is current and multiple submodule branches point at 
>    it
> The supermodule checkout will have to make a decision whether to update the 
> submodule HEAD (in one case it's obvious: a revision in the past has to be 
> detached HEAD as there is no suitable branch).  It's also possible that the 
> single submodule branch case is easy - undetach HEAD; however I don't think 
> that is universally correct.

I don't like to guess which branches to update. I'd prefer to just unconditionally update one specific one.

Show 5 quoted lines
> I know you're very much in favour of making branches in the submodule 
> correspond to branches in the supermodule, but I just don't see a way of 
> making it work - the supermodule cannot know about submodule branches, 
> branches are not part of the repository, they just point at the repository.  
> My branches could be different from your branches.

That would not work, you are right. Please see my above comment about tracking & branches.

> The way submodules should be treated is that the whole submodule is analogous 
> to a single repository-tracked file - that's essentially what a submodule is 
> in the end but the content of the "file" is the submodule revision.
Wholeheartedly agreed.
Show 7 quoted lines
> Now, if you change branch in the submodule, the supermodule will see
> that as a change in the submodule (as it should).  If you changed
> back, it will be restored and the supermodule will again see it as
> unchanged.  If you commit on the submodule, the supermodule will see
> that as a change and you'll have to git-add the submodule and commit
> in the supermodule.  The submodule is on whatever branch it is on - at
> all times.
Show 5 quoted lines
> The only time I can see this causing difficulties is when you want to
> checkout the tip of a submodule branch - how is the supermodule to
> know when it is correct to change HEAD from being detached to being
> attached?  I suppose it's got to be config-based; and out-of-tree
> config at that.

Again, doing things conditionally here just adds to confusion. Just have one dedicated branch and be done with it.

-- 
Martin Waitz
Previous: Andy ParkinsNext: Linus Torvalds
Message 74 of 98 in “Initial subproject support (RFC?)”
  1. 0/6 Initial subproject support (RFC?)Linus Torvalds, Apr 10, 2007
  2. 1/6 diff-lib: use ce_mode_from_stat() rather than messing with modes manuallyLinus Torvalds, Apr 10, 2007
  3. 2/6 Avoid overflowing name buffer in deep directory structuresLinus Torvalds, Apr 10, 2007
  4. 3/6 Add 'resolve_gitlink_ref()' helper functionLinus Torvalds, Apr 10, 2007
  5. Alex RiesenApr 10, 2007
  6. Linus TorvaldsApr 10, 2007
  7. Alex RiesenApr 10, 2007
  8. Linus TorvaldsApr 10, 2007
  9. Alex RiesenApr 10, 2007
  10. Linus TorvaldsApr 10, 2007
  11. Josef WeidendorferApr 10, 2007
  12. 4/6 Add "S_IFDIRLNK" file mode infrastructure for git linksLinus Torvalds, Apr 10, 2007
  13. 5/6 Teach "fsck" not to follow subproject linksLinus Torvalds, Apr 10, 2007
  14. Sam VilainApr 11, 2007
  15. Linus TorvaldsApr 11, 2007
  16. Sam VilainApr 11, 2007
  17. Linus TorvaldsApr 11, 2007
  18. David LangApr 11, 2007
  19. Linus TorvaldsApr 11, 2007
  20. David LangApr 11, 2007
  21. Linus TorvaldsApr 12, 2007
  22. Junio C HamanoApr 12, 2007
  23. David LangApr 12, 2007
  24. Dana HowApr 12, 2007
  25. Linus TorvaldsApr 12, 2007
  26. Rogan DawesApr 13, 2007
  27. Linus TorvaldsApr 13, 2007
  28. Dana HowApr 15, 2007
  29. Dana HowApr 12, 2007
  30. Sam VilainApr 12, 2007
  31. Junio C HamanoApr 12, 2007
  32. Linus TorvaldsApr 12, 2007
  33. Junio C HamanoApr 12, 2007
  34. Junio C HamanoApr 12, 2007
  35. Linus TorvaldsApr 12, 2007
  36. Dana HowApr 11, 2007
  37. 6/6 Teach core object handling functions about gitlinksLinus Torvalds, Apr 10, 2007
  38. Frank LichtenheldApr 10, 2007
  39. Alex RiesenApr 10, 2007
  40. Linus TorvaldsApr 10, 2007
  41. Josef WeidendorferApr 10, 2007
  42. Alex RiesenApr 10, 2007
  43. Josef WeidendorferApr 10, 2007
  44. Linus TorvaldsApr 10, 2007
  45. Andy ParkinsApr 10, 2007
  46. Linus TorvaldsApr 10, 2007
  47. Junio C HamanoApr 10, 2007
  48. Linus TorvaldsApr 10, 2007
  49. Sam VilainApr 12, 2007
  50. Martin WaitzApr 12, 2007
  51. Linus TorvaldsApr 12, 2007
  52. Sam VilainApr 12, 2007
  53. David LangApr 10, 2007
  54. Junio C HamanoApr 10, 2007
  55. Josef WeidendorferApr 10, 2007
  56. Linus TorvaldsApr 10, 2007
  57. Sam VilainApr 11, 2007
  58. Linus TorvaldsApr 12, 2007
  59. Torgil SvenssonApr 12, 2007
  60. Martin WaitzApr 12, 2007
  61. Torgil SvenssonApr 12, 2007
  62. Sam VilainApr 11, 2007
  63. Martin WaitzApr 11, 2007
  64. Alex RiesenApr 11, 2007
  65. Martin WaitzApr 11, 2007
  66. Alex RiesenApr 11, 2007
  67. Martin WaitzApr 11, 2007
  68. Junio C HamanoApr 11, 2007
  69. Martin WaitzApr 11, 2007
  70. Junio C HamanoApr 11, 2007
  71. Martin WaitzApr 11, 2007
  72. Linus TorvaldsApr 11, 2007
  73. Andy ParkinsApr 11, 2007
  74. Martin WaitzApr 11, 2007
  75. Linus TorvaldsApr 11, 2007
  76. Sam VilainApr 11, 2007
  77. Martin WaitzApr 11, 2007
  78. Brian GernhardtApr 12, 2007
  79. Josef WeidendorferApr 12, 2007
  80. Linus TorvaldsApr 10, 2007
  81. Alex RiesenApr 10, 2007
  82. Linus TorvaldsApr 10, 2007
  83. Alex RiesenApr 10, 2007
  84. Linus TorvaldsApr 10, 2007
  85. Alex RiesenApr 10, 2007
  86. Junio C HamanoApr 10, 2007
  87. Linus TorvaldsApr 10, 2007
  88. Junio C HamanoApr 10, 2007
  89. Sam RavnborgApr 10, 2007
  90. Junio C HamanoApr 10, 2007
  91. Nicolas PitreApr 10, 2007
  92. J. Bruce FieldsApr 15, 2007
  93. David KågedalApr 11, 2007
  94. Junio C HamanoApr 11, 2007
  95. J. Bruce FieldsApr 15, 2007
  96. Martin WaitzApr 11, 2007
  97. Alex RiesenApr 11, 2007
  98. Martin WaitzApr 11, 2007

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.