Commit 89e0a66f authored by Friedemann Kleint's avatar Friedemann Kleint

Git: Recognize SHA1s from 7 to 40 digits.

Qt's grafts have 9-digit SHA1s which did not work
with the previous 7-8/40 character limits.

Change-Id: I3989405d00b575a6efb7dc6a467cbb24df9f3db5
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 55e45ff3
......@@ -51,8 +51,7 @@
#include <QTextEdit>
#include <QTextBlock>
#define CHANGE_PATTERN_8C "[a-f0-9]{7,8}"
#define CHANGE_PATTERN_40C "[a-f0-9]{40,40}"
#define CHANGE_PATTERN "[a-f0-9]{7,40}"
namespace Git {
namespace Internal {
......@@ -61,11 +60,9 @@ namespace Internal {
GitEditor::GitEditor(const VcsBase::VcsBaseEditorParameters *type,
QWidget *parent) :
VcsBase::VcsBaseEditorWidget(type, parent),
m_changeNumberPattern8(QLatin1String(CHANGE_PATTERN_8C)),
m_changeNumberPattern40(QLatin1String(CHANGE_PATTERN_40C))
m_changeNumberPattern(QLatin1String(CHANGE_PATTERN))
{
QTC_ASSERT(m_changeNumberPattern8.isValid(), return);
QTC_ASSERT(m_changeNumberPattern40.isValid(), return);
QTC_ASSERT(m_changeNumberPattern.isValid(), return);
/* Diff format:
diff --git a/src/plugins/git/giteditor.cpp b/src/plugins/git/giteditor.cpp
index 40997ff..4e49337 100644
......@@ -85,11 +82,11 @@ QSet<QString> GitEditor::annotationChanges() const
if (txt.isEmpty())
return changes;
// Hunt for first change number in annotation: "<change>:"
QRegExp r(QLatin1String("^(" CHANGE_PATTERN_8C ") "));
QRegExp r(QLatin1String("^(" CHANGE_PATTERN ") "));
QTC_ASSERT(r.isValid(), return changes);
if (r.indexIn(txt) != -1) {
changes.insert(r.cap(1));
r.setPattern(QLatin1String("\n(" CHANGE_PATTERN_8C ") "));
r.setPattern(QLatin1String("\n(" CHANGE_PATTERN ") "));
QTC_ASSERT(r.isValid(), return changes);
int pos = 0;
while ((pos = r.indexIn(txt, pos)) != -1) {
......@@ -108,9 +105,7 @@ QString GitEditor::changeUnderCursor(const QTextCursor &c) const
if (!cursor.hasSelection())
return QString();
const QString change = cursor.selectedText();
if (m_changeNumberPattern8.exactMatch(change))
return change;
if (m_changeNumberPattern40.exactMatch(change))
if (m_changeNumberPattern.exactMatch(change))
return change;
return QString();
}
......
......@@ -68,8 +68,7 @@ private:
void addChangeActions(QMenu *menu, const QString &change);
QString revisionSubject(const QTextBlock &inBlock) const;
mutable QRegExp m_changeNumberPattern8;
mutable QRegExp m_changeNumberPattern40;
mutable QRegExp m_changeNumberPattern;
QString m_currentChange;
};
......
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