From: Junio C Hamano Date: Mon, 29 Aug 2016 20:03:10 GMT Subject: Re: git submodules implementation question Message-ID: In-Reply-To: Uma Srinivasan writes: > git_dir = read_gitfile(buf.buf); > if (!git_dir) > > git_dir = buf.buf; > > Can anyone explain to me why we are replacing a failed reading of a > git file with the original sub directory name? A top-level superproject can have a submodule bound at its "dir/" directory, and "dir/.git" can either be a gitfile which you can read with read_gitfile() and point into somewhere in ".git/modules/" of the top-level superproject. "dir/.git" can _ALSO_ be a fully valid Git directory. So at the top of a superproject, you could do git clone $URL ./dir2 git add dir2 to clone an independent project into dir2 directory, and add it as a new submodule. The fallback is to support such a layout.