forked from qt-creator/qt-creator
Git: Show detached HEAD in branches view when applicable
Fixes: QTCREATORBUG-21311 Change-Id: Ia4297d23a965d83ea2814bd1e41f35a3017b8e9b Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
e0a1b171f1
commit
92431932e3
@@ -1557,14 +1557,20 @@ bool GitClient::synchronousRevParseCmd(const QString &workingDirectory, const QS
|
||||
}
|
||||
|
||||
// Retrieve head revision
|
||||
QString GitClient::synchronousTopRevision(const QString &workingDirectory)
|
||||
QString GitClient::synchronousTopRevision(const QString &workingDirectory, QDateTime *dateTime)
|
||||
{
|
||||
QString revision;
|
||||
QString errorMessage;
|
||||
if (!synchronousRevParseCmd(workingDirectory, HEAD, &revision, &errorMessage))
|
||||
const QStringList arguments = {"show", "-s", "--pretty=format:%H:%ct", HEAD};
|
||||
const SynchronousProcessResponse resp = vcsFullySynchronousExec(
|
||||
workingDirectory, arguments, silentFlags);
|
||||
if (resp.result != SynchronousProcessResponse::Finished)
|
||||
return QString();
|
||||
|
||||
return revision;
|
||||
const QStringList output = resp.stdOut().trimmed().split(':');
|
||||
if (dateTime && output.size() > 1) {
|
||||
bool ok = false;
|
||||
const qint64 timeT = output.at(1).toLongLong(&ok);
|
||||
*dateTime = ok ? QDateTime::fromSecsSinceEpoch(timeT) : QDateTime();
|
||||
}
|
||||
return output.first();
|
||||
}
|
||||
|
||||
void GitClient::synchronousTagsForCommit(const QString &workingDirectory, const QString &revision,
|
||||
|
||||
Reference in New Issue
Block a user