Pass only the branch name to BranchesBelow

The commits panel will need to call it. All it knows is the name of the
checked-out branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-11-08 12:43:36 +01:00
co-authored by Claude Opus 5.5
parent 33f52279c4
commit 633bedf4fd
3 changed files with 10 additions and 10 deletions
+7 -7
View File
@@ -6,11 +6,11 @@ import (
"github.com/samber/lo"
)
// Returns the branches stacked below the given branch: those whose tip is one
// of the given commits of the branch that hasn't been merged into a main
// branch yet. The branch itself and the main branches are left out. The
// result is in the order in which the tips appear in commits, so the branch
// closest to the given one comes first.
// Returns the branches stacked below the branch with the given name: those
// whose tip is one of the given commits of the branch that hasn't been
// merged into a main branch yet. The branch itself and the main branches
// are left out. The result is in the order in which the tips appear in
// commits, so the branch closest to the given one comes first.
//
// A commit counts as merged if the remote branch of a main branch contains it
// (this is what the commit's status says), but also if the local main branch
@@ -23,12 +23,12 @@ import (
func BranchesBelow(
commits []*models.Commit,
branches []*models.Branch,
branch *models.Branch,
branchName string,
mainBranches []string,
) []*models.Branch {
branchesByTip := map[string][]*models.Branch{}
for _, other := range branches {
if !lo.Contains(mainBranches, other.Name) && other.Name != branch.Name {
if !lo.Contains(mainBranches, other.Name) && other.Name != branchName {
branchesByTip[other.CommitHash] = append(branchesByTip[other.CommitHash], other)
}
}
+1 -1
View File
@@ -141,7 +141,7 @@ func TestBranchesBelow(t *testing.T) {
if s.current != nil {
branch = s.current
}
result := BranchesBelow(s.commits, s.branches, branch, mainBranches)
result := BranchesBelow(s.commits, s.branches, branch.Name, mainBranches)
names := lo.Map(result, func(b *models.Branch, _ int) string { return b.Name })
assert.Equal(t, s.expected, names)
})
+2 -2
View File
@@ -129,7 +129,7 @@ func (self *SyncController) pushCurrentBranch(currentBranch *models.Branch) erro
// The branches stacked below the current one that have commits to push
func (self *SyncController) unpushedBranchesBelow(currentBranch *models.Branch) []*models.Branch {
branchesBelow := branchstack.BranchesBelow(
self.c.Model().Commits, self.c.Model().Branches, currentBranch, self.c.UserConfig().Git.MainBranches)
self.c.Model().Commits, self.c.Model().Branches, currentBranch.Name, self.c.UserConfig().Git.MainBranches)
return lo.Filter(branchesBelow, func(branch *models.Branch, _ int) bool {
// Pushing a branch whose remote branch was deleted would recreate it.
@@ -290,7 +290,7 @@ func (self *SyncController) pullCurrentBranch(currentBranch *models.Branch, bran
// those that diverged from them only because they were rewritten
func (self *SyncController) updatableBranchesBelow(currentBranch *models.Branch) []*models.Branch {
branchesBelow := branchstack.BranchesBelow(
self.c.Model().Commits, self.c.Model().Branches, currentBranch, self.c.UserConfig().Git.MainBranches)
self.c.Model().Commits, self.c.Model().Branches, currentBranch.Name, self.c.UserConfig().Git.MainBranches)
return lo.Filter(branchesBelow, func(branch *models.Branch, _ int) bool {
// Updating a branch that is checked out in another worktree changes