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

Re: url.<base>.insteadOf vs. submodules

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 21, 2017, 23:37 UTC
Message-ID
<xmqqo9xvdsji.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAGZ79kby-UhUqci9Mgdhw+wvS5Y39=Q7AmCrWaTMWbcZPNT6Dw@mail.gmail.com>
Stefan Beller <sbeller@google.com> writes:
Show 17 quoted lines
> On Tue, Feb 21, 2017 at 3:00 PM, Jeff King <peff@peff.net> wrote:
> ...
>> I guess one answer is that this is the wrong approach entirely, and the
>> right one is something like: submodules should understand that they are
>> part of a superproject, and respect some whitelisted set of config from
>> the superproject .git/config file.
>
> This would break one of the core assumptions that submodules
> are "independent" repos.
>
> The way of action is a one way street:
> * The superproject is aware of the submodule and when you invoke a
> command on the superproject, you may mess around with the submodule,
> e.g. update/remove it; absorb its git directory.
> * The submodule is "just" a repository with weird .git link file and a
>   respective core.worktree setup. Currently it doesn't know if it is
>   guided by a superproject.

While that is a good discipline to follow, I think you need to differenciate the project that is bound as a submodule to a superproject, and a specific instance of a submodule repository, i.e. a clone of such a project.

It is true that the Linux kernel project should *NEVER* know your appliance project only because you happen to use it as a component of your appliance that happens to use the kernel as one of its submodules. But that does not mean your copy of the kernel that sits in your recursive checkout of your appliance project should not know anything about your superproject.

This is true even without any submodules. The Git project itself does not even care you are Stefan, but you still can and do add [user] name = "Stefan Beller" to .git/config of your clone of the Git project. A clone of the project may want to know more than the data project itself keeps track of to describe the context in which the particular clone is being used. And .git/config is a good place to keep such pieces of information.

So I would think it is entirely reasonable if "git submodule init sub" that is run in the superproject to initialize "sub" writes something in "sub/.git" to tell that "sub" is used in the context of that particular toplevel superproject and customize its behavour accordingly. Perhaps it may want to add the url.*.insteadOf that is useful for updating the submodule repository when it does "submodule init", for example.

Previous: Stefan BellerNext: Junio C Hamano
Message 10 of 19 in “url.<base>.insteadOf vs. submodules”
  1. ToolforgerFeb 19, 2017
  2. Jeff KingFeb 20, 2017
  3. ToolforgerFeb 20, 2017
  4. Jeff KingFeb 20, 2017
  5. ToolforgerFeb 21, 2017
  6. Jeff KingFeb 21, 2017
  7. Stefan BellerFeb 21, 2017
  8. Jeff KingFeb 21, 2017
  9. Stefan BellerFeb 21, 2017
  10. Junio C HamanoFeb 21, 2017
  11. Junio C HamanoFeb 21, 2017
  12. Stefan BellerFeb 22, 2017
  13. Junio C HamanoFeb 22, 2017
  14. Jon LoeligerFeb 22, 2017
  15. Junio C HamanoFeb 22, 2017
  16. Jeff KingFeb 22, 2017
  17. Stefan BellerFeb 22, 2017
  18. Jeff KingFeb 21, 2017
  19. Stefan BellerFeb 22, 2017

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.