MCPcopy Create free account
hub / github.com/cli/cli / WorktreeForBranch

Function WorktreeForBranch

git/objects.go:90–98  ·  view source on GitHub ↗

WorktreeForBranch returns the worktree that has branch checked out, or nil when the branch is not associated with any worktree.

(worktrees []Worktree, branch string)

Source from the content-addressed store, hash-verified

88// WorktreeForBranch returns the worktree that has branch checked out, or nil
89// when the branch is not associated with any worktree.
90func WorktreeForBranch(worktrees []Worktree, branch string) *Worktree {
91 branchRef := "refs/heads/" + branch
92 for i := range worktrees {
93 if worktrees[i].Ref == branchRef {
94 return &worktrees[i]
95 }
96 }
97 return nil
98}

Calls

no outgoing calls