improve files in diff speed (#979)

closes #976
This commit is contained in:
Stephan Dilly 2021-11-11 13:36:17 +01:00 committed by GitHub
parent fa7cd37ca7
commit 3c8eb7e049
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 13 deletions

View file

@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- honor options (for untracked files) in `stage_all` command ([#933](https://github.com/extrawurst/gitui/issues/933)) - 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 ## [0.18] - 2021-10-11

View file

@ -4,7 +4,7 @@ use super::{stash::is_stash_commit, utils::repo, CommitId};
use crate::{ use crate::{
error::Error, error::Result, StatusItem, StatusItemType, error::Error, error::Result, StatusItem, StatusItemType,
}; };
use git2::{Diff, DiffDelta, DiffOptions, Repository}; use git2::{Diff, DiffOptions, Repository};
use scopetime::scope_time; use scopetime::scope_time;
/// get all files that are part of a commit /// get all files that are part of a commit
@ -23,24 +23,21 @@ pub fn get_commit_files(
get_commit_diff(&repo, id, None)? 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( StatusItem {
&mut |delta: DiffDelta<'_>, _progress| {
res.push(StatusItem {
path: delta path: delta
.new_file() .new_file()
.path() .path()
.map(|p| p.to_str().unwrap_or("").to_string()) .map(|p| p.to_str().unwrap_or("").to_string())
.unwrap_or_default(), .unwrap_or_default(),
status: StatusItemType::from(delta.status()), status,
}); }
true })
}, .collect::<Vec<_>>();
None,
None,
None,
)?;
Ok(res) Ok(res)
} }