From 72b5d9a8c575b61b9274ecafbd4d918c7755db02 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 30 Jan 2022 22:43:30 -0800 Subject: [PATCH] cli: when importing Git HEAD, abandon right workspace's old commit (#13) When importing Git HEAD, we already use the right workspace ID for the new checkout, but the old checkout we abandon is always the default workspace's. We should fix that even if we will never support sharing a working copy with Git in a non-default workspace. --- src/commands.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index 50cb8615b..f38d40dc4 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -286,8 +286,9 @@ impl WorkspaceCommandHelper { if new_git_head != old_git_head && new_git_head.is_some() { let workspace_id = self.workspace.workspace_id(); let mut locked_working_copy = self.workspace.working_copy_mut().start_mutation(); - tx.mut_repo() - .record_abandoned_commit(self.repo.view().checkout().clone()); + if let Some(old_checkout) = self.repo.view().get_checkout(&workspace_id) { + tx.mut_repo().record_abandoned_commit(old_checkout.clone()); + } let new_checkout = self .repo .store()