]> git.ipfire.org Git - thirdparty/git.git/blame - t/t9806-git-p4-options.sh
Git 1.8.1.1
[thirdparty/git.git] / t / t9806-git-p4-options.sh
CommitLineData
ef86890c
PW
1#!/bin/sh
2
6ab1d76c 3test_description='git p4 options'
ef86890c
PW
4
5. ./lib-git-p4.sh
6
7test_expect_success 'start p4d' '
8 start_p4d
9'
10
11test_expect_success 'init depot' '
12 (
13 cd "$cli" &&
14 echo file1 >file1 &&
15 p4 add file1 &&
16 p4 submit -d "change 1" &&
17 echo file2 >file2 &&
18 p4 add file2 &&
19 p4 submit -d "change 2" &&
20 echo file3 >file3 &&
21 p4 add file3 &&
22 p4 submit -d "change 3"
23 )
24'
25
26test_expect_success 'clone no --git-dir' '
6ab1d76c 27 test_must_fail git p4 clone --git-dir=xx //depot
ef86890c
PW
28'
29
1471c6b1 30test_expect_success 'clone --branch' '
6ab1d76c 31 git p4 clone --branch=refs/remotes/p4/sb --dest="$git" //depot &&
1471c6b1
PW
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
58c8bc7c 41test_expect_success 'clone --changesfile' '
08c5eb7a
PW
42 test_when_finished "rm cf" &&
43 printf "1\n3\n" >cf &&
44 git p4 clone --changesfile="$TRASH_DIRECTORY/cf" --dest="$git" //depot &&
58c8bc7c
PW
45 test_when_finished cleanup_git &&
46 (
47 cd "$git" &&
48 git log --oneline p4/master >lines &&
49 test_line_count = 2 lines
50 test_path_is_file file1 &&
51 test_path_is_missing file2 &&
52 test_path_is_file file3
53 )
54'
55
56test_expect_success 'clone --changesfile, @all' '
08c5eb7a
PW
57 test_when_finished "rm cf" &&
58 printf "1\n3\n" >cf &&
59 test_must_fail git p4 clone --changesfile="$TRASH_DIRECTORY/cf" --dest="$git" //depot@all
58c8bc7c
PW
60'
61
5a92a6ce
PW
62# imports both master and p4/master in refs/heads
63# requires --import-local on sync to find p4 refs/heads
64# does not update master on sync, just p4/master
65test_expect_success 'clone/sync --import-local' '
6ab1d76c 66 git p4 clone --import-local --dest="$git" //depot@1,2 &&
5a92a6ce
PW
67 test_when_finished cleanup_git &&
68 (
69 cd "$git" &&
70 git log --oneline refs/heads/master >lines &&
71 test_line_count = 2 lines &&
72 git log --oneline refs/heads/p4/master >lines &&
73 test_line_count = 2 lines &&
6ab1d76c 74 test_must_fail git p4 sync &&
5a92a6ce 75
6ab1d76c 76 git p4 sync --import-local &&
5a92a6ce
PW
77 git log --oneline refs/heads/master >lines &&
78 test_line_count = 2 lines &&
79 git log --oneline refs/heads/p4/master >lines &&
80 test_line_count = 3 lines
81 )
82'
83
7fbe1ce9 84test_expect_success 'clone --max-changes' '
6ab1d76c 85 git p4 clone --dest="$git" --max-changes 2 //depot@all &&
7fbe1ce9
PW
86 test_when_finished cleanup_git &&
87 (
88 cd "$git" &&
89 git log --oneline refs/heads/master >lines &&
90 test_line_count = 2 lines
91 )
92'
93
ae3f41f2
PW
94test_expect_success 'clone --keep-path' '
95 (
96 cd "$cli" &&
97 mkdir -p sub/dir &&
98 echo f4 >sub/dir/f4 &&
99 p4 add sub/dir/f4 &&
100 p4 submit -d "change 4"
101 ) &&
6ab1d76c 102 git p4 clone --dest="$git" --keep-path //depot/sub/dir@all &&
ae3f41f2
PW
103 test_when_finished cleanup_git &&
104 (
105 cd "$git" &&
106 test_path_is_missing f4 &&
107 test_path_is_file sub/dir/f4
108 ) &&
109 cleanup_git &&
6ab1d76c 110 git p4 clone --dest="$git" //depot/sub/dir@all &&
ae3f41f2
PW
111 (
112 cd "$git" &&
113 test_path_is_file f4 &&
114 test_path_is_missing sub/dir/f4
115 )
116'
117
09fca77b
PW
118# clone --use-client-spec must still specify a depot path
119# if given, it should rearrange files according to client spec
120# when it has view lines that match the depot path
121# XXX: should clone/sync just use the client spec exactly, rather
122# than needing depot paths?
123test_expect_success 'clone --use-client-spec' '
124 (
125 # big usage message
126 exec >/dev/null &&
6ab1d76c 127 test_must_fail git p4 clone --dest="$git" --use-client-spec
09fca77b 128 ) &&
23bd0c99 129 cli2=$(test-path-utils real_path "$TRASH_DIRECTORY/cli2") &&
09fca77b
PW
130 mkdir -p "$cli2" &&
131 test_when_finished "rmdir \"$cli2\"" &&
132 (
133 cd "$cli2" &&
134 p4 client -i <<-EOF
135 Client: client2
136 Description: client2
137 Root: $cli2
138 View: //depot/sub/... //client2/bus/...
139 EOF
140 ) &&
141 P4CLIENT=client2 &&
142 test_when_finished cleanup_git &&
6ab1d76c 143 git p4 clone --dest="$git" --use-client-spec //depot/... &&
09fca77b
PW
144 (
145 cd "$git" &&
146 test_path_is_file bus/dir/f4 &&
2ea09b5a 147 test_path_is_missing file1
09fca77b
PW
148 ) &&
149 cleanup_git &&
150
151 # same thing again, this time with variable instead of option
09fca77b
PW
152 (
153 cd "$git" &&
154 git init &&
155 git config git-p4.useClientSpec true &&
6ab1d76c 156 git p4 sync //depot/... &&
09fca77b
PW
157 git checkout -b master p4/master &&
158 test_path_is_file bus/dir/f4 &&
2ea09b5a 159 test_path_is_missing file1
09fca77b
PW
160 )
161'
162
ef86890c
PW
163test_expect_success 'kill p4d' '
164 kill_p4d
165'
166
167test_done