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
Linus Torvalds <torvalds@linux-foundation.org>
Date
Apr 10, 2007, 18:45 UTC
Message-ID
<Pine.LNX.4.64.0704101122510.6730@woody.linux-foundation.org>
In-Reply-To
<200704101828.37453.Josef.Weidendorfer@gmx.de>
On Tue, 10 Apr 2007, Josef Weidendorfer wrote:
Show 8 quoted lines
> On Tuesday 10 April 2007, Linus Torvalds wrote:
> > ...
> > +	if (resolve_gitlink_ref(ce->name, "HEAD", sha1) < 0)
> > +		return 0;
> > +	return hashcmp(sha1, ce->sha1);
> 
> So this does mean that the SHA1 of a gitlink entry corresponds
> to the commit in the subproject?
Yes.
Show 5 quoted lines
> I wonder if it is not useful to be able to add some attribute(s)
> to a gitlink, i.e. first reference a gitlink object in the superproject,
> which then references the submodule commit, and also holds some
> further attributes. These attributes can not be put into the subproject,
> as it should be independent.

The special "link" object has come up before, and I actually thought I'd do it that way first, but there were a few reasons why I didn't:

 - I tend to like "minimal", and the patches I sent out really are pretty 
   minimal, in the sense that they introduce just _one_ new concept, in 
   one place (it's basically a "tree entry" - so it shows up in tree 
   reading and writing, and nowhere else. The index, of course, is the 
   staging area for trees, so the index was also affected, but that was 
   really a very direct result of that "it's a new tree entry" thing).
 - in a "link" object, the only thing that would normally *change* is 
   really just the commit SHA1. Everything else is really pretty static. 
   As such, I decided that it's just a waste of a perfectly fine object to 
   have several thousands of the "link" objects that really only differ in 
   the pointer to the commit.
 - the "static" part, which you might as well have somewhere else, tends 
   to be stuff that you would need to be able to override locally, and as 
   such it does *not* really have a global meaning that is useful 
   historically.
   For example, the things that you'd want to associate with the gitlink 
   are things like "where would I find the repository that the commit is 
   part of" and "what is a description of that submodule" and "what are 
   the relationships between the submodules". These are things that aren't 
   necessarily even totally independent: in CVS, for example, you have 
   module names that are really not submodules themselves, but are really 
   just aliases for *collections* of submodules.
   So a 1:1 link object simply wouldn't make much sense anyway, and you'd 
   want to override those defaults with site-specific ones (maybe there is 
   a "canonical" address for the submodule repository, but if you have a 
   copy of it locally on-site, when you clone, you'd rather use the 
   *local* copy over the standard site, for example).
So all of this just made me say:
 - the tree entry just contains the commit ID of the subproject, and 
   *nothing* else.
 - any incidental data probably isn't 1:1 with tree entries anyway (both 
   over time: you have tree entries being updated with new commit ID's, 
   but the incidental data does *not* change, and over "space": different 
   repositories might want to use their local preferences for incidental 
   rules)
 - which all implies that the extra information should go in a separate 
   file that actually describes the modules.

In fact, it shouldn't be _one_ separate file: it should be at least two, since you'd want to have the *defaults* (which get cloned along with the superproject) in a revision-controlled file, and then have local *extra* information that is local.

This is exactly the same as the situation with the ".gitignore" file (which is revision-controlled and cloned with the respository) and the ".git/ignore" file (which is repository-local).

I've been thinking either ".gitmodules" (and ".git/modules") or to just extend the ".git/config" file parser to *also* parse a version-controlled ".gitconfig" file, and just describe the modules there. The config file really has pretty nice syntax, and I think module descriptions in many ways end up similar to remote branch descriptions, so it would fit in there, I think.

(But there's nothing that says that the ".gitmodules" file couldn't just use the same parser as the git config file, so I don't really strongly care either way. I just think it would be nice to be able to say

	[module "kdelibs"]
		dir = kdelibs
		url = git://git.kde.org/kdelibs
		description = "Basic KDE libraries module"
	[module "base"]
		alias = "kdelibs", "kdebase", "kdenetwork"
or whatever. You get the idea..)
		Linus
Previous: Josef WeidendorferNext: Andy Parkins
Message 44 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.