Skip to content

Commit

Permalink
Temporary workaround for Path in libgit2-rs
Browse files Browse the repository at this point in the history
  • Loading branch information
ogham committed Mar 2, 2015
1 parent 9e7c80b commit 369a421
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 369a421

Please sign in to comment.