Re: git submodules implementation question
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 29, 2016, 20:03 UTC
- Message-ID
- <xmqqlgzf9wch.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <CAN5XQftQH8B+hWVh4JQgZwAp+rkbz51P5NZDc_+Tfm0EB1zkew@mail.gmail.com>
Uma Srinivasan <usrinivasan@twitter.com> writes:
Show 7 quoted lines
> 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 dir2to clone an independent project into dir2 directory, and add it as a new submodule. The fallback is to support such a layout.