Fix branch name parsing: strip + prefix from worktree branches

This commit is contained in:
Levi Neely 2026-07-23 16:07:01 +02:00
parent b8218878c5
commit 6e8e2845a0
1 changed files with 4 additions and 2 deletions

View File

@ -1007,8 +1007,8 @@ QString GitPlusPlusView::selectedBranch() const
if (!item)
return {};
QString text = item->text();
// Remove leading "* " for current branch
if (text.startsWith(QStringLiteral("* ")))
// Remove leading "* " for current branch or "+ " for worktree branch
if (text.startsWith(QStringLiteral("* ")) || text.startsWith(QStringLiteral("+ ")))
text = text.mid(2);
return text.trimmed();
}
@ -1220,6 +1220,8 @@ void GitPlusPlusView::onBranchFinished(int exitCode, QProcess::ExitStatus)
if (branch.startsWith(QLatin1Char('*'))) {
current = branch.mid(2);
branch = branch.mid(2);
} else if (branch.startsWith(QLatin1Char('+'))) {
branch = branch.mid(2);
}
// Skip HEAD pointer in remotes
if (branch.contains(QStringLiteral(" -> "))) continue;