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: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Petar Perisin
2013-01-05 19:53:20 +01:00
committed by Tobias Hunger
parent 25f05f7c9e
commit 4009c305fb
3 changed files with 20 additions and 5 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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) {