Skip to content
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

fix some potentials for errors to bubble up #547

Merged
merged 3 commits into from
Feb 24, 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 @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions asyncgit/src/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
21 changes: 16 additions & 5 deletions src/components/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down