Commit e1e19360 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

Git: Add reflog

Change-Id: Id328492826bdcf4b7f7e6933a9dc3931174de0fb
Reviewed-by: default avatarPetar Perisin <petar.perisin@gmail.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent bbbdee7c
......@@ -1151,6 +1151,27 @@ void GitClient::log(const QString &workingDirectory, const QString &fileName,
executeGit(workingDirectory, arguments, editor);
}
void GitClient::reflog(const QString &workingDirectory)
{
const QString title = tr("Git Reflog \"%1\"").arg(workingDirectory);
const Core::Id editorId = Git::Constants::GIT_LOG_EDITOR_ID;
VcsBase::VcsBaseEditorWidget *editor = findExistingVCSEditor("reflogRepository", workingDirectory);
if (!editor) {
editor = createVcsEditor(editorId, title, workingDirectory, CodecLogOutput,
"reflogRepository", workingDirectory, 0);
}
QStringList arguments;
arguments << QLatin1String("reflog") << QLatin1String(noColorOption)
<< QLatin1String(decorateOption);
int logCount = settings()->intValue(GitSettings::logCountKey);
if (logCount > 0)
arguments << QLatin1String("-n") << QString::number(logCount);
executeGit(workingDirectory, arguments, editor);
}
// Do not show "0000" or "^32ae4"
static inline bool canShow(const QString &sha)
{
......
......@@ -148,6 +148,7 @@ public:
void status(const QString &workingDirectory);
void log(const QString &workingDirectory, const QString &fileName = QString(),
bool enableAnnotationContextMenu = false, const QStringList &args = QStringList());
void reflog(const QString &workingDirectory);
void blame(const QString &workingDirectory, const QStringList &args, const QString &fileName,
const QString &revision = QString(), int lineNumber = -1);
void reset(const QString &workingDirectory, const QString &argument, const QString &commit = QString());
......
......@@ -408,6 +408,11 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
globalcontext, true,
SLOT(logRepository()));
createRepositoryAction(localRepositoryMenu,
tr("Reflog"), Core::Id("Git.ReflogRepository"),
globalcontext, true,
SLOT(reflogRepository()));
createRepositoryAction(localRepositoryMenu,
tr("Clean..."), Core::Id("Git.CleanRepository"),
globalcontext, true, SLOT(cleanRepository()));
......@@ -785,6 +790,13 @@ void GitPlugin::logRepository()
m_gitClient->log(state.topLevel());
}
void GitPlugin::reflogRepository()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
m_gitClient->reflog(state.topLevel());
}
void GitPlugin::undoFileChanges(bool revertStaging)
{
if (!ensureAllDocumentsSaved())
......
......@@ -115,6 +115,7 @@ private slots:
void blameFile();
void logProject();
void logRepository();
void reflogRepository();
void undoFileChanges(bool revertStaging = true);
void undoUnstagedFileChanges();
void resetRepository();
......
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