git icon indicating copy to clipboard operation
git copied to clipboard

Add support for worktrees in `fromExisting`

Open dnys1 opened this issue 2 years ago • 0 comments

Adds support for worktree paths in GitDir.fromExisting. Worktrees are identified based on whether the $GIT_DIR and $GIT_COMMON_DIR are different (although not sure there are any edge cases worth considering here).

The logic is refactored a bit to make clear that the only times when GitDir.fromExisting throws are in the cases where:

  • gitDirRoot is not a git directory or worktree
  • gitDirRoot is a subdirectory of a git directory or worktree and allowSubdirectory is false.

dnys1 avatar Aug 15 '23 21:08 dnys1