From fdd84a8692bd799df0e35a3d9bd2da18a119d7e1 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Fri, 12 Jun 2020 13:17:06 +0200 Subject: [PATCH] add test for (#118) --- asyncgit/src/sync/reset.rs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/asyncgit/src/sync/reset.rs b/asyncgit/src/sync/reset.rs index 20ce9734..02aff69b 100644 --- a/asyncgit/src/sync/reset.rs +++ b/asyncgit/src/sync/reset.rs @@ -56,7 +56,6 @@ pub fn reset_workdir_file(repo_path: &str, path: &str) -> Result<()> { let mut checkout_opts = CheckoutBuilder::new(); checkout_opts .update_index(true) // windows: needs this to be true WTF?! - .allow_conflicts(true) .force() .path(path); @@ -76,7 +75,6 @@ pub fn reset_workdir_folder( let mut checkout_opts = CheckoutBuilder::new(); checkout_opts .update_index(true) // windows: needs this to be true WTF?! - .allow_conflicts(true) .remove_untracked(true) .force() .path(path); @@ -334,4 +332,29 @@ mod tests { assert_eq!(get_statuses(repo_path), (0, 0)); } + + #[test] + fn test_reset_untracked_subdir() { + let (_td, repo) = repo_init().unwrap(); + let root = repo.path().parent().unwrap(); + let repo_path = root.as_os_str().to_str().unwrap(); + + { + fs::create_dir_all(&root.join("foo/bar")).unwrap(); + File::create(&root.join("foo/bar/baz.txt")) + .unwrap() + .write_all(b"test\nfoo") + .unwrap(); + } + + debug_cmd_print(repo_path, "git status"); + + assert_eq!(get_statuses(repo_path), (1, 0)); + + reset_workdir_folder(repo_path, "foo/bar").unwrap(); + + debug_cmd_print(repo_path, "git status"); + + assert_eq!(get_statuses(repo_path), (0, 0)); + } }