git p4: fix sync --branch when no master branch

It is legal to sync a branch with a different name than
refs/remotes/p4/master, and to do so even when master does
not exist.

Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Pete Wyckoff
2013-01-14 19:47:06 -05:00
committed by Junio C Hamano
parent 5a8e84cde3
commit 8c9e8b6e75
3 changed files with 20 additions and 7 deletions

View File

@ -2804,14 +2804,22 @@ class P4Sync(Command, P4UserMap):
# branches holds mapping from branch name to sha1
branches = p4BranchesInGit(self.importIntoRemotes)
self.p4BranchesInGit = branches.keys()
for branch in branches.keys():
self.initialParents[self.refPrefix + branch] = branches[branch]
# restrict to just this one, disabling detect-branches
if branch_arg_given:
short = self.branch.split("/")[-1]
if short in branches:
self.p4BranchesInGit = [ short ]
else:
self.p4BranchesInGit = branches.keys()
if len(self.p4BranchesInGit) > 1:
if not self.silent:
print "Importing from/into multiple branches"
self.detectBranches = True
for branch in branches.keys():
self.initialParents[self.refPrefix + branch] = \
branches[branch]
if self.verbose:
print "branches: %s" % self.p4BranchesInGit