Commit 12a99d47 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Tobias Hunger
Browse files

Git: Do not display invalid commit as blame candidate



Change-Id: Ia08775b2e4364f405d223a9b49971ae70c04965a
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent 16a81369
......@@ -1040,9 +1040,8 @@ bool GitClient::synchronousParentRevisions(const QString &workingDirectory,
QByteArray outputTextData;
QByteArray errorText;
QStringList arguments;
if (parents && (revision == QLatin1String("00000000"))) { // Not Committed Yet
parents->clear();
parents->append(QLatin1String("HEAD"));
if (parents && !isValidRevision(revision)) { // Not Committed Yet
*parents = QStringList(QLatin1String("HEAD"));
return true;
}
arguments << QLatin1String("rev-list") << QLatin1String(GitClient::noColorOption)
......@@ -1450,6 +1449,16 @@ QProcessEnvironment GitClient::processEnvironment() const
return environment;
}
bool GitClient::isValidRevision(const QString &revision) const
{
if (revision.length() < 1)
return false;
for (int i = 0; i < revision.length(); ++i)
if (revision.at(i) != QLatin1Char('0'))
return true;
return false;
}
// Synchronous git execution using Utils::SynchronousProcess, with
// log windows updating.
Utils::SynchronousProcessResponse GitClient::synchronousGit(const QString &workingDirectory,
......
......@@ -220,6 +220,8 @@ public:
QProcessEnvironment processEnvironment() const;
bool isValidRevision(const QString &revision) const;
static QString msgNoChangedFiles();
static const char *noColorOption;
......
......@@ -250,6 +250,11 @@ QStringList GitEditor::annotationPreviousVersions(const QString &revision) const
return revisions;
}
bool GitEditor::isValidRevision(const QString &revision) const
{
return GitPlugin::instance()->gitClient()->isValidRevision(revision);
}
} // namespace Internal
} // namespace Git
......@@ -63,6 +63,7 @@ private:
virtual QString fileNameFromDiffSpecification(const QTextBlock &diffFileName) const;
virtual QString decorateVersion(const QString &revision) const;
virtual QStringList annotationPreviousVersions(const QString &revision) const;
virtual bool isValidRevision(const QString &revision) const;
mutable QRegExp m_changeNumberPattern8;
mutable QRegExp m_changeNumberPattern40;
......
......@@ -351,7 +351,8 @@ void ChangeTextCursorHandler::fillContextMenu(QMenu *menu, EditorContentType typ
menu->addAction(createCopyRevisionAction(m_currentChange));
menu->addAction(createDescribeAction(m_currentChange));
menu->addSeparator();
menu->addAction(createAnnotateAction(editorWidget()->decorateVersion(m_currentChange), false));
if (editorWidget()->isValidRevision(m_currentChange))
menu->addAction(createAnnotateAction(editorWidget()->decorateVersion(m_currentChange), false));
const QStringList previousVersions = editorWidget()->annotationPreviousVersions(m_currentChange);
if (!previousVersions.isEmpty()) {
foreach (const QString &pv, previousVersions)
......@@ -1428,6 +1429,12 @@ QString VcsBaseEditorWidget::decorateVersion(const QString &revision) const
return revision;
}
bool VcsBaseEditorWidget::isValidRevision(const QString &revision) const
{
Q_UNUSED(revision);
return true;
}
void VcsBaseEditorWidget::slotApplyDiffChunk()
{
const QAction *a = qobject_cast<QAction *>(sender());
......
......@@ -252,6 +252,8 @@ private:
// Implement to return the previous version[s] of an annotation change
// for "Annotate previous version"
virtual QStringList annotationPreviousVersions(const QString &revision) const;
// Implement to validate revisions
virtual bool isValidRevision(const QString &revision) const;
// cut out chunk and determine file name.
DiffChunk diffChunk(QTextCursor cursor) const;
......
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