diff --git a/addons/project/kateprojectworker.h b/addons/project/kateprojectworker.h --- a/addons/project/kateprojectworker.h +++ b/addons/project/kateprojectworker.h @@ -86,7 +86,6 @@ QStringList filesFromDirectory(const QDir &dir, bool recursive, const QStringList &filters); QStringList gitLsFiles(const QDir &dir); - QStringList gitSubmodulesFiles(const QDir &dir); private: /** diff --git a/addons/project/kateprojectworker.cpp b/addons/project/kateprojectworker.cpp --- a/addons/project/kateprojectworker.cpp +++ b/addons/project/kateprojectworker.cpp @@ -247,33 +247,37 @@ QStringList KateProjectWorker::filesFromGit(const QDir &dir, bool recursive) { - QStringList relFiles = gitLsFiles(dir); - relFiles << gitSubmodulesFiles(dir); - + /** + * query files via ls-files, make them absolute afterwards + */ + const QStringList relFiles = gitLsFiles(dir); QStringList files; for (const QString &relFile : relFiles) { if (!recursive && (relFile.indexOf(QStringLiteral("/")) != -1)) { continue; } files.append(dir.absolutePath() + QLatin1Char('/') + relFile); } - return files; } QStringList KateProjectWorker::gitLsFiles(const QDir &dir) { - QStringList files; - - // git ls-files -z results a bytearray where each entry is \0-terminated. - // NOTE: Without -z, Umlauts such as "Der Bäcker/Das Brötchen.txt" do not work (#389415) + /** + * git ls-files -z results a bytearray where each entry is \0-terminated. + * NOTE: Without -z, Umlauts such as "Der Bäcker/Das Brötchen.txt" do not work (#389415) + * + * use --recurse-submodules, there since git 2.11 (released 2016) + * our own submodules handling code leads to file duplicates + */ QStringList args; - args << QStringLiteral("ls-files") << QStringLiteral("-z") << QStringLiteral("."); + args << QStringLiteral("ls-files") << QStringLiteral("-z") << QStringLiteral("--recurse-submodules") << QStringLiteral("."); QProcess git; git.setWorkingDirectory(dir.absolutePath()); git.start(QStringLiteral("git"), args); + QStringList files; if (!git.waitForStarted() || !git.waitForFinished(-1)) { return files; } @@ -286,36 +290,6 @@ return files; } -QStringList KateProjectWorker::gitSubmodulesFiles(const QDir &dir) -{ - /** - * git submodule command gives little to use for reliable file listing - * so reading the .gitmodule file directly. After the module paths are found - * just treat the new repositories as the main one. - */ - QStringList files; - - QString modulesPath = dir.filePath(QStringLiteral(".gitmodules")); - - if (!QFile::exists(modulesPath)) { - return files; - } - - QSettings config(modulesPath, QSettings::IniFormat); - - for (const QString &module: config.childGroups()) { - QString path = config.value(module + QStringLiteral("/path")).toString(); - QDir moduleDir = dir.filePath(path); - QStringList relFiles = gitLsFiles(moduleDir); - - for (const QString &file: relFiles) { - files << path + QLatin1Char('/') + file; - } - } - - return files; -} - QStringList KateProjectWorker::filesFromMercurial(const QDir &dir, bool recursive) { QStringList files;