bbatsov/projectile — pull request #573 by tarsius (2014-12-09 10:34:14+00:00)
Title:  Fix and refactor getting files using external tools

```
The entry point is `projectile-dir-files-external'. When the project is
a Git repository it also returns the files in submodules. For other
project types nothing equivalent is done, but an abstraction to do that
in the future already existed.

Unfortunately that was implemented using six additional functions. This
lead to a lot of accidental complexity, which in turn lead to work being
done which did not need to be done. Also it didn't quite work in the
only case where we actually made use of this; Git submodules that are
located outside the directory we are interested in where also recursed
into.

So remove all of that and just keep `projectile-dir-files-external'.
When the project is a Git repository, then that function calls out to
the new function `projectile-dir-files-git', which as the name suggests
only knows about Git.

Provided there actually is another vcs which supports the equivalent of
Git submodules, then that should implemented as a separate function.
That function might share some code with the Git variant, but that's
okay; a bit of harmless code duplication is better than a broken
abstraction.

`git submodules foreach COMMAND' calls COMMAND for every initialized
submodule. This includes submodules which are not below the current
directory but $path is always relative to that directory. We need to
filter out such submodules, and that's what is responsible for most
of the complications in `projectile-dir-files-git'.

On the other hand, because `git submodules foreach COMMAND' ignores
submodules that have not been initialize yet, there is no need to
explicitly deal with modules which have themselves or their superproject
as a submodule. There is no risk of infinite recursion because for that
to happen the submodules would have had to be initialized recursively,
which would have failed eventually due to there being no space left on
the harddrive.
```