Commit 42547062 authored by Petar Perisin's avatar Petar Perisin
Browse files

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: default avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 19a4810c
...@@ -1186,7 +1186,8 @@ bool GitClient::synchronousHeadRefs(const QString &workingDirectory, QStringList ...@@ -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) ...@@ -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
......
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