3 test_description='git p4 options'
7 test_expect_success 'start p4d' '
11 test_expect_success 'init depot' '
16 p4 submit -d "change 1" &&
19 p4 submit -d "change 2" &&
22 p4 submit -d "change 3"
26 test_expect_success 'clone no --git-dir' '
27 test_must_fail git p4 clone --git-dir=xx //depot
30 test_expect_failure 'clone --branch should checkout master' '
31 git p4 clone --branch=refs/remotes/p4/sb --dest="$git" //depot &&
32 test_when_finished cleanup_git &&
35 git rev-parse refs/remotes/p4/sb >sb &&
36 git rev-parse refs/heads/master >master &&
38 git rev-parse HEAD >head &&
43 test_expect_failure 'sync when branch is not called master should work' '
44 git p4 clone --branch=refs/remotes/p4/sb --dest="$git" //depot@2 &&
45 test_when_finished cleanup_git &&
49 git show -s --format=%s refs/remotes/p4/sb >show &&
54 # engages --detect-branches code, which will do filename filtering so
55 # no sync to either b1 or b2
56 test_expect_success 'sync when two branches but no master should noop' '
57 test_when_finished cleanup_git &&
61 git p4 sync --branch=refs/remotes/p4/b1 //depot@2 &&
62 git p4 sync --branch=refs/remotes/p4/b2 //depot@2 &&
64 git show -s --format=%s refs/remotes/p4/b1 >show &&
65 grep "Initial import" show &&
66 git show -s --format=%s refs/remotes/p4/b2 >show &&
67 grep "Initial import" show
71 test_expect_failure 'sync --branch updates specified branch' '
72 test_when_finished cleanup_git &&
76 git p4 sync --branch=refs/remotes/p4/b1 //depot@2 &&
77 git p4 sync --branch=refs/remotes/p4/b2 //depot@2 &&
78 git p4 sync --branch=refs/remotes/p4/b2 &&
79 git show -s --format=%s refs/remotes/p4/b1 >show &&
80 grep "Initial import" show &&
81 git show -s --format=%s refs/remotes/p4/b2 >show &&
86 test_expect_success 'clone --changesfile' '
87 test_when_finished "rm cf" &&
88 printf "1\n3\n" >cf &&
89 git p4 clone --changesfile="$TRASH_DIRECTORY/cf" --dest="$git" //depot &&
90 test_when_finished cleanup_git &&
93 git log --oneline p4/master >lines &&
94 test_line_count = 2 lines
95 test_path_is_file file1 &&
96 test_path_is_missing file2 &&
97 test_path_is_file file3
101 test_expect_success 'clone --changesfile, @all' '
102 test_when_finished "rm cf" &&
103 printf "1\n3\n" >cf &&
104 test_must_fail git p4 clone --changesfile="$TRASH_DIRECTORY/cf" --dest="$git" //depot@all
107 # imports both master and p4/master in refs/heads
108 # requires --import-local on sync to find p4 refs/heads
109 # does not update master on sync, just p4/master
110 test_expect_success 'clone/sync --import-local' '
111 git p4 clone --import-local --dest="$git" //depot@1,2 &&
112 test_when_finished cleanup_git &&
115 git log --oneline refs/heads/master >lines &&
116 test_line_count = 2 lines &&
117 git log --oneline refs/heads/p4/master >lines &&
118 test_line_count = 2 lines &&
119 test_must_fail git p4 sync &&
121 git p4 sync --import-local &&
122 git log --oneline refs/heads/master >lines &&
123 test_line_count = 2 lines &&
124 git log --oneline refs/heads/p4/master >lines &&
125 test_line_count = 3 lines
129 test_expect_success 'clone --max-changes' '
130 git p4 clone --dest="$git" --max-changes 2 //depot@all &&
131 test_when_finished cleanup_git &&
134 git log --oneline refs/heads/master >lines &&
135 test_line_count = 2 lines
139 test_expect_success 'clone --keep-path' '
143 echo f4 >sub/dir/f4 &&
145 p4 submit -d "change 4"
147 git p4 clone --dest="$git" --keep-path //depot/sub/dir@all &&
148 test_when_finished cleanup_git &&
151 test_path_is_missing f4 &&
152 test_path_is_file sub/dir/f4
155 git p4 clone --dest="$git" //depot/sub/dir@all &&
158 test_path_is_file f4 &&
159 test_path_is_missing sub/dir/f4
163 # clone --use-client-spec must still specify a depot path
164 # if given, it should rearrange files according to client spec
165 # when it has view lines that match the depot path
166 # XXX: should clone/sync just use the client spec exactly, rather
167 # than needing depot paths?
168 test_expect_success 'clone --use-client-spec' '
172 test_must_fail git p4 clone --dest="$git" --use-client-spec
174 cli2=$(test-path-utils real_path "$TRASH_DIRECTORY/cli2") &&
176 test_when_finished "rmdir \"$cli2\"" &&
183 View: //depot/sub/... //client2/bus/...
187 test_when_finished cleanup_git &&
188 git p4 clone --dest="$git" --use-client-spec //depot/... &&
191 test_path_is_file bus/dir/f4 &&
192 test_path_is_missing file1
196 # same thing again, this time with variable instead of option
200 git config git-p4.useClientSpec true &&
201 git p4 sync //depot/... &&
202 git checkout -b master p4/master &&
203 test_path_is_file bus/dir/f4 &&
204 test_path_is_missing file1
208 test_expect_success 'kill p4d' '