From 514842ca773137c4e4951a0312636d0c2c82b852 Mon Sep 17 00:00:00 2001 From: joshaber Date: Tue, 19 Jan 2016 11:59:16 -0500 Subject: [PATCH] If we can't refresh a submodule, drop it. --- src/git-repository-async.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/git-repository-async.js b/src/git-repository-async.js index f40172c69..9828be14d 100644 --- a/src/git-repository-async.js +++ b/src/git-repository-async.js @@ -853,17 +853,26 @@ export default class GitRepositoryAsync { } for (const name in this.submodules) { - if (submoduleNames.indexOf(name) < 0) { - const repo = this.submodules[name] + const repo = this.submodules[name] + const gone = submoduleNames.indexOf(name) < 0 + if (gone) { repo.destroy() delete this.submodules[name] + } else { + try { + await repo.refreshStatus() + } catch (e) { + // If we error trying to refresh, then it probably means the submodule + // isn't actually a submodule. Libgit2 will report anything listed in + // .gitmodules as a submodule, but that's not necessarily accurate. So + // get rid of the submodule entry. + repo.destroy() + delete this.submodules[name] + } } } - const submoduleRepos = _.values(this.submodules) - await Promise.all(submoduleRepos.map(s => s.refreshStatus())) - - return submoduleRepos + return _.values(this.submodules) } // Get the status for the submodules in the repository.