Allow for non-unicode filenames, closes #225

This commit is contained in:
sharkdp authored and David Peter committed 2020-02-13 08:25:04 +01:00
1 parent e98f34b1e8
commit 7779d9f622
6 files changed
+16 -11

No files matched your search

+4 -2
View File
@@ -1,7 +1,9 @@
use git2::{DiffOptions, IntoCString, Repository};
use std::collections::HashMap;
use std::fs;
use std::path::Path;
use std::ffi::OsStr;
use git2::{DiffOptions, IntoCString, Repository};
#[derive(Copy, Clone, Debug)]
pub enum LineChange {
@@ -13,7 +15,7 @@ pub enum LineChange {
pub type LineChanges = HashMap<u32, LineChange>;
pub fn get_git_diff(filename: &str) -> Option<LineChanges> {
pub fn get_git_diff(filename: &OsStr) -> Option<LineChanges> {
let repo = Repository::discover(&filename).ok()?;
let repo_path_absolute = fs::canonicalize(repo.workdir()?).ok()?;