Git: Use git describe for topic before falling back to "Detach Head"

Change-Id: Iaf8be78ac3b6119f01ad3491eec7eccfa5f45e26
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Orgad Shaneh
2014-02-26 22:03:55 +02:00
committed by Orgad Shaneh
parent f74021260a
commit 1817c48c7b

View File

@@ -2052,9 +2052,19 @@ QString GitClient::synchronousTopic(const QString &workingDirectory)
(derefInd == -1) ? -1 : derefInd - remoteStart.size());
}
}
if (!remoteBranch.isEmpty())
return remoteBranch;
// No tag
return remoteBranch.isEmpty() ? tr("Detached HEAD") : remoteBranch;
// No tag or remote branch - try git describe
QByteArray output;
QStringList arguments;
arguments << QLatin1String("describe");
if (fullySynchronousGit(workingDirectory, arguments, &output, 0, VcsBasePlugin::NoOutput)) {
const QString describeOutput = commandOutputFromLocal8Bit(output.trimmed());
if (!describeOutput.isEmpty())
return describeOutput;
}
return tr("Detached HEAD");
}
bool GitClient::synchronousRevParseCmd(const QString &workingDirectory, const QString &ref,