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>
Pete Wyckoff committed
Jan 14, 2013 at 19:47 UTC
c595956db99a728ab2247b564c8283cf5c0d84e6
3 files changed
+11
-14
Documentation/git-p4.txt
+1
-2
@@ -174,8 +174,7 @@ subsequent 'sync' operations.
174
--branch <branch>::
175
Import changes into given branch. If the branch starts with
176
'refs/', it will be used as is, otherwise the path 'refs/heads/'
177
- will be prepended. The default branch is 'master'. If used
178
- with an initial clone, no HEAD will be checked out.
177
+ will be prepended. The default branch is 'p4/master'.
178
+
179
This example imports a new remote "p4/proj2" into an existing
180
git repository:
git-p4.py
+9
-11
@@ -3118,17 +3118,15 @@ class P4Clone(P4Sync):
3118
3119
if not P4Sync.run(self, depotPaths):
3120
return False
3121
- if self.branch != "master":
3122
- if self.importIntoRemotes:
3123
- masterbranch = "refs/remotes/p4/master"
3124
- else:
3125
- masterbranch = "refs/heads/p4/master"
3126
- if gitBranchExists(masterbranch):
3127
- system("git branch master %s" % masterbranch)
3128
- if not self.cloneBare:
3129
- system("git checkout -f")
3130
- else:
3131
- print "Could not detect main branch. No checkout/master branch created."
3121
+
3122
+ # create a master branch and check out a work tree
3123
+ if gitBranchExists(self.branch):
3124
+ system([ "git", "branch", "master", self.branch ])
3125
+ if not self.cloneBare:
3126
+ system([ "git", "checkout", "-f" ])
3127
+ else:
3128
+ print 'Not checking out any branch, use ' \
3129
+ '"git checkout -q -b master <branch>"'
3130
3131
# auto-set this variable if invoked with --use-client-spec
3132
if self.useClientSpec_from_options:
t/t9806-git-p4-options.sh
+1
-1
@@ -27,7 +27,7 @@ test_expect_success 'clone no --git-dir' '
27
test_must_fail git p4 clone --git-dir=xx //depot
28
'
29
30
-test_expect_failure 'clone --branch should checkout master' '
30
+test_expect_success 'clone --branch should checkout master' '
31
git p4 clone --branch=refs/remotes/p4/sb --dest="$git" //depot &&
32
test_when_finished cleanup_git &&
33
(