Skip to content

Commit 93e941c

Browse files
committed
Scaffold remaining arguments to blame_file
1 parent 2db45f1 commit 93e941c

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

gitoxide-core/src/repository/blame.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
1-
use std::ffi::OsStr;
1+
use std::{ffi::OsStr, os::unix::ffi::OsStrExt, path::PathBuf};
22

3-
pub fn blame_file(repo: gix::Repository, _file: &OsStr) -> anyhow::Result<()> {
3+
use gix::bstr::BStr;
4+
5+
pub fn blame_file(repo: gix::Repository, file: &OsStr) -> anyhow::Result<()> {
46
let traverse: Vec<Result<gix::traverse::commit::Info, gix::traverse::commit::simple::Error>> = vec![];
7+
let mut resource_cache = repo.diff_resource_cache_for_tree_diff()?;
8+
let mut reference = gix::refs::file::Store::find(&repo.refs, "HEAD")?;
9+
10+
// Needed for `peel_to_id_in_place`.
11+
use gix::refs::file::ReferenceExt;
12+
13+
let suspect = reference.peel_to_id_in_place(&repo.refs, &repo.objects)?;
14+
15+
let work_dir: PathBuf = repo.work_dir().expect("TODO").into();
16+
let file_path: &BStr = file.as_bytes().into();
517

6-
if let Ok(_blame_entries) = gix::blame::blame_file(repo.objects, traverse, todo!(), todo!(), todo!(), todo!()) {
18+
if let Ok(_blame_entries) = gix::blame::blame_file(
19+
repo.objects,
20+
traverse,
21+
&mut resource_cache,
22+
suspect,
23+
work_dir,
24+
&file_path,
25+
) {
726
todo!()
827
} else {
928
todo!()

0 commit comments

Comments
 (0)