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.
This commit is contained in:
Martin von Zweigbergk 2022-01-30 22:43:30 -08:00
parent 48bbb3abc0
commit 72b5d9a8c5

View file

@ -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()