forked from qt-creator/qt-creator
Git: dereference topic result
sometimes tags are annotated, and have different hash than head - now all will be good with them too. Change-Id: Ibd66b78e6dbc7f181ba05f45339f2d97bb611602 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -1186,7 +1186,8 @@ bool GitClient::synchronousHeadRefs(const QString &workingDirectory, QStringList
|
|||||||
QString *errorMessage)
|
QString *errorMessage)
|
||||||
{
|
{
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << QLatin1String("show-ref") << QLatin1String("--head") << QLatin1String("--abbrev=10");
|
args << QLatin1String("show-ref") << QLatin1String("--head")
|
||||||
|
<< QLatin1String("--abbrev=10") << QLatin1String("--dereference");
|
||||||
QByteArray outputText;
|
QByteArray outputText;
|
||||||
QByteArray errorText;
|
QByteArray errorText;
|
||||||
const bool rc = fullySynchronousGit(workingDirectory, args, &outputText, &errorText);
|
const bool rc = fullySynchronousGit(workingDirectory, args, &outputText, &errorText);
|
||||||
@@ -1258,15 +1259,21 @@ QString GitClient::synchronousTopic(const QString &workingDirectory)
|
|||||||
if (!synchronousHeadRefs(workingDirectory, &references))
|
if (!synchronousHeadRefs(workingDirectory, &references))
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
QString tagStart = QLatin1String("refs/tags/");
|
const QString tagStart(QLatin1String("refs/tags/"));
|
||||||
QString remoteStart = QLatin1String("refs/remotes/");
|
const QString remoteStart(QLatin1String("refs/remotes/"));
|
||||||
|
const QString dereference(QLatin1String("^{}"));
|
||||||
QString remoteBranch;
|
QString remoteBranch;
|
||||||
|
|
||||||
foreach (const QString &ref, references) {
|
foreach (const QString &ref, references) {
|
||||||
if (ref.startsWith(tagStart))
|
int derefInd = ref.indexOf(dereference);
|
||||||
return data.topic = ref.mid(10);
|
if (ref.startsWith(tagStart)) {
|
||||||
if (ref.startsWith(remoteStart))
|
return data.topic = ref.mid(tagStart.size(),
|
||||||
remoteBranch = ref.mid(13);
|
(derefInd == -1) ? -1 : derefInd - tagStart.size());
|
||||||
|
}
|
||||||
|
if (ref.startsWith(remoteStart)) {
|
||||||
|
remoteBranch = ref.mid(remoteStart.size(),
|
||||||
|
(derefInd == -1) ? -1 : derefInd - remoteStart.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// No tag
|
// No tag
|
||||||
|
Reference in New Issue
Block a user