MCPcopy Create free account
hub / github.com/LegacyCodeHQ/clarity-cli / IsPrimaryWorktree

Function IsPrimaryWorktree

vcs/git/git_worktree.go:45–55  ·  view source on GitHub ↗

IsPrimaryWorktree reports whether `path` is inside the primary worktree of its repository. True iff the git dir equals the common dir.

(path string)

Source from the content-addressed store, hash-verified

43// IsPrimaryWorktree reports whether `path` is inside the primary worktree of
44// its repository. True iff the git dir equals the common dir.
45func IsPrimaryWorktree(path string) (bool, error) {
46 gitDir, err := GetGitDir(path)
47 if err != nil {
48 return false, err
49 }
50 commonDir, err := GetCommonDir(path)
51 if err != nil {
52 return false, err
53 }
54 return resolveSymlinks(gitDir) == resolveSymlinks(commonDir), nil
55}
56
57// ListWorktrees enumerates all worktrees registered with the repository
58// containing `path`. The primary worktree is always the first entry.

Callers 3

planInitialReposFunction · 0.92
TestIsPrimaryWorktreeFunction · 0.85

Calls 3

GetGitDirFunction · 0.85
GetCommonDirFunction · 0.85
resolveSymlinksFunction · 0.70

Tested by 1

TestIsPrimaryWorktreeFunction · 0.68