summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--project.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/project.py b/project.py
index 8fec98165..de1ab3c6c 100644
--- a/project.py
+++ b/project.py
@@ -3443,11 +3443,18 @@ class Project:
# Finish checking out the worktree.
cmd = ["read-tree", "--reset", "-u", "-v", HEAD]
- if GitCommand(self, cmd).Wait() != 0:
- raise GitError(
- "Cannot initialize work tree for " + self.name,
- project=self.name,
- )
+ try:
+ if GitCommand(self, cmd).Wait() != 0:
+ raise GitError(
+ "Cannot initialize work tree for " + self.name,
+ project=self.name,
+ )
+ except Exception as e:
+ # Something went wrong with read-tree (perhaps fetching
+ # missing blobs), so remove .git to avoid half initialized
+ # workspace from which repo can't recover on its own.
+ platform_utils.remove(dotgit)
+ raise e
if submodules:
self._SyncSubmodules(quiet=True)