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, 08:06 UTC
Message-ID
<20070411080641.GF21701@admingilde.org>
In-Reply-To
<Pine.LNX.4.64.0704092115350.6730@woody.linux-foundation.org>
hoi :)

thanks Linus for your nice implementation. Your core code is so much nicer than my hacked-up prototype :-).

I only had little time to actually have a look at it but the core is very similiar to my approach and I'll try to rebase some of my code on top of yours in the following days.

The only thing I disagree with you is in using HEAD of the submodule:
On Mon, Apr 09, 2007 at 09:20:29PM -0700, Linus Torvalds wrote:
Show 16 quoted lines
> +static int ce_compare_gitlink(struct cache_entry *ce)
> +{
> +	unsigned char sha1[20];
> +
> +	/*
> +	 * We don't actually require that the .git directory
> +	 * under DIRLNK directory be a valid git directory. It
> +	 * might even be missing (in case nobody populated that
> +	 * sub-project).
> +	 *
> +	 * If so, we consider it always to match.
> +	 */
> +	if (resolve_gitlink_ref(ce->name, "HEAD", sha1) < 0)
> +		return 0;
> +	return hashcmp(sha1, ce->sha1);
> +}
Show 9 quoted lines
> @@ -2332,6 +2333,8 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, int write
>  				     path);
>  		free(target);
>  		break;
> +	case S_IFDIR:
> +		return resolve_gitlink_ref(path, "HEAD", sha1);
>  	default:
>  		return error("%s: unsupported file type", path);
>  	}

Always using HEAD of the submodule makes branches in the submodule useless.

Whenever you do a checkout in the supermodule you also have to update the submodule and this update has to change the same thing which is read above. Updating the branch which HEAD points to is dangerous. You could overwrite some unrelated branch just because the user forgot to switch back to his supermodule-tracking-branch. The user would always have to make sure that all the submodules are in the correct state for an update of the supermodule. Updating HEAD directly is possible now and may make some sense, but you still get problems when you want to switch to some temporary branch in the submodule. You have no chance to get back to the original supermodule version and now your temporary submodule branch gets shown as the new submodule version which should be part of the supermodule. The submodule version which is stored in the supermodules tree is kind of a hidden/remote reference/branch. When working on a remote branch we first create a local working branch and then sync it with the remote one. I think that it makes sense to use the same model for submodules: have one local branch in the submodule which is used for all work that is done in the supermodule context.

So my advice is: Always read and write one dedicated branch (hardcoded "master" or configurable) when the supermodule wants to access a submodule.

Then you have two type of branches: You can branch the supermodule and have you own branch of the entire project with all submodules. Use this if you want to commit your work on the submodule into the supermodule. You can also branch the submodule to effectively disconnect the submodule from the supermodule temporarily. You can use this to do some experimental/debugging stuff which should not yet go into the supermodule. Once you want this branch to show up in the supermodule, just merge it to "master" and commit it to the supermodule (and now its in the supermodule branch, the submodule branch is not needed any more).

See also the discussion about it in the messages around http://marc.info/?l=git&m=116636334226668&w=2

-- 
Martin Waitz
Previous: Sam VilainNext: Alex Riesen
Message 63 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.