From 40d69ac3a4fd72b879bab9975b26e1b445b5f0cc Mon Sep 17 00:00:00 2001 From: Pete Wyckoff Date: Mon, 14 Jan 2013 19:47:03 -0500 Subject: git p4: allow short ref names to --branch For a clone or sync, --branch says where the newly imported branch should go, or which existing branch to sync up. It takes an argument, which is currently either something that starts with "refs/", or if not, "refs/heads/p4" is prepended. Putting it in heads seems like a bad default; these should go in remotes/p4/ in most situations. Make that the new default, and be more liberal in the form of the branch name. Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- git-p4.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'git-p4.py') diff --git a/git-p4.py b/git-p4.py index c59ad93034..2d0b58f0b4 100755 --- a/git-p4.py +++ b/git-p4.py @@ -2841,8 +2841,18 @@ class P4Sync(Command, P4UserMap): 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: -- cgit v1.2.1