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: Stash pop removes stash from list even when there are conflicts #2382

Closed
wants to merge 1 commit into from
Closed
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 @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* add `use_selection_fg` to theme file to allow customizing selection foreground color [[@Upsylonbare](https://github.com/Upsylonbare)] ([#2515](https://github.com/gitui-org/gitui/pull/2515))

### Changed
* Stash pop removes stash from list even when there are conflicts([#2372](https://github.com/extrawurst/gitui/issues/2372))
* improve syntax highlighting file detection [[@acuteenvy](https://github.com/acuteenvy)] ([#2524](https://github.com/extrawurst/gitui/pull/2524))
* Updated project links to point to `gitui-org` instead of `extrawurst` [[@vasleymus](https://github.com/vasleymus)] ([#2538](https://github.com/gitui-org/gitui/pull/2538))
* After commit: jump back to unstaged area [[@tommady](https://github.com/tommady)] ([#2476](https://github.com/extrawurst/gitui/issues/2476))
Expand Down
4 changes: 4 additions & 0 deletions asyncgit/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ pub enum Error {
#[error("git: conflict during rebase")]
RebaseConflict,

///
#[error("git: conflict during stash apply")]
StashApplyConflict,

///
#[error("git: remote url not found")]
UnknownRemote,
Expand Down
16 changes: 15 additions & 1 deletion asyncgit/src/sync/stash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,21 @@ pub fn stash_pop(

let index = get_stash_index(&mut repo, stash_id.into())?;

repo.stash_pop(index, None)?;
// todo: The allow_conflicts parameter set in CheckoutBuilder is not actually taking effect.
let mut checkout = CheckoutBuilder::new();
checkout.allow_conflicts(false);

let mut opt = StashApplyOptions::default();
opt.checkout_options(checkout);
repo.stash_apply(index, None)?;

// check for merge conflicts
if repo.index()?.has_conflicts() {
return Err(Error::StashApplyConflict);
}

// remove the entry at the specified index from the stash list
repo.stash_drop(index)?;

Ok(())
}
Expand Down
Loading