From: Pete Wyckoff <pw@padd.com>
To: git@vger.kernel.org
Cc: Olivier Delalleau <shish@keba.be>
Subject: [PATCH 05/14] git p4: create p4/HEAD on initial clone
Date: Mon, 14 Jan 2013 19:46:59 -0500 [thread overview]
Message-ID: <1358210828-2369-6-git-send-email-pw@padd.com> (raw)
In-Reply-To: <1358210828-2369-1-git-send-email-pw@padd.com>
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>
---
git-p4.py | 12 ++++++++----
t/t9806-git-p4-options.sh | 23 +++++++++++++++++++++++
2 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/git-p4.py b/git-p4.py
index 8814049..537eac6 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2778,10 +2778,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:
@@ -3013,6 +3010,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):
diff --git a/t/t9806-git-p4-options.sh b/t/t9806-git-p4-options.sh
index 844aae0..4900aef 100755
--- a/t/t9806-git-p4-options.sh
+++ b/t/t9806-git-p4-options.sh
@@ -83,6 +83,29 @@ test_expect_failure 'sync --branch updates specified branch' '
)
'
+# allows using the refname "p4" as a short name for p4/master
+test_expect_success 'clone creates HEAD symbolic reference' '
+ git p4 clone --dest="$git" //depot &&
+ test_when_finished cleanup_git &&
+ (
+ cd "$git" &&
+ git rev-parse --verify refs/remotes/p4/master >master &&
+ git rev-parse --verify p4 >p4 &&
+ test_cmp master p4
+ )
+'
+
+test_expect_success 'clone --branch creates HEAD symbolic reference' '
+ git p4 clone --branch=refs/remotes/p4/sb --dest="$git" //depot &&
+ test_when_finished cleanup_git &&
+ (
+ cd "$git" &&
+ git rev-parse --verify refs/remotes/p4/sb >sb &&
+ git rev-parse --verify p4 >p4 &&
+ test_cmp sb p4
+ )
+'
+
test_expect_success 'clone --changesfile' '
test_when_finished "rm cf" &&
printf "1\n3\n" >cf &&
--
1.8.1.350.gdbf6fd0
next prev parent reply other threads:[~2013-01-15 0:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-15 0:46 [PATCH 00/14] git p4 branch handling fixes Pete Wyckoff
2013-01-15 0:46 ` [PATCH 01/14] git p4: test sync/clone --branch behavior Pete Wyckoff
2013-01-15 0:46 ` [PATCH 02/14] git p4: rearrange and simplify hasOrigin handling Pete Wyckoff
2013-01-15 0:46 ` [PATCH 03/14] git p4: add comments to p4BranchesInGit Pete Wyckoff
2013-01-15 0:46 ` [PATCH 04/14] git p4: inline listExistingP4GitBranches Pete Wyckoff
2013-01-15 0:46 ` Pete Wyckoff [this message]
2013-01-15 0:47 ` [PATCH 06/14] git p4: verify expected refs in clone --bare test Pete Wyckoff
2013-01-15 0:47 ` [PATCH 07/14] git p4: clone --branch should checkout master Pete Wyckoff
2013-01-15 0:47 ` [PATCH 08/14] git p4 doc: fix branch detection example Pete Wyckoff
2013-01-15 0:47 ` [PATCH 09/14] git p4: allow short ref names to --branch Pete Wyckoff
2013-01-15 0:47 ` [PATCH 10/14] git p4: rearrange self.initialParent use Pete Wyckoff
2013-01-15 0:47 ` [PATCH 11/14] git p4: fail gracefully on sync with no master branch Pete Wyckoff
2013-01-15 0:47 ` [PATCH 12/14] git p4: fix sync --branch when " Pete Wyckoff
2013-01-15 0:47 ` [PATCH 13/14] git p4 test: keep P4CLIENT changes inside subshells Pete Wyckoff
2013-01-15 0:47 ` [PATCH 14/14] git p4: fix submit when no master branch Pete Wyckoff
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1358210828-2369-6-git-send-email-pw@padd.com \
--to=pw@padd.com \
--cc=git@vger.kernel.org \
--cc=shish@keba.be \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).