git-p4: document and test --import-local

Explain that it is needed on future syncs to find p4 branches in refs/heads. Test this behavior. 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 5a92a6ce90d6dbabf8075164e089e1cffbd351f7
2 files changed +25 -1
Documentation/git-p4.txt
+3 -1
@@ -211,7 +211,9 @@ git repository:
211 By default, p4 branches are stored in 'refs/remotes/p4/',
212 where they will be treated as remote-tracking branches by
213 linkgit:git-branch[1] and other commands. This option instead
214 - puts p4 branches in 'refs/heads/p4/'.
214 + puts p4 branches in 'refs/heads/p4/'. Note that future
215 + sync operations must specify '--import-local' as well so that
216 + they can find the p4 branches in refs/heads.
217
218 --max-changes <n>::
219 Limit the number of imported changes to 'n'. Useful to
t/t9806-git-p4-options.sh
+22
@@ -61,6 +61,28 @@ test_expect_success 'clone --changesfile, @all' '
61 test_must_fail "$GITP4" clone --changesfile="$cf" --dest="$git" //depot@all
62 '
63
64 +# imports both master and p4/master in refs/heads
65 +# requires --import-local on sync to find p4 refs/heads
66 +# does not update master on sync, just p4/master
67 +test_expect_success 'clone/sync --import-local' '
68 + "$GITP4" clone --import-local --dest="$git" //depot@1,2 &&
69 + test_when_finished cleanup_git &&
70 + (
71 + cd "$git" &&
72 + git log --oneline refs/heads/master >lines &&
73 + test_line_count = 2 lines &&
74 + git log --oneline refs/heads/p4/master >lines &&
75 + test_line_count = 2 lines &&
76 + test_must_fail "$GITP4" sync &&
77 +
78 + "$GITP4" sync --import-local &&
79 + git log --oneline refs/heads/master >lines &&
80 + test_line_count = 2 lines &&
81 + git log --oneline refs/heads/p4/master >lines &&
82 + test_line_count = 3 lines
83 + )
84 +'
85 +
86 test_expect_success 'kill p4d' '
87 kill_p4d
88 '