git p4: allow short ref names to --branch
[gitweb.git] / git-p4.py
index c59ad9303488066ae11286388def4f51296f3155..2d0b58f0b450dcd8ab2009d2e03e3ba6fcfbc4fc 100755 (executable)
--- a/git-p4.py
+++ b/git-p4.py
@@ -2841,8 +2841,18 @@ def run(self, args):
                 if not self.silent and not self.detectBranches:
                     print "Performing incremental import into %s git branch" % self.branch
 
+        # accept multiple ref name abbreviations:
+        #    refs/foo/bar/branch -> use it exactly
+        #    p4/branch -> prepend refs/remotes/ or refs/heads/
+        #    branch -> prepend refs/remotes/p4/ or refs/heads/p4/
         if not self.branch.startswith("refs/"):
-            self.branch = "refs/heads/" + self.branch
+            if self.importIntoRemotes:
+                prepend = "refs/remotes/"
+            else:
+                prepend = "refs/heads/"
+            if not self.branch.startswith("p4/"):
+                prepend += "p4/"
+            self.branch = prepend + self.branch
 
         if len(args) == 0 and self.depotPaths:
             if not self.silent: