Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ uint qHash(const ShaString&); // optimized custom hash for sha strings
namespace QGit {

// minimum git version required
extern const QString GIT_VERSION;
extern const QString GIT_VERSION_REQUIRED;

// tab pages
enum TabType {
Expand Down
48 changes: 46 additions & 2 deletions src/git.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,62 @@ Git::Git(QObject* p) : QObject(p) {
revsFiles.reserve(MAX_DICT_SIZE);
}

int Git::gitVersionCompare(QString lhs, QString rhs) {
lhs = lhs.trimmed();
rhs = rhs.trimmed();

QRegExp versionRegex("\\d+\\.\\d+\\.\\d+(-rc\\d+)?");
if (!versionRegex.exactMatch(lhs)) {
dbp("ASSERT: Incorrect git version given: \"%1\"", lhs);
return -1;
}
if (!versionRegex.exactMatch(rhs)) {
dbp("ASSERT: Incorrect git version given: \"%1\"", rhs);
return -1;
}

lhs.replace("-rc", ".");
rhs.replace("-rc", ".");
QStringList lcs = lhs.split('.');
QStringList rcs = rhs.split('.');

for (int i = 0; i < 3; ++i) {
uint lc = lcs.takeFirst().toUInt();
uint rc = rcs.takeFirst().toUInt();
if (lc != rc)
return lc < rc ? -1 : 1;
}
if (lcs.isEmpty() != rcs.isEmpty()) // -rc present in one only
return lcs.isEmpty() ? 1 : -1;
if (lcs.isEmpty()) { // -rc present in both
uint lc = lcs.takeFirst().toUInt();
uint rc = rcs.takeFirst().toUInt();
if (lc != rc)
return lc < rc ? -1 : 1;
}
return 0;
}

void Git::checkEnvironment() {

QString version;
if (run("git --version", &version)) {

version = version.section(' ', -1, -1).section('.', 0, 2);
if (version < GIT_VERSION) {
if (gitVersionCompare(version, GIT_VERSION_REQUIRED) < 0) {

// simply send information, the 'not compatible version'
// policy should be implemented upstream
const QString cmd("Current git version is " + version +
" but is required " + GIT_VERSION + " or better");
" but is required " + GIT_VERSION_REQUIRED + " or better");

const QString errorDesc("Your installed git is too old."
"\nPlease upgrade to avoid possible misbehaviours.");

MainExecErrorEvent* e = new MainExecErrorEvent(cmd, errorDesc);
QApplication::postEvent(parent(), e);
}
gitVersion = version;
} else {
dbs("Cannot find git files");
return;
Expand Down Expand Up @@ -2166,6 +2203,9 @@ bool Git::startRevList(SCList args, FileHistory* fh) {
} else
{} // initCmd << QString("--early-output"); currently disabled

if (gitVersionCompare(gitVersion, "2.10.0") >= 0)
initCmd << "--no-show-signature";

return startParseProc(initCmd + args, fh, QString());
}

Expand All @@ -2185,6 +2225,10 @@ bool Git::startUnappliedList() {
"--pretty=format:" GIT_LOG_FORMAT "%b ^HEAD");

QStringList sl(cmd.split(' '));

if (gitVersionCompare(gitVersion, "2.10.0") >= 0)
sl << "--no-show-signature";

sl << unAppliedShaList;
return startParseProc(sl, revData, QString());
}
Expand Down
2 changes: 2 additions & 0 deletions src/git.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Q_OBJECT
typedef QList<TreeEntry> TreeInfo;

void setDefaultModel(FileHistory* fh) { revData = fh; }
static int gitVersionCompare(QString lhs, QString rhs);
void checkEnvironment();
void userInfo(SList info);
const QStringList getGitConfigList(bool global);
Expand Down Expand Up @@ -267,6 +268,7 @@ private slots:
QString curBranchName;
int filesLoadingStartOfs;
bool cacheNeedsUpdate;
QString gitVersion;
bool errorReportingEnabled;
bool isMergeHead;
bool isStGIT;
Expand Down
2 changes: 1 addition & 1 deletion src/namespace_def.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const ShaString QGit::toPersistentSha(const QString& sha, QVector<QByteArray>& v
}

// minimum git version required
const QString QGit::GIT_VERSION = "1.5.5";
const QString QGit::GIT_VERSION_REQUIRED = "1.5.5";

// colors
const QColor QGit::BROWN = QColor(150, 75, 0);
Expand Down