GetGitDir returns the absolute path to the git directory for `path`. For the primary worktree this equals GetCommonDir; for a linked worktree this is the per-worktree gitdir under ` /worktrees/ `.
(path string)
| 22 | // For the primary worktree this equals GetCommonDir; for a linked worktree |
| 23 | // this is the per-worktree gitdir under `<common>/worktrees/<name>`. |
| 24 | func GetGitDir(path string) (string, error) { |
| 25 | stdout, stderr, err := runGitCommand(path, "rev-parse", "--absolute-git-dir") |
| 26 | if err != nil { |
| 27 | return "", gitCommandError(err, stderr) |
| 28 | } |
| 29 | return strings.TrimSpace(string(stdout)), nil |
| 30 | } |
| 31 | |
| 32 | // GetCommonDir returns the absolute path to the common git directory — the |
| 33 | // primary repository's `.git`. Identical for the primary and every linked |