summaryrefslogtreecommitdiff
path: root/git-p4.py
diff options
context:
space:
mode:
authorPete Wyckoff <pw@padd.com>2013-01-14 19:46:59 -0500
committerJunio C Hamano <gitster@pobox.com>2013-01-15 09:46:29 -0800
commit55d124376f1d5d91be4376016d92a6ca6474428a (patch)
tree7f88c160dac645ef493f2a4a8bca8b86c7ea480a /git-p4.py
parent3b650fc9869a51190578aed8014d906f01f510a9 (diff)
downloadgit-55d124376f1d5d91be4376016d92a6ca6474428a.tar.gz
git p4: create p4/HEAD on initial clone
There is code to create a symbolic reference from p4/HEAD to p4/master. This allows saying "git show p4" as a shortcut to "git show p4/master", for example. But this reference was only created on the second "git p4 sync" (or first sync after a clone). Make it work on the initial clone or sync. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-p4.py')
-rwxr-xr-xgit-p4.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/git-p4.py b/git-p4.py
index 2443f79e07..7a0c0409be 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2772,10 +2772,7 @@ class P4Sync(Command, P4UserMap):
self.branch = self.refPrefix + "master"
if gitBranchExists("refs/heads/p4") and self.importIntoRemotes:
system("git update-ref %s refs/heads/p4" % self.branch)
- system("git branch -D p4");
- # create it /after/ importing, when master exists
- if not gitBranchExists(self.refPrefix + "HEAD") and self.importIntoRemotes and gitBranchExists(self.branch):
- system("git symbolic-ref %sHEAD %s" % (self.refPrefix, self.branch))
+ system("git branch -D p4")
# accept either the command-line option, or the configuration variable
if self.useClientSpec:
@@ -3007,6 +3004,13 @@ class P4Sync(Command, P4UserMap):
read_pipe("git update-ref -d %s" % branch)
os.rmdir(os.path.join(os.environ.get("GIT_DIR", ".git"), self.tempBranchLocation))
+ # Create a symbolic ref p4/HEAD pointing to p4/<branch> to allow
+ # a convenient shortcut refname "p4".
+ if self.importIntoRemotes:
+ head_ref = self.refPrefix + "HEAD"
+ if not gitBranchExists(head_ref) and gitBranchExists(self.branch):
+ system(["git", "symbolic-ref", head_ref, self.branch])
+
return True
class P4Rebase(Command):