Skip to main content

resolve_git_toplevel

Function resolve_git_toplevel 

Source
pub fn resolve_git_toplevel(cwd: &Path) -> Result<PathBuf, ChangedFilesError>
Expand description

Resolve the canonical git toplevel for cwd.

Runs git rev-parse --show-toplevel, which is git’s own answer to “where does this repository live?”. The returned path is canonicalized so it agrees with paths produced by fs::canonicalize elsewhere on macOS (/tmp -> /private/tmp) and Windows (8.3 short paths).

Used by try_get_changed_files to produce changed-file paths whose absolute form matches what the analysis pipeline emits, regardless of whether the caller’s cwd is the repo root or a subdirectory of it.