aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/git/gitclient.cpp
diff options
context:
space:
mode:
authorOrgad Shaneh <[email protected]>2020-09-27 16:01:14 +0300
committerOrgad Shaneh <[email protected]>2020-10-04 17:06:23 +0000
commit48c56416f5e128c04f2d2d867b518775e0527607 (patch)
tree66b5cefc44fd241dbf51b81daac84caad07fe847 /src/plugins/git/gitclient.cpp
parentc0b001737cd14cca89d4522bab44ec1fa4d4eeab (diff)
Git: Do not prompt to add files in a submodule
Fixes: QTCREATORBUG-23845 Change-Id: Ibf20eed26469b5a8599927e5ac2d458bbff9a156 Reviewed-by: AndrĂ© Hartmann <[email protected]>
Diffstat (limited to 'src/plugins/git/gitclient.cpp')
-rw-r--r--src/plugins/git/gitclient.cpp40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index 2352c81f126..593f16fc4d7 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -840,22 +840,30 @@ bool GitClient::managesFile(const QString &workingDirectory, const QString &file
== SynchronousProcessResponse::Finished;
}
-QStringList GitClient::unmanagedFiles(const QString &workingDirectory,
- const QStringList &filePaths) const
-{
- QStringList args({"ls-files", "-z"});
- QDir wd(workingDirectory);
- args << transform(filePaths, [&wd](const QString &fp) { return wd.relativeFilePath(fp); });
- const SynchronousProcessResponse response
- = vcsFullySynchronousExec(workingDirectory, args, Core::ShellCommand::NoOutput);
- if (response.result != SynchronousProcessResponse::Finished)
- return filePaths;
- const QStringList managedFilePaths
- = transform(response.stdOut().split('\0', Qt::SkipEmptyParts),
- [&wd](const QString &fp) { return wd.absoluteFilePath(fp); });
- return filtered(filePaths, [&managedFilePaths](const QString &fp) {
- return !managedFilePaths.contains(fp);
- });
+QStringList GitClient::unmanagedFiles(const QStringList &filePaths) const
+{
+ QMap<QString, QStringList> filesForDir;
+ for (const QString &filePath : filePaths) {
+ const FilePath fp = FilePath::fromString(filePath);
+ filesForDir[fp.parentDir().toString()] << fp.fileName();
+ }
+ QStringList res;
+ for (auto it = filesForDir.begin(), end = filesForDir.end(); it != end; ++it) {
+ QStringList args({"ls-files", "-z"});
+ const QDir wd(it.key());
+ args << transform(it.value(), [&wd](const QString &fp) { return wd.relativeFilePath(fp); });
+ const SynchronousProcessResponse response
+ = vcsFullySynchronousExec(it.key(), args, Core::ShellCommand::NoOutput);
+ if (response.result != SynchronousProcessResponse::Finished)
+ return filePaths;
+ const QStringList managedFilePaths
+ = transform(response.stdOut().split('\0', Qt::SkipEmptyParts),
+ [&wd](const QString &fp) { return wd.absoluteFilePath(fp); });
+ res += filtered(it.value(), [&managedFilePaths, &wd](const QString &fp) {
+ return !managedFilePaths.contains(wd.absoluteFilePath(fp));
+ });
+ }
+ return res;
}
QTextCodec *GitClient::codecFor(GitClient::CodecType codecType, const QString &source) const