git p4: rearrange and simplify hasOrigin handling
authorPete Wyckoff <pw@padd.com>
Tue, 15 Jan 2013 00:46:56 +0000 (19:46 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 15 Jan 2013 17:46:29 +0000 (09:46 -0800)
Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-p4.py

index 551aec9417401dcd7ef526dd6c9b554e5194f861..e9127319d4620d27ac148412bed0b12b1fdae2bc 100755 (executable)
--- a/git-p4.py
+++ b/git-p4.py
@@ -2748,23 +2748,23 @@ class P4Sync(Command, P4UserMap):
         self.changeRange = ""
         self.initialParent = ""
         self.previousDepotPaths = []
+        self.hasOrigin = False
 
         # map from branch depot path to parent branch
         self.knownBranches = {}
         self.initialParents = {}
-        self.hasOrigin = originP4BranchesExist()
-        if not self.syncWithOrigin:
-            self.hasOrigin = False
 
         if self.importIntoRemotes:
             self.refPrefix = "refs/remotes/p4/"
         else:
             self.refPrefix = "refs/heads/p4/"
 
-        if self.syncWithOrigin and self.hasOrigin:
-            if not self.silent:
-                print "Syncing with origin first by calling git fetch origin"
-            system("git fetch origin")
+        if self.syncWithOrigin:
+            self.hasOrigin = originP4BranchesExist()
+            if self.hasOrigin:
+                if not self.silent:
+                    print 'Syncing with origin first, using "git fetch origin"'
+                system("git fetch origin")
 
         if len(self.branch) == 0:
             self.branch = self.refPrefix + "master"