Commit 34fd5ca5 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

Git: Handle "no changes" case on conflict resolving



Change-Id: I75bb18c9564ffac3de2654bd388465794481b487
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent c68adbf9
......@@ -2132,10 +2132,10 @@ bool GitClient::synchronousPull(const QString &workingDirectory, bool rebase)
return executeAndHandleConflicts(workingDirectory, arguments, abortCommand);
}
bool GitClient::synchronousCommandContinue(const QString &workingDirectory, const QString &command)
bool GitClient::synchronousCommandContinue(const QString &workingDirectory, const QString &command, bool hasChanges)
{
QStringList arguments;
arguments << command << QLatin1String("--continue");
arguments << command << QLatin1String(hasChanges ? "--continue" : "--skip");
return executeAndHandleConflicts(workingDirectory, arguments, command);
}
......
......@@ -198,7 +198,7 @@ public:
QString vcsGetRepositoryURL(const QString &directory);
bool synchronousFetch(const QString &workingDirectory, const QString &remote);
bool synchronousPull(const QString &workingDirectory, bool rebase);
bool synchronousCommandContinue(const QString &workingDirectory, const QString &command);
bool synchronousCommandContinue(const QString &workingDirectory, const QString &command, bool hasChanges);
bool synchronousPush(const QString &workingDirectory, const QString &remote = QString());
bool synchronousMerge(const QString &workingDirectory, const QString &branch);
bool synchronousRebase(const QString &workingDirectory,
......
......@@ -255,26 +255,31 @@ void MergeTool::readData()
}
}
void MergeTool::continuePreviousGitCommand(const QString &msgBoxTitle, const QString &msgBoxText,
void MergeTool::continuePreviousGitCommand(const QString &msgBoxTitle, QString msgBoxText,
const QString &buttonName, const QString &gitCommand)
{
QString workingDirectory = m_process->workingDirectory();
QMessageBox msgBox;
QPushButton *commandButton = msgBox.addButton(buttonName, QMessageBox::AcceptRole);
QPushButton *abortButton = msgBox.addButton(QMessageBox::Abort);
bool isRebase = gitCommand == QLatin1String("rebase");
bool hasChanges = m_gitClient->gitStatus(m_process->workingDirectory(),
StatusMode(NoUntracked | NoSubmodules)) == GitClient::StatusChanged;
if (!hasChanges)
msgBoxText.prepend(tr("No changes found. "));
QMessageBox msgBox(QMessageBox::Question, msgBoxTitle, msgBoxText);
if (hasChanges || isRebase)
msgBox.addButton(hasChanges ? buttonName : tr("Skip"), QMessageBox::AcceptRole);
msgBox.addButton(QMessageBox::Abort);
msgBox.addButton(QMessageBox::Ignore);
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(msgBoxTitle);
msgBox.setText(msgBoxText);
msgBox.exec();
if (msgBox.clickedButton() == commandButton) { // Continue
if (gitCommand == QLatin1String("rebase"))
m_gitClient->synchronousCommandContinue(workingDirectory, gitCommand);
switch (msgBox.exec()) {
case QMessageBox::Ignore:
break;
case QMessageBox::Abort:
m_gitClient->synchronousAbortCommand(workingDirectory, gitCommand);
break;
default: // Continue/Skip
if (isRebase)
m_gitClient->synchronousCommandContinue(workingDirectory, gitCommand, hasChanges);
else
GitPlugin::instance()->startCommit();
} else if (msgBox.clickedButton() == abortButton) { // Abort
m_gitClient->synchronousAbortCommand(workingDirectory, gitCommand);
}
}
......
......@@ -78,7 +78,7 @@ private:
QString stateName(FileState state, const QString &extraInfo);
void chooseAction();
void addButton(QMessageBox *msgBox, const QString &text, char key);
void continuePreviousGitCommand(const QString &msgBoxTitle, const QString &msgBoxText,
void continuePreviousGitCommand(const QString &msgBoxTitle, QString msgBoxText,
const QString &buttonName, const QString &gitCommand);
MergeToolProcess *m_process;
......
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