diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bdf2930..f38f5aff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ![charcount](assets/char_count.gif) ### Fixed +- fix some potential errors when deleting files while they are being diffed ([#490](https://github.com/extrawurst/gitui/issues/490)) - push defaults to 'origin' remote if it exists ([#494](https://github.com/extrawurst/gitui/issues/494)) - support missing pageUp/down support in branchlist ([#519](https://github.com/extrawurst/gitui/issues/519)) - don't hide branch name while in commit dialog ([#529](https://github.com/extrawurst/gitui/issues/529)) diff --git a/Makefile b/Makefile index 549faad2..77b035e3 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ profile: cargo run --features=timing,pprof -- -l debug: - cargo run --features=timing -- -l + RUST_BACKTRACE=true cargo run --features=timing -- -l build-release: cargo build --release diff --git a/asyncgit/src/diff.rs b/asyncgit/src/diff.rs index 657bdf21..8298c996 100644 --- a/asyncgit/src/diff.rs +++ b/asyncgit/src/diff.rs @@ -118,8 +118,14 @@ impl AsyncDiff { arc_last, arc_current, hash, - ) - .expect("error getting diff"); + ); + + let notify = if let Err(err) = notify { + log::error!("get_diff_helper error: {}", err); + true + } else { + false + }; arc_pending.fetch_sub(1, Ordering::Relaxed); diff --git a/src/components/diff.rs b/src/components/diff.rs index b5be1565..304d7e0c 100644 --- a/src/components/diff.rs +++ b/src/components/diff.rs @@ -518,6 +518,16 @@ impl DiffComponent { ); } + fn stage_unstage_hunk(&mut self) -> Result<()> { + if self.current.is_stage { + self.unstage_hunk()?; + } else { + self.stage_hunk()?; + } + + Ok(()) + } + const fn is_stage(&self) -> bool { self.current.is_stage } @@ -659,11 +669,12 @@ impl Component for DiffComponent { } else if e == self.key_config.enter && !self.is_immutable { - if self.current.is_stage { - self.unstage_hunk()?; - } else { - self.stage_hunk()?; - } + try_or_popup!( + self, + "hunk error:", + self.stage_unstage_hunk() + ); + Ok(true) } else if e == self.key_config.status_reset_item && !self.is_immutable