git p4: clone --branch should checkout master
When using the --branch argument to "git p4 clone", one might specify a destination for p4 changes different from the default refs/remotes/p4/master. Both cases should create a master branch and checkout files. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
695d699894
commit
c595956db9
@ -174,8 +174,7 @@ subsequent 'sync' operations.
|
|||||||
--branch <branch>::
|
--branch <branch>::
|
||||||
Import changes into given branch. If the branch starts with
|
Import changes into given branch. If the branch starts with
|
||||||
'refs/', it will be used as is, otherwise the path 'refs/heads/'
|
'refs/', it will be used as is, otherwise the path 'refs/heads/'
|
||||||
will be prepended. The default branch is 'master'. If used
|
will be prepended. The default branch is 'p4/master'.
|
||||||
with an initial clone, no HEAD will be checked out.
|
|
||||||
+
|
+
|
||||||
This example imports a new remote "p4/proj2" into an existing
|
This example imports a new remote "p4/proj2" into an existing
|
||||||
git repository:
|
git repository:
|
||||||
|
20
git-p4.py
20
git-p4.py
@ -3118,17 +3118,15 @@ class P4Clone(P4Sync):
|
|||||||
|
|
||||||
if not P4Sync.run(self, depotPaths):
|
if not P4Sync.run(self, depotPaths):
|
||||||
return False
|
return False
|
||||||
if self.branch != "master":
|
|
||||||
if self.importIntoRemotes:
|
# create a master branch and check out a work tree
|
||||||
masterbranch = "refs/remotes/p4/master"
|
if gitBranchExists(self.branch):
|
||||||
else:
|
system([ "git", "branch", "master", self.branch ])
|
||||||
masterbranch = "refs/heads/p4/master"
|
if not self.cloneBare:
|
||||||
if gitBranchExists(masterbranch):
|
system([ "git", "checkout", "-f" ])
|
||||||
system("git branch master %s" % masterbranch)
|
else:
|
||||||
if not self.cloneBare:
|
print 'Not checking out any branch, use ' \
|
||||||
system("git checkout -f")
|
'"git checkout -q -b master <branch>"'
|
||||||
else:
|
|
||||||
print "Could not detect main branch. No checkout/master branch created."
|
|
||||||
|
|
||||||
# auto-set this variable if invoked with --use-client-spec
|
# auto-set this variable if invoked with --use-client-spec
|
||||||
if self.useClientSpec_from_options:
|
if self.useClientSpec_from_options:
|
||||||
|
@ -27,7 +27,7 @@ test_expect_success 'clone no --git-dir' '
|
|||||||
test_must_fail git p4 clone --git-dir=xx //depot
|
test_must_fail git p4 clone --git-dir=xx //depot
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_failure 'clone --branch should checkout master' '
|
test_expect_success 'clone --branch should checkout master' '
|
||||||
git p4 clone --branch=refs/remotes/p4/sb --dest="$git" //depot &&
|
git p4 clone --branch=refs/remotes/p4/sb --dest="$git" //depot &&
|
||||||
test_when_finished cleanup_git &&
|
test_when_finished cleanup_git &&
|
||||||
(
|
(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user