On Fri, Jan 20, 2017 at 01:58:02PM -0800, Junio C Hamano wrote: > Junio C Hamano <gitster@xxxxxxxxx> writes: > > > Jeff King <peff@xxxxxxxx> writes: > > > >>> And in my current understanding of submodules the check in > >>> .gitmodules ought to be enough, too. > >> > >> Yeah, that probably makes sense. You can have a gitlink without a > >> .gitmodules file, but I don't quite know what that would mean in terms > >> of submodules (I guess it's not a submodule but "something else"). > > > > That may be a lot better than reading the index unconditionally, but > > I'd rather not to see "git rev-parse" read ".gitmodules" at all. It > > would discourage scripted use of Git for no good reason. > > Thinking about this more, I suspect that > > cd sub && git anything > > when the index of the top-level thinks "sub" must be a submodule and > the user is not interested in "sub" (hence it hasn't gone through > "git submodule init" or "update") should get the same error as you > would get if you did > > cd /var/tmp/ && git anything > > when none of /, /var, /var/tmp/ is controlled by any Git repository. > I.e. "fatal: Not a git repository". Not sure if our emails just crossed, but yes, I agree completely. > Perhaps we can update two things and make it cheap. > > - checking out the top-level working tree without populating the > working tree of a submodule learns to do a bit more than just > creating an empty directory. Instead, it creates the third kind > of ".git" (we currently support two kinds of ".git", one that is > a repository itself, and another that is points at a repository), > that tells us that there is not (yet) a repository there. > > - the "discovering the root of the working tree" logic learns to > notice the third kind of ".git" and stop with "Not a git > repository". Yeah, I thought about suggesting something like that earlier. It's slightly more efficient than the "find the root and then complain" thing Stefan and I were talking about, but I'd worry it comes with weird corner cases. E.g., are there tools (or other parts of git) that care about it literally being an empty directory? E.g., would parts of "checkout" need to know that it's OK to blow it away?