|
Previously, `git-branch-list` didn't work inside worktree directories.
It expected the current directory to be a descendant of the main Git
repository directory, which isn't the case for worktrees.
Given a Git repository `test-repo`:
$ git rev-parse --show-toplevel
/tmp/test-repo
$ git rev-parse --git-common-dir
.git
$ mkdir subdir && cd subdir
$ git rev-parse --git-common-dir
../.git
$ cd -
$ git worktree add ../test-repo-worktree
$ cd ../test-repo-worktree
$ git rev-parse --show-toplevel
/tmp/test-repo-worktree
$ git rev-parse --git-common-dir
/tmp/test-repo/.git
The `git rev-parse --show-toplevel` command outputs the top-level path
of the worktree, not the main repository directory. Using `git rev-parse
--git-common-dir`, we can get the correct path whether we're in a
subdirectory or a worktree.
|