pub fn relative_worktree_path(repo: &Repository, path: &Path) -> Option<String>Expand description
Compute path’s root-relative path, robust to symlinks on either side.
workon_root() and a worktree’s path() can disagree on symlink resolution — git
canonicalizes the paths it writes into gitdir/commondir, while a path computed
from workon_root() may not be (e.g. macOS routes both /tmp and /var/folders
through symlinks). A plain strip_prefix fails silently in that case, which would
make every path-based lookup miss every worktree under a symlinked root. Canonicalize
both sides first, falling back to the original when canonicalize fails (e.g. a
worktree directory that no longer exists).
Returns None if path isn’t inside workon_root(). The result always uses /
separators, matching the format encode_worktree_name expects.