Chester Liu 4 лет назад
Родитель
Сommit
9d613016c0
1 измененных файлов с 9 добавлено и 0 удалено
  1. 9 0
      src/fs/feature/git.rs

+ 9 - 0
src/fs/feature/git.rs

@@ -273,6 +273,7 @@ impl Git {
 /// Paths need to be absolute for them to be compared properly, otherwise
 /// you’d ask a repo about “./README.md” but it only knows about
 /// “/vagrant/README.md”, prefixed by the workdir.
+#[cfg(unix)]
 fn reorient(path: &Path) -> PathBuf {
     use std::env::current_dir;
 
@@ -285,6 +286,14 @@ fn reorient(path: &Path) -> PathBuf {
     path.canonicalize().unwrap_or(path)
 }
 
+#[cfg(windows)]
+fn reorient(path: &Path) -> PathBuf {
+    let unc_path = path.canonicalize().unwrap();
+    // On Windows UNC path is returned. We need to strip the prefix for it to work.
+    let normal_path = unc_path.as_os_str().to_str().unwrap().trim_left_matches("\\\\?\\");
+    return PathBuf::from(normal_path);
+}
+
 /// The character to display if the file has been modified, but not staged.
 fn working_tree_status(status: git2::Status) -> f::GitStatus {
     match status {