Re: git submodule vs GIT_WORK_TREE
- From
Jens Lehmann <jens.lehmann@web.de>
- Date
- Jun 26, 2012, 18:27 UTC
- Message-ID
- <4FE9FF0C.8050409@web.de>
- In-Reply-To
- <7vobo6cazk.fsf@alter.siamese.dyndns.org>
Am 26.06.2012 18:07, schrieb Junio C Hamano:
Show 8 quoted lines
> Richard Hartmann <richih.mailinglist@gmail.com> writes: > >> As you are most likely aware, `git submodule` allows you to access a >> separate git repository in a sub-directory, e.g. $submodule, while >> $GIT_WORK_TREE forces git to operate in a specific directory. Combine >> the two and the result is less than ideal. git is forced to operate in >> $GIT_WORK_TREE while it should operate on $GIT_WORK_TREE/$submodule, >> instead.
Richard, could you please tell us what git commands behave strange in what way and what your expectations were? A short test shows e.g. "git submodule foreach" operates on $(pwd)/submodule even though GIT_WORK_TREE is set while at the same time git status shows the same submodule as missing because it is looking for it in $GIT_WORK_TREE. Is that what you are talking about?
Show 13 quoted lines
> The end user should not be asked to anything special. > > When the user exports GIT_WORK_TREE to tell git that the root of the > working tree the user wants to work on resides there (which is > needed when the user exports GIT_DIR to tell git that the user wants > to work on that repository), that wish obviously applies only to > that repository. If git decides to visit the working tree of a > different repository (e.g. a checkout of a submodule bound to the > project GIT_WORK_TREE points at), even if it is done in response to > the user action (e.g. like passing "--recurse-submodules" option), > it should adjust GIT_WORK_TREE and GIT_DIR to be appropriate for > operations in the submodule repository while doing so. If the more > recent "recursive" behaviour forgets to do so, it simply is a bug.
I'm not sure what you mean by "appropriate for operations in the submodule repository". Should the submodule work tree be searched for under $GIT_WORK_TREE of the superproject or under $(pwd)?
As far as I can see all submodule code consistently clears all environment variables used by git before descending into a submodule (at least since February 2010 and 5ce9086dd). Maybe we should change that so it sets the GIT_WORK_TREE environment to "$GIT_WORK_TREE/submodule" to be consistent?