MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / getWorktreeCountFromFs

Function getWorktreeCountFromFs

src/utils/git/gitFilesystem.ts:686–699  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

684 * The main worktree is not listed there, so add 1.
685 */
686export async function getWorktreeCountFromFs(): Promise<number> {
687 try {
688 const gitDir = await resolveGitDir()
689 if (!gitDir) {
690 return 0
691 }
692 const commonDir = (await getCommonDir(gitDir)) ?? gitDir
693 const entries = await readdir(join(commonDir, 'worktrees'))
694 return entries.length + 1
695 } catch {
696 // No worktrees directory means only the main worktree
697 return 1
698 }
699}

Callers 1

getWorktreeCountFunction · 0.85

Calls 3

resolveGitDirFunction · 0.85
getCommonDirFunction · 0.85
readdirFunction · 0.85

Tested by

no test coverage detected