Re: [RFC/PATCH] ls-files: adding support for submodules
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 9, 2016, 23:01 UTC
- Message-ID
- <xmqqh99o8ypm.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <1473458004-41460-1-git-send-email-bmwill@google.com>
Brandon Williams <bmwill@google.com> writes:
> Allow ls-files to recognize submodules in order to retrieve a list of > files from a repository's submodules. This is done by forking off a > process to recursively call ls-files on all submodules.
While I see why "ls-files --recurse-submodules" sounds nice ("hey, I can get list of _all_ the files here"), and I am quite happy with the quality of implementation (not just the code but its documentation and test) especially from a first-time contributor, I am not quite sure what the utility of this new feature would be, especially given that the command is a plumbing, i.e. meant to be a useful building block for scripts.
If I get
$ git ls-files --recurse-submodules
Makefile
lib/Makefile
lib/hello.py
main.py
goodbye.pyout of the command, what can I do with it without knowing where the submodule boundaries are? It's not like I can just do
git ls-files --recurse-submodule |
while read path
do
git update-index --add "$path"
donewhen "lib/" is a submodule. Instead, I'd need to go to "lib/" and then add "Makefile" and "hello.py" from there.
Show 17 quoted lines
> diff --git a/t/t3007-ls-files-recurse-submodules.sh b/t/t3007-ls-files-recurse-submodules.sh > new file mode 100644 > index 0000000..78deded > --- /dev/null > +++ b/t/t3007-ls-files-recurse-submodules.sh > @@ -0,0 +1,103 @@ > +... > +test_expect_success 'setup directory structure and submodules' ' > +... > +' > + > +cat >expect <<EOF > +.gitmodules > +a > +b/b > +submodule/c > +EOF
We used to do that when we didn't know better.
Please don't do things outside test_expect_* block, especially in a new script.