Skip to content

Commit 369a421

Browse files
committed
Temporary workaround for Path in libgit2-rs
1 parent 9e7c80b commit 369a421

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/dir.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,19 @@ impl Git {
8484
/// Discover a Git repository on or above this directory, scanning it for
8585
/// the files' statuses if one is found.
8686
fn scan(path: &Path) -> Result<Git, git2::Error> {
87+
use std::os::unix::OsStrExt;
88+
use std::ffi::AsOsStr;
89+
90+
// TODO: libgit2-rs uses the new Path module, but exa still uses the
91+
// old_path one, and will have to continue to do so until the new IO
92+
// module gets a bit more developed. So we have to turn Paths into
93+
// old_path::Paths. Yes, this is hacky, but hopefully temporary.
8794
let repo = try!(git2::Repository::discover(path));
88-
let workdir = repo.workdir().unwrap_or(Path::new("."));
95+
let workdir = match repo.workdir() {
96+
Some(w) => Path::new(w.as_os_str().as_bytes()),
97+
None => return Ok(Git { statuses: vec![] }), // bare repo
98+
};
99+
89100
let statuses = try!(repo.statuses(None)).iter()
90101
.map(|e| (workdir.join(e.path_bytes()), e.status()))
91102
.collect();

0 commit comments

Comments
 (0)