Skip to content

Commit 1471c6b

Browse files
Pete Wyckoffgitster
authored andcommitted
git-p4: document and test clone --branch
Clone with --branch will not checkout HEAD, unless the branch happens to be called the default refs/remotes/p4/master. The --branch option is most useful with sync; give an example of that. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent da191d1 commit 1471c6b

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Documentation/git-p4.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,15 @@ subsequent 'sync' operations.
178178
--branch <branch>::
179179
Import changes into given branch. If the branch starts with
180180
'refs/', it will be used as is, otherwise the path 'refs/heads/'
181-
will be prepended. The default branch is 'master'.
181+
will be prepended. The default branch is 'master'. If used
182+
with an initial clone, no HEAD will be checked out.
183+
+
184+
This example imports a new remote "p4/proj2" into an existing
185+
git repository:
186+
----
187+
$ git init
188+
$ git p4 sync --branch=refs/remotes/p4/proj2 //depot/proj2
189+
----
182190

183191
--detect-branches::
184192
Use the branch detection algorithm to find new paths in p4. It is

t/t9806-git-p4-options.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ test_expect_success 'clone no --git-dir' '
2727
test_must_fail "$GITP4" clone --git-dir=xx //depot
2828
'
2929

30+
test_expect_success 'clone --branch' '
31+
"$GITP4" clone --branch=refs/remotes/p4/sb --dest="$git" //depot &&
32+
test_when_finished cleanup_git &&
33+
(
34+
cd "$git" &&
35+
git ls-files >files &&
36+
test_line_count = 0 files &&
37+
test_path_is_file .git/refs/remotes/p4/sb
38+
)
39+
'
40+
3041
test_expect_success 'kill p4d' '
3142
kill_p4d
3243
'

0 commit comments

Comments
 (0)