Add in a check to see if a submodule is active before attempting to recurse. This prevents 'ls-files' from trying to operate on a submodule which may not exist in the working directory. Signed-off-by: Brandon Williams <bmwill@xxxxxxxxxx> --- After you mentioned possibly needing to check if a submodule is initialized, I went back and noticed that there was indeed no check for it...So this patch adds in the necessary check to see if a submodule is active or not before attempting to recurse. builtin/ls-files.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/builtin/ls-files.c b/builtin/ls-files.c index d449e46db..10ddc0306 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -15,6 +15,7 @@ #include "string-list.h" #include "pathspec.h" #include "run-command.h" +#include "submodule.h" static int abbrev; static int show_deleted; @@ -235,7 +236,8 @@ static void show_ce_entry(const char *tag, const struct cache_entry *ce) die("git ls-files: internal error - cache entry not superset of prefix"); if (recurse_submodules && S_ISGITLINK(ce->ce_mode) && - submodule_path_match(&pathspec, name.buf, ps_matched)) { + submodule_path_match(&pathspec, name.buf, ps_matched) && + is_submodule_initialized(ce->name)) { show_gitlink(ce); } else if (match_pathspec(&pathspec, name.buf, name.len, len, ps_matched, @@ -604,8 +606,10 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix) if (require_work_tree && !is_inside_work_tree()) setup_work_tree(); - if (recurse_submodules) + if (recurse_submodules) { + gitmodules_config(); compile_submodule_options(argv, &dir, show_tag); + } if (recurse_submodules && (show_stage || show_deleted || show_others || show_unmerged || -- 2.12.2.762.g0e3151a226-goog