Skip to content

Commit

Permalink
speed up more
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun committed Jun 11, 2024
1 parent 82d3999 commit e576dad
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions fmt/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,17 @@ pub fn resolve_file_attrs(repo: &Repository) -> anyhow::Result<HashMap<String, G
let mut cache = repo.diff_resource_cache(mode, Default::default())?;

let head = repo.head_commit()?;
let mut prev_commit = head.clone();
let mut prev_tree = head.tree()?;

for info in head.ancestors().all()? {
let sorting = gix::traverse::commit::simple::Sorting::ByCommitTimeNewestFirst;
for info in head.ancestors().sorting(sorting).all()? {
let info = info?;
let this_commit = info.object()?;
let time = this_commit.time()?;
let time = gix::date::Time::new(info.commit_time(), 0);

let tree = this_commit.tree()?;
let tree = info.id().object()?.peel_to_tree()?;
let mut changes = tree.changes()?;
changes.track_path().for_each_to_obtain_tree_with_cache(
&prev_commit.tree()?,
&prev_tree,
&mut cache,
|change| {
let filepath = workdir.join(change.location.to_string());
Expand All @@ -141,7 +141,7 @@ pub fn resolve_file_attrs(repo: &Repository) -> anyhow::Result<HashMap<String, G
Ok::<_, Infallible>(Default::default())
},
)?;
prev_commit = this_commit;
prev_tree = tree;
cache.clear_resource_cache();
}

Expand Down

0 comments on commit e576dad

Please sign in to comment.