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>

Pete Wyckoff committed Dec 24, 2011 at 21:07 UTC 1471c6b1558f45fa11ad606fc9ea72261d965284
2 files changed +20 -1
Documentation/git-p4.txt
+9 -1
@@ -178,7 +178,15 @@ subsequent 'sync' operations.
178 --branch <branch>::
179 Import changes into given branch. If the branch starts with
180 '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 +----
190
191 --detect-branches::
192 Use the branch detection algorithm to find new paths in p4. It is
t/t9806-git-p4-options.sh
+11
@@ -27,6 +27,17 @@ test_expect_success 'clone no --git-dir' '
27 test_must_fail "$GITP4" clone --git-dir=xx //depot
28 '
29
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 +
41 test_expect_success 'kill p4d' '
42 kill_p4d
43 '