2
3
test_description='git-p4 tests'
4
5
-. ./test-lib.sh
5
+. ./lib-git-p4.sh
6
7
-( p4 -h && p4d -h ) >/dev/null 2>&1 || {
8
- skip_all='skipping git-p4 tests; no p4 or p4d'
9
- test_done
10
-}
11
-
12
-GITP4=$GIT_BUILD_DIR/contrib/fast-import/git-p4
13
-P4DPORT=10669
14
-
15
-export P4PORT=localhost:$P4DPORT
16
-
17
-db="$TRASH_DIRECTORY/db"
18
-cli="$TRASH_DIRECTORY/cli"
19
-git="$TRASH_DIRECTORY/git"
20
-
21
-test_debug 'echo p4d -q -d -r "$db" -p $P4DPORT'
22
-test_expect_success setup '
23
- mkdir -p "$db" &&
24
- p4d -q -d -r "$db" -p $P4DPORT &&
25
- mkdir -p "$cli" &&
26
- mkdir -p "$git" &&
27
- export P4PORT=localhost:$P4DPORT
7
+test_expect_success 'start p4d' '
8
+ start_p4d
9
'
10
11
test_expect_success 'add p4 files' '
31
- cd "$cli" &&
32
- p4 client -i <<-EOF &&
33
- Client: client
34
- Description: client
35
- Root: $cli
36
- View: //depot/... //client/...
37
- EOF
38
- export P4CLIENT=client &&
39
- echo file1 >file1 &&
40
- p4 add file1 &&
41
- p4 submit -d "file1" &&
42
- echo file2 >file2 &&
43
- p4 add file2 &&
44
- p4 submit -d "file2" &&
45
- cd "$TRASH_DIRECTORY"
12
+ (
13
+ cd "$cli" &&
14
+ echo file1 >file1 &&
15
+ p4 add file1 &&
16
+ p4 submit -d "file1" &&
17
+ echo file2 >file2 &&
18
+ p4 add file2 &&
19
+ p4 submit -d "file2"
20
+ )
21
'
22
48
-cleanup_git() {
49
- cd "$TRASH_DIRECTORY" &&
50
- rm -rf "$git" &&
51
- mkdir "$git"
52
-}
53
-
23
test_expect_success 'basic git-p4 clone' '
24
"$GITP4" clone --dest="$git" //depot &&
25
test_when_finished cleanup_git &&
57
- cd "$git" &&
58
- git log --oneline >lines &&
59
- test_line_count = 1 lines
26
+ (
27
+ cd "$git" &&
28
+ git log --oneline >lines &&
29
+ test_line_count = 1 lines
30
+ )
31
'
32
33
test_expect_success 'git-p4 clone @all' '
34
"$GITP4" clone --dest="$git" //depot@all &&
35
test_when_finished cleanup_git &&
65
- cd "$git" &&
66
- git log --oneline >lines &&
67
- test_line_count = 2 lines
36
+ (
37
+ cd "$git" &&
38
+ git log --oneline >lines &&
39
+ test_line_count = 2 lines
40
+ )
41
'
42
43
test_expect_success 'git-p4 sync uninitialized repo' '
44
test_create_repo "$git" &&
45
test_when_finished cleanup_git &&
73
- cd "$git" &&
74
- test_must_fail "$GITP4" sync
46
+ (
47
+ cd "$git" &&
48
+ test_must_fail "$GITP4" sync
49
+ )
50
'
51
52
#
56
test_expect_success 'git-p4 sync new branch' '
57
test_create_repo "$git" &&
58
test_when_finished cleanup_git &&
84
- cd "$git" &&
85
- test_commit head &&
86
- "$GITP4" sync --branch=refs/remotes/p4/depot //depot@all &&
87
- git log --oneline p4/depot >lines &&
88
- test_line_count = 2 lines
59
+ (
60
+ cd "$git" &&
61
+ test_commit head &&
62
+ "$GITP4" sync --branch=refs/remotes/p4/depot //depot@all &&
63
+ git log --oneline p4/depot >lines &&
64
+ test_line_count = 2 lines
65
+ )
66
'
67
68
test_expect_success 'exit when p4 fails to produce marshaled output' '
69
badp4dir="$TRASH_DIRECTORY/badp4dir" &&
93
- mkdir -p "$badp4dir" &&
94
- test_when_finished "rm -rf $badp4dir" &&
70
+ mkdir "$badp4dir" &&
71
+ test_when_finished "rm \"$badp4dir/p4\" && rmdir \"$badp4dir\"" &&
72
cat >"$badp4dir"/p4 <<-EOF &&
73
#!$SHELL_PATH
74
exit 1
80
'
81
82
test_expect_success 'add p4 files with wildcards in the names' '
106
- cd "$cli" &&
107
- echo file-wild-hash >file-wild#hash &&
108
- echo file-wild-star >file-wild\*star &&
109
- echo file-wild-at >file-wild@at &&
110
- echo file-wild-percent >file-wild%percent &&
111
- p4 add -f file-wild* &&
112
- p4 submit -d "file wildcards"
83
+ (
84
+ cd "$cli" &&
85
+ echo file-wild-hash >file-wild#hash &&
86
+ echo file-wild-star >file-wild\*star &&
87
+ echo file-wild-at >file-wild@at &&
88
+ echo file-wild-percent >file-wild%percent &&
89
+ p4 add -f file-wild* &&
90
+ p4 submit -d "file wildcards"
91
+ )
92
'
93
94
test_expect_success 'wildcard files git-p4 clone' '
95
"$GITP4" clone --dest="$git" //depot &&
96
test_when_finished cleanup_git &&
118
- cd "$git" &&
119
- test -f file-wild#hash &&
120
- test -f file-wild\*star &&
121
- test -f file-wild@at &&
122
- test -f file-wild%percent
97
+ (
98
+ cd "$git" &&
99
+ test -f file-wild#hash &&
100
+ test -f file-wild\*star &&
101
+ test -f file-wild@at &&
102
+ test -f file-wild%percent
103
+ )
104
'
105
106
test_expect_success 'clone bare' '
107
"$GITP4" clone --dest="$git" --bare //depot &&
108
test_when_finished cleanup_git &&
128
- cd "$git" &&
129
- test ! -d .git &&
130
- bare=`git config --get core.bare` &&
131
- test "$bare" = true
109
+ (
110
+ cd "$git" &&
111
+ test ! -d .git &&
112
+ bare=`git config --get core.bare` &&
113
+ test "$bare" = true
114
+ )
115
'
116
117
p4_add_user() {
135
- name=$1
136
- fullname=$2
137
- p4 user -f -i <<EOF &&
138
-User: $name
139
-Email: $name@localhost
140
-FullName: $fullname
141
-EOF
142
- p4 passwd -P secret $name
118
+ name=$1 fullname=$2 &&
119
+ p4 user -f -i <<-EOF &&
120
+ User: $name
121
+ Email: $name@localhost
122
+ FullName: $fullname
123
+ EOF
124
+ p4 passwd -P secret $name
125
}
126
127
p4_grant_admin() {
146
- name=$1
147
- p4 protect -o |\
148
- awk "{print}END{print \" admin user $name * //depot/...\"}" |\
149
- p4 protect -i
128
+ name=$1 &&
129
+ {
130
+ p4 protect -o &&
131
+ echo " admin user $name * //depot/..."
132
+ } | p4 protect -i
133
}
134
135
p4_check_commit_author() {
153
- file=$1
154
- user=$2
155
- if p4 changes -m 1 //depot/$file | grep $user > /dev/null ; then
156
- return 0
157
- else
158
- echo "file $file not modified by user $user" 1>&2
159
- return 1
160
- fi
136
+ file=$1 user=$2 &&
137
+ p4 changes -m 1 //depot/$file | grep -q $user
138
}
139
140
make_change_by_user() {
151
p4_grant_admin alice &&
152
"$GITP4" clone --dest="$git" //depot &&
153
test_when_finished cleanup_git &&
177
- cd "$git" &&
178
- echo "username: a change by alice" >> file1 &&
179
- echo "username: a change by bob" >> file2 &&
180
- git commit --author "Alice <alice@localhost>" -m "a change by alice" file1 &&
181
- git commit --author "Bob <bob@localhost>" -m "a change by bob" file2 &&
182
- git config git-p4.skipSubmitEditCheck true &&
183
- P4EDITOR=touch P4USER=alice P4PASSWD=secret "$GITP4" commit --preserve-user &&
184
- p4_check_commit_author file1 alice &&
185
- p4_check_commit_author file2 bob
154
+ (
155
+ cd "$git" &&
156
+ echo "username: a change by alice" >>file1 &&
157
+ echo "username: a change by bob" >>file2 &&
158
+ git commit --author "Alice <alice@localhost>" -m "a change by alice" file1 &&
159
+ git commit --author "Bob <bob@localhost>" -m "a change by bob" file2 &&
160
+ git config git-p4.skipSubmitEditCheck true &&
161
+ P4EDITOR=touch P4USER=alice P4PASSWD=secret "$GITP4" commit --preserve-user &&
162
+ p4_check_commit_author file1 alice &&
163
+ p4_check_commit_author file2 bob
164
+ )
165
'
166
167
# Test username support, submitting as bob, who lacks admin rights. Should
169
test_expect_success 'refuse to preserve users without perms' '
170
"$GITP4" clone --dest="$git" //depot &&
171
test_when_finished cleanup_git &&
193
- cd "$git" &&
194
- git config git-p4.skipSubmitEditCheck true &&
195
- echo "username-noperms: a change by alice" >> file1 &&
196
- git commit --author "Alice <alice@localhost>" -m "perms: a change by alice" file1 &&
197
- ! P4EDITOR=touch P4USER=bob P4PASSWD=secret "$GITP4" commit --preserve-user &&
198
- ! git diff --exit-code HEAD..p4/master > /dev/null
172
+ (
173
+ cd "$git" &&
174
+ git config git-p4.skipSubmitEditCheck true &&
175
+ echo "username-noperms: a change by alice" >>file1 &&
176
+ git commit --author "Alice <alice@localhost>" -m "perms: a change by alice" file1 &&
177
+ P4EDITOR=touch P4USER=bob P4PASSWD=secret test_must_fail "$GITP4" commit --preserve-user &&
178
+ test_must_fail git diff --exit-code HEAD..p4/master
179
+ )
180
'
181
182
# What happens with unknown author? Without allowMissingP4Users it should fail.
183
test_expect_success 'preserve user where author is unknown to p4' '
184
"$GITP4" clone --dest="$git" //depot &&
185
test_when_finished cleanup_git &&
205
- cd "$git" &&
206
- git config git-p4.skipSubmitEditCheck true &&
207
- echo "username-bob: a change by bob" >> file1 &&
208
- git commit --author "Bob <bob@localhost>" -m "preserve: a change by bob" file1 &&
209
- echo "username-unknown: a change by charlie" >> file1 &&
210
- git commit --author "Charlie <charlie@localhost>" -m "preserve: a change by charlie" file1 &&
211
- ! P4EDITOR=touch P4USER=alice P4PASSWD=secret "$GITP4" commit --preserve-user &&
212
- ! git diff --exit-code HEAD..p4/master > /dev/null &&
213
- echo "$0: repeat with allowMissingP4Users enabled" &&
214
- git config git-p4.allowMissingP4Users true &&
215
- git config git-p4.preserveUser true &&
216
- P4EDITOR=touch P4USER=alice P4PASSWD=secret "$GITP4" commit &&
217
- git diff --exit-code HEAD..p4/master > /dev/null &&
218
- p4_check_commit_author file1 alice
186
+ (
187
+ cd "$git" &&
188
+ git config git-p4.skipSubmitEditCheck true &&
189
+ echo "username-bob: a change by bob" >>file1 &&
190
+ git commit --author "Bob <bob@localhost>" -m "preserve: a change by bob" file1 &&
191
+ echo "username-unknown: a change by charlie" >>file1 &&
192
+ git commit --author "Charlie <charlie@localhost>" -m "preserve: a change by charlie" file1 &&
193
+ P4EDITOR=touch P4USER=alice P4PASSWD=secret test_must_fail "$GITP4" commit --preserve-user &&
194
+ test_must_fail git diff --exit-code HEAD..p4/master &&
195
+
196
+ echo "$0: repeat with allowMissingP4Users enabled" &&
197
+ git config git-p4.allowMissingP4Users true &&
198
+ git config git-p4.preserveUser true &&
199
+ P4EDITOR=touch P4USER=alice P4PASSWD=secret "$GITP4" commit &&
200
+ git diff --exit-code HEAD..p4/master &&
201
+ p4_check_commit_author file1 alice
202
+ )
203
'
204
205
# If we're *not* using --preserve-user, git-p4 should warn if we're submitting
209
test_expect_success 'not preserving user with mixed authorship' '
210
"$GITP4" clone --dest="$git" //depot &&
211
test_when_finished cleanup_git &&
228
- cd "$git" &&
229
- git config git-p4.skipSubmitEditCheck true &&
230
- p4_add_user derek Derek &&
231
-
232
- make_change_by_user usernamefile3 Derek derek@localhost &&
233
- P4EDITOR=cat P4USER=alice P4PASSWD=secret "$GITP4" commit >actual &&
234
- grep "git author derek@localhost does not match" actual &&
235
-
236
- make_change_by_user usernamefile3 Charlie charlie@localhost &&
237
- P4EDITOR=cat P4USER=alice P4PASSWD=secret "$GITP4" commit >actual &&
238
- grep "git author charlie@localhost does not match" actual &&
239
-
240
- make_change_by_user usernamefile3 alice alice@localhost &&
241
- P4EDITOR=cat P4USER=alice P4PASSWD=secret "$GITP4" commit >actual &&
242
- ! grep "git author.*does not match" actual &&
243
-
244
- git config git-p4.skipUserNameCheck true &&
245
- make_change_by_user usernamefile3 Charlie charlie@localhost &&
246
- P4EDITOR=cat P4USER=alice P4PASSWD=secret "$GITP4" commit >actual &&
247
- ! grep "git author.*does not match" actual &&
248
-
249
- p4_check_commit_author usernamefile3 alice
212
+ (
213
+ cd "$git" &&
214
+ git config git-p4.skipSubmitEditCheck true &&
215
+ p4_add_user derek Derek &&
216
+
217
+ make_change_by_user usernamefile3 Derek derek@localhost &&
218
+ P4EDITOR=cat P4USER=alice P4PASSWD=secret "$GITP4" commit |\
219
+ grep "git author derek@localhost does not match" &&
220
+
221
+ make_change_by_user usernamefile3 Charlie charlie@localhost &&
222
+ P4EDITOR=cat P4USER=alice P4PASSWD=secret "$GITP4" commit |\
223
+ grep "git author charlie@localhost does not match" &&
224
+
225
+ make_change_by_user usernamefile3 alice alice@localhost &&
226
+ P4EDITOR=cat P4USER=alice P4PASSWD=secret "$GITP4" |\
227
+ test_must_fail grep "git author.*does not match" &&
228
+
229
+ git config git-p4.skipUserNameCheck true &&
230
+ make_change_by_user usernamefile3 Charlie charlie@localhost &&
231
+ P4EDITOR=cat P4USER=alice P4PASSWD=secret "$GITP4" commit |\
232
+ test_must_fail grep "git author.*does not match" &&
233
+
234
+ p4_check_commit_author usernamefile3 alice
235
+ )
236
'
237
238
marshal_dump() {
239
what=$1
254
- python -c 'import marshal, sys; d = marshal.load(sys.stdin); print d["'$what'"]'
240
+ "$PYTHON_PATH" -c 'import marshal, sys; d = marshal.load(sys.stdin); print d["'$what'"]'
241
}
242
243
# Sleep a bit so that the top-most p4 change did not happen "now". Then
249
sleep 3 &&
250
"$GITP4" clone --dest="$git" //depot &&
251
test_when_finished cleanup_git &&
266
- cd "$git" &&
267
- gittime=$(git show -s --raw --pretty=format:%at HEAD) &&
268
- echo $p4time $gittime &&
269
- test $p4time = $gittime
252
+ (
253
+ cd "$git" &&
254
+ gittime=$(git show -s --raw --pretty=format:%at HEAD) &&
255
+ echo $p4time $gittime &&
256
+ test $p4time = $gittime
257
+ )
258
'
259
260
# Rename a file and confirm that rename is not detected in P4.
267
test_expect_success 'detect renames' '
268
"$GITP4" clone --dest="$git" //depot@all &&
269
test_when_finished cleanup_git &&
282
- cd "$git" &&
283
- git config git-p4.skipSubmitEditCheck true &&
284
-
285
- git mv file1 file4 &&
286
- git commit -a -m "Rename file1 to file4" &&
287
- git diff-tree -r -M HEAD &&
288
- "$GITP4" submit &&
289
- p4 filelog //depot/file4 &&
290
- ! p4 filelog //depot/file4 | grep -q "branch from" &&
291
-
292
- git mv file4 file5 &&
293
- git commit -a -m "Rename file4 to file5" &&
294
- git diff-tree -r -M HEAD &&
295
- git config git-p4.detectRenames true &&
296
- "$GITP4" submit &&
297
- p4 filelog //depot/file5 &&
298
- p4 filelog //depot/file5 | grep -q "branch from //depot/file4" &&
299
-
300
- git mv file5 file6 &&
301
- echo update >>file6 &&
302
- git add file6 &&
303
- git commit -a -m "Rename file5 to file6 with changes" &&
304
- git diff-tree -r -M HEAD &&
305
- level=$(git diff-tree -r -M HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/R0*//") &&
306
- test -n "$level" && test "$level" -gt 0 && test "$level" -lt 98 &&
307
- git config git-p4.detectRenames $((level + 2)) &&
308
- "$GITP4" submit &&
309
- p4 filelog //depot/file6 &&
310
- ! p4 filelog //depot/file6 | grep -q "branch from" &&
311
-
312
- git mv file6 file7 &&
313
- echo update >>file7 &&
314
- git add file7 &&
315
- git commit -a -m "Rename file6 to file7 with changes" &&
316
- git diff-tree -r -M HEAD &&
317
- level=$(git diff-tree -r -M HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/R0*//") &&
318
- test -n "$level" && test "$level" -gt 2 && test "$level" -lt 100 &&
319
- git config git-p4.detectRenames $((level - 2)) &&
320
- "$GITP4" submit &&
321
- p4 filelog //depot/file7 &&
322
- p4 filelog //depot/file7 | grep -q "branch from //depot/file6"
270
+ (
271
+ cd "$git" &&
272
+ git config git-p4.skipSubmitEditCheck true &&
273
+
274
+ git mv file1 file4 &&
275
+ git commit -a -m "Rename file1 to file4" &&
276
+ git diff-tree -r -M HEAD &&
277
+ "$GITP4" submit &&
278
+ p4 filelog //depot/file4 &&
279
+ p4 filelog //depot/file4 | test_must_fail grep -q "branch from" &&
280
+
281
+ git mv file4 file5 &&
282
+ git commit -a -m "Rename file4 to file5" &&
283
+ git diff-tree -r -M HEAD &&
284
+ git config git-p4.detectRenames true &&
285
+ "$GITP4" submit &&
286
+ p4 filelog //depot/file5 &&
287
+ p4 filelog //depot/file5 | grep -q "branch from //depot/file4" &&
288
+
289
+ git mv file5 file6 &&
290
+ echo update >>file6 &&
291
+ git add file6 &&
292
+ git commit -a -m "Rename file5 to file6 with changes" &&
293
+ git diff-tree -r -M HEAD &&
294
+ level=$(git diff-tree -r -M HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/R0*//") &&
295
+ test -n "$level" && test "$level" -gt 0 && test "$level" -lt 98 &&
296
+ git config git-p4.detectRenames $(($level + 2)) &&
297
+ "$GITP4" submit &&
298
+ p4 filelog //depot/file6 &&
299
+ p4 filelog //depot/file6 | test_must_fail grep -q "branch from" &&
300
+
301
+ git mv file6 file7 &&
302
+ echo update >>file7 &&
303
+ git add file7 &&
304
+ git commit -a -m "Rename file6 to file7 with changes" &&
305
+ git diff-tree -r -M HEAD &&
306
+ level=$(git diff-tree -r -M HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/R0*//") &&
307
+ test -n "$level" && test "$level" -gt 2 && test "$level" -lt 100 &&
308
+ git config git-p4.detectRenames $(($level - 2)) &&
309
+ "$GITP4" submit &&
310
+ p4 filelog //depot/file7 &&
311
+ p4 filelog //depot/file7 | grep -q "branch from //depot/file6"
312
+ )
313
'
314
315
# Copy a file and confirm that copy is not detected in P4.
326
test_expect_success 'detect copies' '
327
"$GITP4" clone --dest="$git" //depot@all &&
328
test_when_finished cleanup_git &&
339
- cd "$git" &&
340
- git config git-p4.skipSubmitEditCheck true &&
341
-
342
- cp file2 file8 &&
343
- git add file8 &&
344
- git commit -a -m "Copy file2 to file8" &&
345
- git diff-tree -r -C HEAD &&
346
- "$GITP4" submit &&
347
- p4 filelog //depot/file8 &&
348
- ! p4 filelog //depot/file8 | grep -q "branch from" &&
349
-
350
- cp file2 file9 &&
351
- git add file9 &&
352
- git commit -a -m "Copy file2 to file9" &&
353
- git diff-tree -r -C HEAD &&
354
- git config git-p4.detectCopies true &&
355
- "$GITP4" submit &&
356
- p4 filelog //depot/file9 &&
357
- ! p4 filelog //depot/file9 | grep -q "branch from" &&
358
-
359
- echo "file2" >>file2 &&
360
- cp file2 file10 &&
361
- git add file2 file10 &&
362
- git commit -a -m "Modify and copy file2 to file10" &&
363
- git diff-tree -r -C HEAD &&
364
- "$GITP4" submit &&
365
- p4 filelog //depot/file10 &&
366
- p4 filelog //depot/file10 | grep -q "branch from //depot/file" &&
367
-
368
- cp file2 file11 &&
369
- git add file11 &&
370
- git commit -a -m "Copy file2 to file11" &&
371
- git diff-tree -r -C --find-copies-harder HEAD &&
372
- src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
373
- test "$src" = file10 &&
374
- git config git-p4.detectCopiesHarder true &&
375
- "$GITP4" submit &&
376
- p4 filelog //depot/file11 &&
377
- p4 filelog //depot/file11 | grep -q "branch from //depot/file" &&
378
-
379
- cp file2 file12 &&
380
- echo "some text" >>file12 &&
381
- git add file12 &&
382
- git commit -a -m "Copy file2 to file12 with changes" &&
383
- git diff-tree -r -C --find-copies-harder HEAD &&
384
- level=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/C0*//") &&
385
- test -n "$level" && test "$level" -gt 0 && test "$level" -lt 98 &&
386
- src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
387
- test "$src" = file10 &&
388
- git config git-p4.detectCopies $((level + 2)) &&
389
- "$GITP4" submit &&
390
- p4 filelog //depot/file12 &&
391
- ! p4 filelog //depot/file12 | grep -q "branch from" &&
392
-
393
- cp file2 file13 &&
394
- echo "different text" >>file13 &&
395
- git add file13 &&
396
- git commit -a -m "Copy file2 to file13 with changes" &&
397
- git diff-tree -r -C --find-copies-harder HEAD &&
398
- level=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/C0*//") &&
399
- test -n "$level" && test "$level" -gt 2 && test "$level" -lt 100 &&
400
- src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
401
- test "$src" = file10 &&
402
- git config git-p4.detectCopies $((level - 2)) &&
403
- "$GITP4" submit &&
404
- p4 filelog //depot/file13 &&
405
- p4 filelog //depot/file13 | grep -q "branch from //depot/file"
406
-'
407
-
408
-# Create a simple branch structure in P4 depot to check if it is correctly
409
-# cloned.
410
-test_expect_success 'add simple p4 branches' '
411
- cd "$cli" &&
412
- mkdir branch1 &&
413
- cd branch1 &&
414
- echo file1 >file1 &&
415
- echo file2 >file2 &&
416
- p4 add file1 file2 &&
417
- p4 submit -d "branch1" &&
418
- p4 integrate //depot/branch1/... //depot/branch2/... &&
419
- p4 submit -d "branch2" &&
420
- echo file3 >file3 &&
421
- p4 add file3 &&
422
- p4 submit -d "add file3 in branch1" &&
423
- p4 open file2 &&
424
- echo update >>file2 &&
425
- p4 submit -d "update file2 in branch1" &&
426
- p4 integrate //depot/branch1/... //depot/branch3/... &&
427
- p4 submit -d "branch3" &&
428
- cd "$TRASH_DIRECTORY"
429
-'
430
-
431
-# Configure branches through git-config and clone them.
432
-# All files are tested to make sure branches were cloned correctly.
433
-# Finally, make an update to branch1 on P4 side to check if it is imported
434
-# correctly by git-p4.
435
-test_expect_success 'git-p4 clone simple branches' '
436
- test_when_finished cleanup_git &&
437
- test_create_repo "$git" &&
438
- cd "$git" &&
439
- git config git-p4.branchList branch1:branch2 &&
440
- git config --add git-p4.branchList branch1:branch3 &&
441
- "$GITP4" clone --dest=. --detect-branches //depot@all &&
442
- git log --all --graph --decorate --stat &&
443
- git reset --hard p4/depot/branch1 &&
444
- test -f file1 &&
445
- test -f file2 &&
446
- test -f file3 &&
447
- grep -q update file2 &&
448
- git reset --hard p4/depot/branch2 &&
449
- test -f file1 &&
450
- test -f file2 &&
451
- test ! -f file3 &&
452
- ! grep -q update file2 &&
453
- git reset --hard p4/depot/branch3 &&
454
- test -f file1 &&
455
- test -f file2 &&
456
- test -f file3 &&
457
- grep -q update file2 &&
458
- cd "$cli" &&
459
- cd branch1 &&
460
- p4 edit file2 &&
461
- echo file2_ >>file2 &&
462
- p4 submit -d "update file2 in branch1" &&
463
- cd "$git" &&
464
- git reset --hard p4/depot/branch1 &&
465
- "$GITP4" rebase &&
466
- grep -q file2_ file2
329
+ (
330
+ cd "$git" &&
331
+ git config git-p4.skipSubmitEditCheck true &&
332
+
333
+ cp file2 file8 &&
334
+ git add file8 &&
335
+ git commit -a -m "Copy file2 to file8" &&
336
+ git diff-tree -r -C HEAD &&
337
+ "$GITP4" submit &&
338
+ p4 filelog //depot/file8 &&
339
+ p4 filelog //depot/file8 | test_must_fail grep -q "branch from" &&
340
+
341
+ cp file2 file9 &&
342
+ git add file9 &&
343
+ git commit -a -m "Copy file2 to file9" &&
344
+ git diff-tree -r -C HEAD &&
345
+ git config git-p4.detectCopies true &&
346
+ "$GITP4" submit &&
347
+ p4 filelog //depot/file9 &&
348
+ p4 filelog //depot/file9 | test_must_fail grep -q "branch from" &&
349
+
350
+ echo "file2" >>file2 &&
351
+ cp file2 file10 &&
352
+ git add file2 file10 &&
353
+ git commit -a -m "Modify and copy file2 to file10" &&
354
+ git diff-tree -r -C HEAD &&
355
+ "$GITP4" submit &&
356
+ p4 filelog //depot/file10 &&
357
+ p4 filelog //depot/file10 | grep -q "branch from //depot/file" &&
358
+
359
+ cp file2 file11 &&
360
+ git add file11 &&
361
+ git commit -a -m "Copy file2 to file11" &&
362
+ git diff-tree -r -C --find-copies-harder HEAD &&
363
+ src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
364
+ test "$src" = file10 &&
365
+ git config git-p4.detectCopiesHarder true &&
366
+ "$GITP4" submit &&
367
+ p4 filelog //depot/file11 &&
368
+ p4 filelog //depot/file11 | grep -q "branch from //depot/file" &&
369
+
370
+ cp file2 file12 &&
371
+ echo "some text" >>file12 &&
372
+ git add file12 &&
373
+ git commit -a -m "Copy file2 to file12 with changes" &&
374
+ git diff-tree -r -C --find-copies-harder HEAD &&
375
+ level=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/C0*//") &&
376
+ test -n "$level" && test "$level" -gt 0 && test "$level" -lt 98 &&
377
+ src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
378
+ test "$src" = file10 &&
379
+ git config git-p4.detectCopies $(($level + 2)) &&
380
+ "$GITP4" submit &&
381
+ p4 filelog //depot/file12 &&
382
+ p4 filelog //depot/file12 | test_must_fail grep -q "branch from" &&
383
+
384
+ cp file2 file13 &&
385
+ echo "different text" >>file13 &&
386
+ git add file13 &&
387
+ git commit -a -m "Copy file2 to file13 with changes" &&
388
+ git diff-tree -r -C --find-copies-harder HEAD &&
389
+ level=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/C0*//") &&
390
+ test -n "$level" && test "$level" -gt 2 && test "$level" -lt 100 &&
391
+ src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
392
+ test "$src" = file10 &&
393
+ git config git-p4.detectCopies $(($level - 2)) &&
394
+ "$GITP4" submit &&
395
+ p4 filelog //depot/file13 &&
396
+ p4 filelog //depot/file13 | grep -q "branch from //depot/file"
397
+ )
398
'
399
469
-test_expect_success 'shutdown' '
470
- pid=`pgrep -f p4d` &&
471
- test -n "$pid" &&
472
- test_debug "ps wl `echo $pid`" &&
473
- kill $pid
400
+test_expect_success 'kill p4d' '
401
+ kill_p4d
402
'
403
404
test_done