[git] IJPL-203021 Fix current branch filtering condition

(cherry picked from commit 292319e954be5f377b33e4f2e1f7a705c6e96f5a)

IJ-CR-173023

GitOrigin-RevId: fd05c4c301a36e4758cb05df2ee2672e86b96b08
This commit is contained in:
Ilia.Shulgin
2025-08-20 11:44:55 +02:00
committed by intellij-monorepo-bot
parent 45e789519f
commit bbd6721d5f

View File

@@ -65,8 +65,10 @@ private class GitCompareWithBranchesTreeModel(project: Project, repository: GitR
override fun getLocalBranches(): Collection<GitStandardLocalBranch> = repository.state.localBranches.skipCurrentBranch()
override fun getRecentBranches(): Collection<GitStandardLocalBranch> = super.getRecentBranches().skipCurrentBranch()
private fun Collection<GitStandardLocalBranch>.skipCurrentBranch(): Collection<GitStandardLocalBranch> =
filter { repository.state.currentRef?.matches(it) == false }
private fun Collection<GitStandardLocalBranch>.skipCurrentBranch(): Collection<GitStandardLocalBranch> {
val currentBranch = repository.state.currentBranch ?: return this
return filter { it != currentBranch }
}
override fun getPreferredSelection(): TreePath? {
return getPreferredBranch()?.let { createTreePathFor(this, it) }