diff --git a/lib/src/working_copy.rs b/lib/src/working_copy.rs index 3cce573f9..41b598e13 100644 --- a/lib/src/working_copy.rs +++ b/lib/src/working_copy.rs @@ -460,8 +460,8 @@ impl TreeState { } /// Look for changes to the working copy. If there are any changes, create - /// a new tree from it and return it, and also update the dirstate on disk. - pub fn snapshot(&mut self, base_ignores: Arc) -> Result { + /// a new tree from it. + pub fn snapshot(&mut self, base_ignores: Arc) -> Result<(), SnapshotError> { let sparse_matcher = self.sparse_matcher(); let mut work = vec![( RepoPath::root(), @@ -517,7 +517,7 @@ impl TreeState { tree_builder.remove(file.clone()); } self.tree_id = tree_builder.write_tree(); - Ok(self.tree_id.clone()) + Ok(()) } fn has_files_under(&self, dir: &RepoPath) -> bool { @@ -1162,7 +1162,9 @@ impl LockedWorkingCopy<'_> { // because the TreeState may be long-lived if the library is used in a // long-lived process. pub fn snapshot(&mut self, base_ignores: Arc) -> Result { - self.wc.tree_state_mut().snapshot(base_ignores) + let mut tree_state = self.wc.tree_state_mut(); + tree_state.snapshot(base_ignores)?; + Ok(tree_state.current_tree_id().clone()) } pub fn check_out(&mut self, new_tree: &Tree) -> Result { diff --git a/src/diff_edit.rs b/src/diff_edit.rs index 2b49166b3..6a86f0a6d 100644 --- a/src/diff_edit.rs +++ b/src/diff_edit.rs @@ -177,7 +177,8 @@ pub fn edit_diff( std::fs::remove_file(instructions_path).ok(); } - Ok(right_tree_state.snapshot(base_ignores)?) + right_tree_state.snapshot(base_ignores)?; + Ok(right_tree_state.current_tree_id().clone()) } /// Merge/diff tool loaded from the settings.