Skip to content

Commit 70cf348

Browse files
committed
fix: canonicalize repo_root on windows to match file paths
git rev-parse --show-toplevel returns paths with lowercase drive letters and forward slashes on Windows, which causes strip_prefix to fail when comparing against canonicalized paths (which use uppercase drive letters and UNC prefixes). Canonicalizing the repo_root immediately ensures it matches the format of the file paths being checked.
1 parent abafdab commit 70cf348

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/ops/git.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,8 @@ fn repo_root(cwd: &Path) -> anyhow::Result<PathBuf> {
320320
if !output.status.success() {
321321
anyhow::bail!("not inside a git repository");
322322
}
323-
Ok(PathBuf::from(
324-
String::from_utf8_lossy(&output.stdout).trim().to_string(),
325-
))
323+
let path = PathBuf::from(String::from_utf8_lossy(&output.stdout).trim().to_string());
324+
Ok(std::fs::canonicalize(&path).unwrap_or(path))
326325
}
327326

328327
pub fn repo_relative_session_files(

0 commit comments

Comments
 (0)