diff --git a/git-p4.py b/git-p4.py index 0eb3bb4c47dcf1..3ea1c405e55ac9 100755 --- a/git-p4.py +++ b/git-p4.py @@ -4251,7 +4251,8 @@ def run(self, args): if self.tempBranches != []: for branch in self.tempBranches: read_pipe(["git", "update-ref", "-d", branch]) - os.rmdir(os.path.join(os.environ.get("GIT_DIR", ".git"), self.tempBranchLocation)) + if len(read_pipe(["git", "for-each-ref", self.tempBranchLocation])) > 0: + die("There are unexpected temporary branches") # Create a symbolic ref p4/HEAD pointing to p4/ to allow # a convenient shortcut refname "p4".