Skip to content

improve files in diff speed (#976) #979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
23 changes: 10 additions & 13 deletions asyncgit/src/sync/commit_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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::<Vec<_>>();

Ok(res)
}
Expand Down