forked from qt-creator/qt-creator
Git: Return empty list for remote branches when there are none
The function currently returns "<Detached HEAD>" Change-Id: I68786d5521549aacc29807632a5054593db24b3b Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
b8c99a66b3
commit
5b49ed506b
@@ -2094,6 +2094,7 @@ QStringList GitClient::synchronousRepositoryBranches(const QString &repositoryUR
|
||||
QString headSha;
|
||||
// split "82bfad2f51d34e98b18982211c82220b8db049b<tab>refs/heads/master"
|
||||
bool headFound = false;
|
||||
bool branchFound = false;
|
||||
foreach (const QString &line, resp.stdOut().split('\n')) {
|
||||
if (line.endsWith("\tHEAD")) {
|
||||
QTC_CHECK(headSha.isNull());
|
||||
@@ -2104,6 +2105,7 @@ QStringList GitClient::synchronousRepositoryBranches(const QString &repositoryUR
|
||||
const QString pattern = "\trefs/heads/";
|
||||
const int pos = line.lastIndexOf(pattern);
|
||||
if (pos != -1) {
|
||||
branchFound = true;
|
||||
const QString branchName = line.mid(pos + pattern.count());
|
||||
if (!headFound && line.startsWith(headSha)) {
|
||||
branches[0] = branchName;
|
||||
@@ -2113,6 +2115,8 @@ QStringList GitClient::synchronousRepositoryBranches(const QString &repositoryUR
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!branchFound)
|
||||
branches.clear();
|
||||
return branches;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user