From 73e9029df494efe65ceb79e80399322c9cdc5c9e Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Mon, 30 Mar 2020 19:25:52 +0200 Subject: [PATCH] simplify reset_workdir (#6) --- asyncgit/src/sync/reset.rs | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/asyncgit/src/sync/reset.rs b/asyncgit/src/sync/reset.rs index cdfd8015..96cba6b6 100644 --- a/asyncgit/src/sync/reset.rs +++ b/asyncgit/src/sync/reset.rs @@ -45,28 +45,14 @@ pub fn reset_workdir(repo_path: &str, path: &Path) -> bool { return removed_file_wd; } - if status != Status::WT_MODIFIED | Status::INDEX_NEW { - let mut checkout_opts = CheckoutBuilder::new(); - checkout_opts - .remove_untracked(true) - .force() - .update_index(false) - .path(&path); - - //first reset working dir file - repo.checkout_head(Some(&mut checkout_opts)).unwrap(); - } - let mut checkout_opts = CheckoutBuilder::new(); checkout_opts .update_index(true) // windows: needs this to be true WTF?! .allow_conflicts(true) + .force() .path(&path); - // now reset staged changes back to working dir - repo.checkout_index(None, Some(&mut checkout_opts)).unwrap(); - - true + repo.checkout_index(None, Some(&mut checkout_opts)).is_ok() } else { false }