forked from qt-creator/qt-creator
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 <orgads@gmail.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
0d9a56ab3f
commit
97925eaf54
@@ -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);
|
||||
branch.remove(QLatin1Char('\n'));
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user