summaryrefslogtreecommitdiff
path: root/src/plugins/git/gitclient.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2010-03-25 16:23:37 +0100
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2010-03-25 16:23:37 +0100
commitde28b61cca3ac3f1f147ad57a9ad69aedf892cb6 (patch)
tree40203cb07a380943a8c1344c526e8af25a767519 /src/plugins/git/gitclient.cpp
parent37acb3b8d1bf194c6f85cb6c12c7f72757e44768 (diff)
downloadqt-creator-de28b61cca3ac3f1f147ad57a9ad69aedf892cb6.tar.gz
VCS[git], CodePaster: Add support for applying patches.
Modify CodePaster::fetch to do a mimetype detection on the content, create a filename with the matching extension and open that file. This gives correct syntax highlighting and makes "Save as" more convenient. Keep the file around and delete on exit. Modify patch mimetype with some content detection (higher priority than C++). Add a "current patch file" to the VCSBasePlugin::State. Add "Apply patch" to git with whitespace fix.
Diffstat (limited to 'src/plugins/git/gitclient.cpp')
-rw-r--r--src/plugins/git/gitclient.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index a2310888c2..1a8c9e3b11 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -973,6 +973,26 @@ bool GitClient::synchronousCleanList(const QString &workingDirectory,
return true;
}
+bool GitClient::synchronousApplyPatch(const QString &workingDirectory,
+ const QString &file, QString *errorMessage)
+{
+ if (Git::Constants::debug)
+ qDebug() << Q_FUNC_INFO << workingDirectory;
+ QStringList args;
+ args << QLatin1String("apply") << QLatin1String("--whitespace=fix") << file;
+ QByteArray outputText;
+ QByteArray errorText;
+ const bool rc = synchronousGit(workingDirectory, args, &outputText, &errorText);
+ if (rc) {
+ if (!errorText.isEmpty())
+ *errorMessage = tr("There were warnings while applying %1 to %2:\n%3").arg(file, workingDirectory, commandOutputFromLocal8Bit(errorText));
+ } else {
+ *errorMessage = tr("Unable apply patch %1 to %2: %3").arg(file, workingDirectory, commandOutputFromLocal8Bit(errorText));
+ return false;
+ }
+ return true;
+}
+
// Factory function to create an asynchronous command
GitCommand *GitClient::createCommand(const QString &workingDirectory,
VCSBase::VCSBaseEditor* editor,