1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-08 06:12:27 +01:00

Allow for non-unicode filenames, closes #225

This commit is contained in:
sharkdp
2020-02-12 23:23:49 +01:00
committed by David Peter
parent e98f34b1e8
commit 7779d9f622
6 changed files with 16 additions and 11 deletions

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()?;