diff options
author | Ben S <ogham@bsago.me> | 2015-03-02 03:18:26 +0000 |
---|---|---|
committer | Ben S <ogham@bsago.me> | 2015-03-02 03:18:26 +0000 |
commit | 369a42135992d8175b5f00383005c0a40bc0d0a8 (patch) | |
tree | 7df9014d9296b063c4411f03bd116a2fbe7bed74 /src/dir.rs | |
parent | 9e7c80bcd0c16b65715c72cf16fcc334c20f0418 (diff) |
Temporary workaround for Path in libgit2-rs
Diffstat (limited to 'src/dir.rs')
-rw-r--r-- | src/dir.rs | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -84,8 +84,19 @@ impl Git { /// Discover a Git repository on or above this directory, scanning it for /// the files' statuses if one is found. fn scan(path: &Path) -> Result<Git, git2::Error> { + use std::os::unix::OsStrExt; + use std::ffi::AsOsStr; + + // TODO: libgit2-rs uses the new Path module, but exa still uses the + // old_path one, and will have to continue to do so until the new IO + // module gets a bit more developed. So we have to turn Paths into + // old_path::Paths. Yes, this is hacky, but hopefully temporary. let repo = try!(git2::Repository::discover(path)); - let workdir = repo.workdir().unwrap_or(Path::new(".")); + let workdir = match repo.workdir() { + Some(w) => Path::new(w.as_os_str().as_bytes()), + None => return Ok(Git { statuses: vec![] }), // bare repo + }; + let statuses = try!(repo.statuses(None)).iter() .map(|e| (workdir.join(e.path_bytes()), e.status())) .collect(); |