if not worktree:
return True
+ # If .git is a symlink, worktree result might be the target.
+ if worktree == str(git_dir().resolve()):
+ return True
+
# NB: worktree path is supposed to be absolute from for-each-ref, but it's
# not always, so we have to resolve it. https://crbug.com/git/88
worktree = (git_dir() / worktree).resolve()