mirror of
https://github.com/sharkdp/bat.git
synced 2025-04-18 08:40:35 +01:00
Fix relative-path computation for Windows
This commit is contained in:
parent
a6ff3b900d
commit
194155f062
@ -16,7 +16,9 @@ pub type LineChanges = HashMap<u32, LineChange>;
|
|||||||
pub fn get_git_diff(filename: &str) -> Option<LineChanges> {
|
pub fn get_git_diff(filename: &str) -> Option<LineChanges> {
|
||||||
let repo = Repository::discover(&filename).ok()?;
|
let repo = Repository::discover(&filename).ok()?;
|
||||||
let path_absolute = fs::canonicalize(&filename).ok()?;
|
let path_absolute = fs::canonicalize(&filename).ok()?;
|
||||||
let path_relative_to_repo = path_absolute.strip_prefix(repo.workdir()?).ok()?;
|
let path_relative_to_repo = path_absolute
|
||||||
|
.strip_prefix(fs::canonicalize(repo.workdir()?).ok()?)
|
||||||
|
.ok()?;
|
||||||
|
|
||||||
let mut diff_options = DiffOptions::new();
|
let mut diff_options = DiffOptions::new();
|
||||||
let pathspec = path_relative_to_repo.into_c_string().ok()?;
|
let pathspec = path_relative_to_repo.into_c_string().ok()?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user