]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-p4: make closeStreams() idempotent
authorLuke Diamand <luke@diamand.org>
Wed, 29 Jan 2020 11:12:41 +0000 (11:12 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 30 Jan 2020 20:20:57 +0000 (12:20 -0800)
Ensure that we can safely call self.closeStreams() multiple times, and
can also call it even if there is no git fast-import stream at all.

Signed-off-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-p4.py

index 40d9e7c594e590bd97069e29096dc34f3e642ed9..23724defe875094135e8441701f94a868769865a 100755 (executable)
--- a/git-p4.py
+++ b/git-p4.py
@@ -3549,11 +3549,14 @@ class P4Sync(Command, P4UserMap):
         self.gitError = self.importProcess.stderr
 
     def closeStreams(self):
+        if self.gitStream is None:
+            return
         self.gitStream.close()
         if self.importProcess.wait() != 0:
             die("fast-import failed: %s" % self.gitError.read())
         self.gitOutput.close()
         self.gitError.close()
+        self.gitStream = None
 
     def run(self, args):
         if self.importIntoRemotes: