diff --git a/CHANGELOG.md b/CHANGELOG.md index 32476fd5..a67f39da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - honor options (for untracked files) in `stage_all` command ([#933](https://github.com/extrawurst/gitui/issues/933)) +- improved file diff speed dramatically ([#976](https://github.com/extrawurst/gitui/issues/976)) ## [0.18] - 2021-10-11 diff --git a/asyncgit/src/sync/commit_files.rs b/asyncgit/src/sync/commit_files.rs index 6015d843..b74bd8a1 100644 --- a/asyncgit/src/sync/commit_files.rs +++ b/asyncgit/src/sync/commit_files.rs @@ -4,7 +4,7 @@ use super::{stash::is_stash_commit, utils::repo, CommitId}; use crate::{ error::Error, error::Result, StatusItem, StatusItemType, }; -use git2::{Diff, DiffDelta, DiffOptions, Repository}; +use git2::{Diff, DiffOptions, Repository}; use scopetime::scope_time; /// get all files that are part of a commit @@ -23,24 +23,21 @@ pub fn get_commit_files( get_commit_diff(&repo, id, None)? }; - let mut res = Vec::new(); + let res = diff + .deltas() + .map(|delta| { + let status = StatusItemType::from(delta.status()); - diff.foreach( - &mut |delta: DiffDelta<'_>, _progress| { - res.push(StatusItem { + StatusItem { path: delta .new_file() .path() .map(|p| p.to_str().unwrap_or("").to_string()) .unwrap_or_default(), - status: StatusItemType::from(delta.status()), - }); - true - }, - None, - None, - None, - )?; + status, + } + }) + .collect::>(); Ok(res) }