summaryrefslogtreecommitdiff
path: root/src/plugins/git/gitversioncontrol.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/git/gitversioncontrol.cpp')
-rw-r--r--src/plugins/git/gitversioncontrol.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/plugins/git/gitversioncontrol.cpp b/src/plugins/git/gitversioncontrol.cpp
index 2f351b2839..85b94493ac 100644
--- a/src/plugins/git/gitversioncontrol.cpp
+++ b/src/plugins/git/gitversioncontrol.cpp
@@ -56,7 +56,7 @@ QString GitVersionControl::displayName() const
Core::Id GitVersionControl::id() const
{
- return VcsBase::Constants::VCS_ID_GIT;
+ return Core::Id(VcsBase::Constants::VCS_ID_GIT);
}
bool GitVersionControl::isConfigured() const
@@ -140,7 +140,12 @@ QString GitVersionControl::vcsGetRepositoryURL(const QString &directory)
return m_client->vcsGetRepositoryURL(directory);
}
-/* Snapshots are implement using stashes, relying on stash messages for
+QString GitVersionControl::vcsTopic(const QString &directory)
+{
+ return m_client->synchronousTopic(directory);
+}
+
+/* Snapshots are implemented using stashes, relying on stash messages for
* naming as the actual stash names (stash{n}) are rotated as one adds stashes.
* Note that the snapshot interface does not care whether we have an unmodified
* repository state, in which case git refuses to stash.
@@ -161,10 +166,10 @@ QString GitVersionControl::vcsCreateSnapshot(const QString &topLevel)
return stashMessage;
if (repositoryUnchanged) {
// For unchanged repository state: return identifier + top revision
- QString topRevision;
- QString branch;
- if (!m_client->synchronousTopRevision(topLevel, &topRevision, &branch))
+ QString topRevision = m_client->synchronousTopRevision(topLevel);
+ if (topRevision.isEmpty())
return QString();
+ QString branch = m_client->synchronousTopic(topLevel);
const QChar colon = QLatin1Char(':');
QString id = QLatin1String(stashRevisionIdC);
id += colon;
@@ -183,7 +188,7 @@ QStringList GitVersionControl::vcsSnapshots(const QString &topLevel)
return QStringList();
// Return the git stash 'message' as identifier, ignoring empty ones
QStringList rc;
- foreach(const Stash &s, stashes)
+ foreach (const Stash &s, stashes)
if (!s.message.isEmpty())
rc.push_back(s.message);
return rc;
@@ -201,15 +206,19 @@ bool GitVersionControl::vcsRestoreSnapshot(const QString &topLevel, const QStrin
break;
const QString branch = tokens.at(1);
const QString revision = tokens.at(2);
- success = m_client->synchronousReset(topLevel)
- && m_client->synchronousCheckoutBranch(topLevel, branch)
- && m_client->synchronousCheckoutFiles(topLevel, QStringList(), revision);
+ success = m_client->synchronousReset(topLevel);
+ if (success && !branch.isEmpty()) {
+ success = m_client->synchronousCheckout(topLevel, branch) &&
+ m_client->synchronousCheckoutFiles(topLevel, QStringList(), revision);
+ } else {
+ success = m_client->synchronousCheckout(topLevel, revision);
+ }
} else {
// Restore stash if it can be resolved.
QString stashName;
success = m_client->stashNameFromMessage(topLevel, name, &stashName)
&& m_client->synchronousReset(topLevel)
- && m_client->synchronousStashRestore(topLevel, stashName);
+ && m_client->synchronousStashRestore(topLevel, stashName, true);
}
} while (false);
return success;