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

Re: git submodule vs GIT_WORK_TREE

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 26, 2012, 22:53 UTC
Message-ID
<7vzk7p8z38.fsf@alter.siamese.dyndns.org>
In-Reply-To
<4FEA380D.8070001@web.de>
Jens Lehmann <Jens.Lehmann@web.de> writes:
Show 20 quoted lines
> Am 26.06.2012 21:51, schrieb Junio C Hamano:
> ...
>> If the user has to use GIT_WORK_TREE to mark the root level of the
>> superproject working tree as such, it is very likely that the
>> controlling repository of the superproject does not live in the
>> $GIT_WORK_TREE/.git directory (in other words, $GIT_DIR points at
>> somewhere else).  Exporting GIT_WORK_TREE/submodule as the new value
>> of GIT_WORK_TREE is sensible, but I do not see a reasonable way to
>> deduce the value of GIT_DIR for the submodule in such a case.  The
>> controlling repository of the superproject is located somewhere
>> random; there is no reason to assume the repository for the
>> submodule is somewhere at fixed relation to it.
>> 
>> Does it mean the short answer to Richard's situation is "Don't do
>> it"?  I am not sure, but it is starting to sound like it.
>
> Not at all, I was just trying to reach consensus on what the user
> can reasonably expect when setting GIT_WORK_TREE in the presence of
> submodules. I will look into it to see how we can handle the cases
> where GIT_WORK_TREE and/or GIT_DIR are set.

Thanks, then I'll let you look into it. I do not see how you could determine GIT_DIR for the submodule sensibly if the superproject's working tree does not have its GIT_DIR as ".git" at the top-level, though.

Declaring that a checked out submodule _must_ have its controlling repository as ".git" at its root level, i.e. it should be accessible without using GIT_WORK_TREE/GIT_DIR at all just like a normal Git repository is, would be a clean way to avoid the issue altogether and it still will allow the top-level superproject to be structured in a funny way to require GIT_WORK_TREE/GIT_DIR to access it, but I am not sure if that is too restrictive for people who for some unknown reason want to use these environment variables to create repositories with a strange layout.

Previous: Jens LehmannNext: Richard Hartmann
Message 6 of 13 in “git submodule vs GIT_WORK_TREE”
  1. Richard HartmannJun 26, 2012
  2. Junio C HamanoJun 26, 2012
  3. Jens LehmannJun 26, 2012
  4. Junio C HamanoJun 26, 2012
  5. Jens LehmannJun 26, 2012
  6. Junio C HamanoJun 26, 2012
  7. Richard HartmannJun 29, 2012
  8. Junio C HamanoJun 29, 2012
  9. Junio C HamanoJun 29, 2012
  10. Junio C HamanoJun 29, 2012
  11. Richard HartmannJul 1, 2012
  12. Junio C HamanoJul 2, 2012
  13. Richard HartmannJun 29, 2012

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.