Commit 97925eaf authored by Mathias Hasselmann's avatar Mathias Hasselmann Committed by Orgad Shaneh
Browse files

git: Don't use the "--short" for git symbolic-ref

We cannot use the "--short" switch since it only got introduced with git
1.7.10, which is not installed by default on popular Linux distributions
like Ubuntu 12.04.1 LTS.

Therefore stripping the "refs/heads/" prefix manually.

Change-Id: I3fb8e07e90e2ee8fdaa50836c1e982b47219e790
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <>
parent 0d9a56ab
......@@ -1103,12 +1103,20 @@ QString GitClient::synchronousBranch(const QString &workingDirectory)
QByteArray outputTextData;
QStringList arguments;
arguments << QLatin1String("symbolic-ref") << QLatin1String("--short") << QLatin1String("HEAD");
arguments << QLatin1String("symbolic-ref") << QLatin1String("HEAD");
// if HEAD is detached, the command is expected to fail.
if (!fullySynchronousGit(workingDirectory, arguments, &outputTextData))
return QString();
QString branch = commandOutputFromLocal8Bit(outputTextData);
// Must strip the "refs/heads/" prefix manually since the --short switch
// of git symbolic-ref only got introduced with git 1.7.10, which is not
// available for all popular Linux distributions yet.
const QString refsHeadsPrefix = QLatin1String("refs/heads/");
if (branch.startsWith(refsHeadsPrefix))
branch.remove(0, refsHeadsPrefix.count());
return branch;
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