Commit 4009c305 authored by Petar Perisin's avatar Petar Perisin Committed by Tobias Hunger
Browse files

Git: Fixed a bug with rebase check



Rebase on pull should check if branch configuration has rebase set to
true. This is important to correctly abort operation when conflicts
appear, and user chooses not to run mergetool

Change-Id: I365aa534bdbece466514f542ea2e3c371c89a4a8
Reviewed-by: default avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 25f05f7c
......@@ -1665,8 +1665,10 @@ GitClient::StatusResult GitClient::gitStatus(const QString &workingDirectory, St
// Quietly retrieve branch list of remote repository URL
//
// The branch HEAD is pointing to is always returned first.
QStringList GitClient::synchronousRepositoryBranches(const QString &repositoryURL)
QStringList GitClient::synchronousRepositoryBranches(const QString &repositoryURL, bool *isDetached)
{
if (isDetached)
*isDetached = true;
QStringList arguments(QLatin1String("ls-remote"));
arguments << repositoryURL << QLatin1String("HEAD") << QLatin1String("refs/heads/*");
const unsigned flags =
......@@ -1689,10 +1691,13 @@ QStringList GitClient::synchronousRepositoryBranches(const QString &repositoryUR
const int pos = line.lastIndexOf(pattern);
if (pos != -1) {
const QString branchName = line.mid(pos + pattern.count());
if (line.startsWith(headSha))
if (line.startsWith(headSha)) {
branches[0] = branchName;
else
if (isDetached)
*isDetached = false;
} else {
branches.push_back(branchName);
}
}
}
return branches;
......
......@@ -231,7 +231,7 @@ public:
void launchRepositoryBrowser(const QString &workingDirectory);
QStringList synchronousRepositoryBranches(const QString &repositoryURL);
QStringList synchronousRepositoryBranches(const QString &repositoryURL, bool *isDetached = 0);
GitSettings *settings() const;
......
......@@ -888,7 +888,17 @@ void GitPlugin::pull()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
const bool rebase = m_gitClient->settings()->boolValue(GitSettings::pullRebaseKey);
bool rebase = m_gitClient->settings()->boolValue(GitSettings::pullRebaseKey);
if (!rebase) {
bool isDetached;
QString branchRebaseConfig = m_gitClient->synchronousRepositoryBranches(state.topLevel(), &isDetached).at(0);
if (!isDetached) {
branchRebaseConfig.prepend(QLatin1String("branch."));
branchRebaseConfig.append(QLatin1String(".rebase"));
rebase = (m_gitClient->readConfigValue(state.topLevel(), branchRebaseConfig) == QLatin1String("true"));
}
}
GitClient::StashResult stashResult = m_gitClient->ensureStash(state.topLevel());
switch (stashResult) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment