Set the default branch in run, not in the constructor
[gitweb.git] / contrib / fast-import / git-p4
index 6ead1c41732743cabdd3741bf5da66c1a44b134e..e6a34f4f478db2451de28687a55c9387d16c7c9d 100755 (executable)
@@ -83,6 +83,9 @@ def extractDepotPathAndChangeFromGitLog(log):
 
     return values.get("depot-path"), values.get("change")
 
+def gitBranchExists(branch):
+    return os.system("git-rev-parse %s 2>/dev/null >/dev/null") == 0
+
 class Command:
     def __init__(self):
         self.usage = "usage: %prog [options]"
@@ -376,7 +379,7 @@ class GitSync(Command):
         self.knownBranches = Set()
         self.createdBranches = Set()
         self.committedChanges = Set()
-        self.branch = "p4"
+        self.branch = ""
         self.detectBranches = False
         self.changesFile = ""
 
@@ -703,6 +706,9 @@ class GitSync(Command):
             self.users[output["User"]] = output["FullName"] + " <" + output["Email"] + ">"
 
     def run(self, args):
+        if len(self.branch) == 0:
+            self.branch = "p4"
+
         self.branch = "refs/heads/" + self.branch
         self.globalPrefix = self.previousDepotPath = os.popen("git-repo-config --get p4.depotpath").read()
         if len(self.globalPrefix) != 0: