9

I have a single git repo with a directory structure that looks like this:

root ---------- src
        |
        |
        |------ 3rd

root is my working directory, 3rd consists of multiple third-party git submodules.
projectile-find-file only finds files in src, it does not work for the submodules.

Rorschach
  • 31,301
  • 5
  • 78
  • 129
guoxx
  • 348
  • 1
  • 9
  • It seems you were able to solve the problem yourself which is great! However, instead of including the solution in your question, you might want to consider posting an [answer](https://stackoverflow.com/help/self-answer) below. (You will even be able to accept it after 48 hours.) – itsjeyd Apr 23 '14 at 21:46
  • You're welcome, and thanks for following up on my suggestion! :) – itsjeyd Apr 24 '14 at 09:05

3 Answers3

7

projectile-git-command uses git ls-files to list the files belonging to the project,
so I resolved the problem with the following code:

(setq projectile-git-command "git-ls-all-files")

git-ls-all-files is a shell script:

\#!/bin/zsh
files=`git ls-files -co --exclude-standard`
sb_files=`git --no-pager submodule --quiet foreach 'git ls-files --full-name -co --exclude-standard | sed s!^!$path/!'`
all_files=$files$sb_files

echo $all_files
guoxx
  • 348
  • 1
  • 9
  • 1
    Or, all in one command: (setq projectile-git-command "cat <(git ls-files -zco --exclude-standard) <(git --no-pager submodule --quiet foreach 'git ls-files --full-name -co --exclude-standard | sed s!^!$path/!')") – scvalex Aug 10 '14 at 12:11
  • That's cool! Thanks you very much! And two git ls-files commands should use same flags `-zco`. – guoxx Sep 14 '14 at 10:21
6

I just had an equivalent problem, I fixed it by adding an empty .projectile file to my root directory, this tells projectile that that directory is the real project root and to search all the files in it's subdirectories when you want to find something.

See here for more info.

Mike H-R
  • 7,726
  • 5
  • 43
  • 65
  • Thanks - this helped me solve a similar issues as OP. I needed a way to tell projectile to load multiple repositories (similar to "adding a folder" in VSCode) so that I could grep through and open files belonging to multiple repositories. – Kevin Friedheim Feb 03 '21 at 20:37
0

In addition to the solution of Mike, I add a .projectile file to each submodule and this submodule will become a new project in Emacs.

Trung Ta
  • 1,582
  • 1
  • 16
  • 25