3 test_description
='git p4 tests'
7 test_expect_success
'start p4d' '
11 test_expect_success
'add p4 files' '
16 p4 submit -d "file1" &&
23 test_expect_success
'basic git p4 clone' '
24 git p4 clone --dest="$git" //depot &&
25 test_when_finished cleanup_git &&
28 git log --oneline >lines &&
29 test_line_count = 1 lines
33 test_expect_success
'git p4 clone @all' '
34 git p4 clone --dest="$git" //depot@all &&
35 test_when_finished cleanup_git &&
38 git log --oneline >lines &&
39 test_line_count = 2 lines
43 test_expect_success
'git p4 sync uninitialized repo' '
44 test_create_repo "$git" &&
45 test_when_finished cleanup_git &&
48 test_must_fail git p4 sync 2>errs &&
49 test_i18ngrep "Perhaps you never did" errs
54 # Create a git repo by hand. Add a commit so that HEAD is valid.
55 # Test imports a new p4 repository into a new git branch.
57 test_expect_success
'git p4 sync new branch' '
58 test_create_repo "$git" &&
59 test_when_finished cleanup_git &&
63 git p4 sync --branch=refs/remotes/p4/depot //depot@all &&
64 git log --oneline p4/depot >lines &&
65 test_line_count = 2 lines
69 test_expect_success
'clone two dirs' '
73 echo sub1/f1 >sub1/f1 &&
74 echo sub2/f2 >sub2/f2 &&
76 p4 submit -d "sub1/f1" &&
78 p4 submit -d "sub2/f2"
80 git p4 clone --dest="$git" //depot/sub1 //depot/sub2 &&
81 test_when_finished cleanup_git &&
84 git ls-files >lines &&
85 test_line_count = 2 lines &&
86 git log --oneline p4/master >lines &&
87 test_line_count = 1 lines
91 test_expect_success
'clone two dirs, @all' '
94 echo sub1/f3 >sub1/f3 &&
96 p4 submit -d "sub1/f3"
98 git p4 clone --dest="$git" //depot/sub1@all //depot/sub2@all &&
99 test_when_finished cleanup_git &&
102 git ls-files >lines &&
103 test_line_count = 3 lines &&
104 git log --oneline p4/master >lines &&
105 test_line_count = 3 lines
109 test_expect_success
'clone two dirs, @all, conflicting files' '
112 echo sub2/f3 >sub2/f3 &&
114 p4 submit -d "sub2/f3"
116 git p4 clone --dest="$git" //depot/sub1@all //depot/sub2@all &&
117 test_when_finished cleanup_git &&
120 git ls-files >lines &&
121 test_line_count = 3 lines &&
122 git log --oneline p4/master >lines &&
123 test_line_count = 4 lines &&
124 echo sub2/f3 >expected &&
129 test_expect_success
'exit when p4 fails to produce marshaled output' '
131 test_when_finished "rm badp4dir/p4 && rmdir badp4dir" &&
132 cat >badp4dir/p4 <<-EOF &&
136 chmod 755 badp4dir/p4 &&
138 PATH="$TRASH_DIRECTORY/badp4dir:$PATH" &&
140 test_expect_code 1 git p4 clone --dest="$git" //depot >errs 2>&1
143 ! test_i18ngrep Traceback errs
146 test_expect_success
'clone bare' '
148 git p4 clone --dest="$git" --bare //depot &&
149 test_when_finished cleanup_git &&
153 bare=`git config --get core.bare` &&
158 # Sleep a bit so that the top-most p4 change did not happen "now". Then
159 # import the repo and make sure that the initial import has the same time
160 # as the top-most change.
161 test_expect_success
'initial import time from top change time' '
162 p4change=$(p4 -G changes -m 1 //depot/... | marshal_dump change) &&
163 p4time=$(p4 -G changes -m 1 //depot/... | marshal_dump time) &&
165 git p4 clone --dest="$git" //depot &&
166 test_when_finished cleanup_git &&
169 gittime=$(git show -s --raw --pretty=format:%at HEAD) &&
170 echo $p4time $gittime &&
171 test $p4time = $gittime
175 test_expect_success
'kill p4d' '