forked from qt-creator/qt-creator
Git: Support reflog also for branches
Change-Id: I9321ba4964d086d90aaf540a2006f95b94de8375 Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
committed by
Orgad Shaneh
parent
c9f1d84db7
commit
c728d04b52
@@ -240,6 +240,7 @@ void BranchView::slotCustomContextMenu(const QPoint &point)
|
|||||||
GitPlugin::client()->diffBranch(m_repository, fullName);
|
GitPlugin::client()->diffBranch(m_repository, fullName);
|
||||||
});
|
});
|
||||||
contextMenu.addAction(tr("&Log"), this, [this] { log(selectedIndex()); });
|
contextMenu.addAction(tr("&Log"), this, [this] { log(selectedIndex()); });
|
||||||
|
contextMenu.addAction(tr("&Reflog"), this, [this] { reflog(selectedIndex()); });
|
||||||
contextMenu.addSeparator();
|
contextMenu.addSeparator();
|
||||||
if (!currentSelected) {
|
if (!currentSelected) {
|
||||||
auto resetMenu = new QMenu(tr("Re&set"), &contextMenu);
|
auto resetMenu = new QMenu(tr("Re&set"), &contextMenu);
|
||||||
@@ -559,6 +560,13 @@ void BranchView::log(const QModelIndex &idx)
|
|||||||
GitPlugin::client()->log(m_repository, QString(), false, {branchName});
|
GitPlugin::client()->log(m_repository, QString(), false, {branchName});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BranchView::reflog(const QModelIndex &idx)
|
||||||
|
{
|
||||||
|
const QString branchName = m_model->fullName(idx, true);
|
||||||
|
if (!branchName.isEmpty())
|
||||||
|
GitPlugin::client()->reflog(m_repository, branchName);
|
||||||
|
}
|
||||||
|
|
||||||
void BranchView::push()
|
void BranchView::push()
|
||||||
{
|
{
|
||||||
const QModelIndex selected = selectedIndex();
|
const QModelIndex selected = selectedIndex();
|
||||||
|
@@ -83,6 +83,7 @@ private:
|
|||||||
void rebase();
|
void rebase();
|
||||||
bool cherryPick();
|
bool cherryPick();
|
||||||
void log(const QModelIndex &idx);
|
void log(const QModelIndex &idx);
|
||||||
|
void reflog(const QModelIndex &idx);
|
||||||
void push();
|
void push();
|
||||||
|
|
||||||
QToolButton *m_addButton = nullptr;
|
QToolButton *m_addButton = nullptr;
|
||||||
|
@@ -1062,20 +1062,24 @@ void GitClient::log(const QString &workingDirectory, const QString &fileName,
|
|||||||
vcsExec(workingDir, arguments, editor);
|
vcsExec(workingDir, arguments, editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitClient::reflog(const QString &workingDirectory)
|
void GitClient::reflog(const QString &workingDirectory, const QString &ref)
|
||||||
{
|
{
|
||||||
const QString title = tr("Git Reflog \"%1\"").arg(workingDirectory);
|
const QString title = tr("Git Reflog \"%1\"").arg(workingDirectory);
|
||||||
const Id editorId = Git::Constants::GIT_LOG_EDITOR_ID;
|
const Id editorId = Git::Constants::GIT_LOG_EDITOR_ID;
|
||||||
VcsBaseEditorWidget *editor = createVcsEditor(editorId, title, workingDirectory, codecFor(CodecLogOutput),
|
// Creating document might change the referenced workingDirectory. Store a copy and use it.
|
||||||
"reflogRepository", workingDirectory);
|
const QString workingDir = workingDirectory;
|
||||||
|
VcsBaseEditorWidget *editor = createVcsEditor(editorId, title, workingDir, codecFor(CodecLogOutput),
|
||||||
|
"reflogRepository", workingDir);
|
||||||
VcsBaseEditorConfig *argWidget = editor->editorConfig();
|
VcsBaseEditorConfig *argWidget = editor->editorConfig();
|
||||||
if (!argWidget) {
|
if (!argWidget) {
|
||||||
argWidget = new GitRefLogArgumentsWidget(settings(), editor->toolBar());
|
argWidget = new GitRefLogArgumentsWidget(settings(), editor->toolBar());
|
||||||
|
if (!ref.isEmpty())
|
||||||
|
argWidget->setBaseArguments({ref});
|
||||||
connect(argWidget, &VcsBaseEditorConfig::commandExecutionRequested, this,
|
connect(argWidget, &VcsBaseEditorConfig::commandExecutionRequested, this,
|
||||||
[=] { this->reflog(workingDirectory); });
|
[=] { this->reflog(workingDir, ref); });
|
||||||
editor->setEditorConfig(argWidget);
|
editor->setEditorConfig(argWidget);
|
||||||
}
|
}
|
||||||
editor->setWorkingDirectory(workingDirectory);
|
editor->setWorkingDirectory(workingDir);
|
||||||
|
|
||||||
QStringList arguments = {"reflog", noColorOption, decorateOption};
|
QStringList arguments = {"reflog", noColorOption, decorateOption};
|
||||||
arguments << argWidget->arguments();
|
arguments << argWidget->arguments();
|
||||||
@@ -1083,7 +1087,7 @@ void GitClient::reflog(const QString &workingDirectory)
|
|||||||
if (logCount > 0)
|
if (logCount > 0)
|
||||||
arguments << "-n" << QString::number(logCount);
|
arguments << "-n" << QString::number(logCount);
|
||||||
|
|
||||||
vcsExec(workingDirectory, arguments, editor);
|
vcsExec(workingDir, arguments, editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not show "0000" or "^32ae4"
|
// Do not show "0000" or "^32ae4"
|
||||||
|
@@ -167,7 +167,7 @@ public:
|
|||||||
void status(const QString &workingDirectory);
|
void status(const QString &workingDirectory);
|
||||||
void log(const QString &workingDirectory, const QString &fileName = QString(),
|
void log(const QString &workingDirectory, const QString &fileName = QString(),
|
||||||
bool enableAnnotationContextMenu = false, const QStringList &args = QStringList());
|
bool enableAnnotationContextMenu = false, const QStringList &args = QStringList());
|
||||||
void reflog(const QString &workingDirectory);
|
void reflog(const QString &workingDirectory, const QString &branch = {});
|
||||||
VcsBase::VcsBaseEditorWidget *annotate(
|
VcsBase::VcsBaseEditorWidget *annotate(
|
||||||
const QString &workingDir, const QString &file, const QString &revision = QString(),
|
const QString &workingDir, const QString &file, const QString &revision = QString(),
|
||||||
int lineNumber = -1, const QStringList &extraOptions = QStringList()) override;
|
int lineNumber = -1, const QStringList &extraOptions = QStringList()) override;
|
||||||
|
@@ -278,6 +278,7 @@ public:
|
|||||||
void blameFile();
|
void blameFile();
|
||||||
void logProject();
|
void logProject();
|
||||||
void logRepository();
|
void logRepository();
|
||||||
|
void reflogRepository();
|
||||||
void undoFileChanges(bool revertStaging);
|
void undoFileChanges(bool revertStaging);
|
||||||
void resetRepository();
|
void resetRepository();
|
||||||
void recoverDeletedFiles();
|
void recoverDeletedFiles();
|
||||||
@@ -707,7 +708,7 @@ GitPluginPrivate::GitPluginPrivate()
|
|||||||
context, true, std::bind(&GitPluginPrivate::logRepository, this));
|
context, true, std::bind(&GitPluginPrivate::logRepository, this));
|
||||||
|
|
||||||
createRepositoryAction(localRepositoryMenu, tr("Reflog"), "Git.ReflogRepository",
|
createRepositoryAction(localRepositoryMenu, tr("Reflog"), "Git.ReflogRepository",
|
||||||
context, true, &GitClient::reflog);
|
context, true, std::bind(&GitPluginPrivate::reflogRepository, this));
|
||||||
|
|
||||||
createRepositoryAction(localRepositoryMenu, tr("Clean..."), "Git.CleanRepository",
|
createRepositoryAction(localRepositoryMenu, tr("Clean..."), "Git.CleanRepository",
|
||||||
context, true, [this] { cleanRepository(); });
|
context, true, [this] { cleanRepository(); });
|
||||||
@@ -1057,6 +1058,13 @@ void GitPluginPrivate::logRepository()
|
|||||||
m_gitClient.log(state.topLevel());
|
m_gitClient.log(state.topLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GitPluginPrivate::reflogRepository()
|
||||||
|
{
|
||||||
|
const VcsBasePluginState state = currentState();
|
||||||
|
QTC_ASSERT(state.hasTopLevel(), return);
|
||||||
|
m_gitClient.reflog(state.topLevel());
|
||||||
|
}
|
||||||
|
|
||||||
void GitPluginPrivate::undoFileChanges(bool revertStaging)
|
void GitPluginPrivate::undoFileChanges(bool revertStaging)
|
||||||
{
|
{
|
||||||
if (IDocument *document = EditorManager::currentDocument()) {
|
if (IDocument *document = EditorManager::currentDocument()) {
|
||||||
|
Reference in New Issue
Block a user