Git: Start interactive rebase from log window

Useful if local changes are already pushed to a
remote and therefore Creator refuses interactive
rebase due to missing local commits.

Task-number: QTCREATORBUG-11200
Change-Id: I2e9b9fd35b75fcb232c1358c553fe1092ce97161
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Andre Hartmann
2019-04-17 11:04:49 +02:00
committed by André Hartmann
parent cb8da0e93b
commit d2d05c584e
3 changed files with 25 additions and 9 deletions

View File

@@ -816,20 +816,31 @@ void GitPlugin::recoverDeletedFiles()
void GitPlugin::startRebase()
{
if (!DocumentManager::saveAllModifiedDocuments())
return;
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
const QString topLevel = state.topLevel();
if (topLevel.isEmpty() || !m_gitClient->canRebase(topLevel))
startRebaseFromCommit(topLevel, QString());
}
void GitPlugin::startRebaseFromCommit(const QString &workingDirectory, QString commit)
{
if (!DocumentManager::saveAllModifiedDocuments())
return;
LogChangeDialog dialog(false, ICore::dialogParent());
RebaseItemDelegate delegate(dialog.widget());
dialog.setWindowTitle(tr("Interactive Rebase"));
if (!dialog.runDialog(topLevel))
if (workingDirectory.isEmpty() || !m_gitClient->canRebase(workingDirectory))
return;
if (m_gitClient->beginStashScope(topLevel, "Rebase-i"))
m_gitClient->interactiveRebase(topLevel, dialog.commit(), false);
if (commit.isEmpty()) {
LogChangeDialog dialog(false, ICore::dialogParent());
RebaseItemDelegate delegate(dialog.widget());
dialog.setWindowTitle(tr("Interactive Rebase"));
if (!dialog.runDialog(workingDirectory))
return;
commit = dialog.commit();
}
if (m_gitClient->beginStashScope(workingDirectory, "Rebase-i"))
m_gitClient->interactiveRebase(workingDirectory, commit, false);
}
void GitPlugin::startChangeRelatedAction(const Id &id)