IsPrimaryWorktree reports whether `path` is inside the primary worktree of its repository. True iff the git dir equals the common dir.
(path string)
| 43 | // IsPrimaryWorktree reports whether `path` is inside the primary worktree of |
| 44 | // its repository. True iff the git dir equals the common dir. |
| 45 | func 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. |