git-p4: test and document --use-client-spec
The depot path is required, even with this option. Make sure git-p4 fails and exits with non-zero. Contents in the specified depot path will be rearranged according to the client spec. Test this and add a note in the docs. Leave an XXX suggesting that this is somewhat confusing behavior that might be good to fix later. Function stripRepoPath() looks at self.useClientSpec. Make sure this is set both for command-line option --use-client-spec and for configuration variable git-p4.useClientSpec. Test this. 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
09fca77b9ecd64e2008835208bab29e15a4b2809
3 files changed
+55
-2
Documentation/git-p4.txt
+4
-1
@@ -232,7 +232,10 @@ git repository:
232
Use a client spec to find the list of interesting files in p4.
233
The client spec is discovered using 'p4 client -o' which checks
234
the 'P4CLIENT' environment variable and returns a mapping of
235
- depot files to workspace files.
235
+ depot files to workspace files. Note that a depot path is
236
+ still required, but files found in the path that match in
237
+ the client spec view will be laid out according to the client
238
+ spec.
239
240
Clone options
241
~~~~~~~~~~~~~
contrib/fast-import/git-p4
+5
-1
@@ -1951,7 +1951,10 @@ class P4Sync(Command, P4UserMap):
1951
if not gitBranchExists(self.refPrefix + "HEAD") and self.importIntoRemotes and gitBranchExists(self.branch):
1952
system("git symbolic-ref %sHEAD %s" % (self.refPrefix, self.branch))
1953
1954
- if self.useClientSpec or gitConfig("git-p4.useclientspec") == "true":
1954
+ if not self.useClientSpec:
1955
+ if gitConfig("git-p4.useclientspec", "--bool") == "true":
1956
+ self.useClientSpec = True
1957
+ if self.useClientSpec:
1958
self.getClientSpec()
1959
1960
# TODO: should always look at previous commits,
@@ -2380,6 +2383,7 @@ def main():
2383
2384
if not cmd.run(args):
2385
parser.print_help()
2386
+ sys.exit(2)
2387
2388
2389
if __name__ == '__main__':
t/t9806-git-p4-options.sh
+46
@@ -117,6 +117,52 @@ test_expect_success 'clone --keep-path' '
117
)
118
'
119
120
+# clone --use-client-spec must still specify a depot path
121
+# if given, it should rearrange files according to client spec
122
+# when it has view lines that match the depot path
123
+# XXX: should clone/sync just use the client spec exactly, rather
124
+# than needing depot paths?
125
+test_expect_success 'clone --use-client-spec' '
126
+ (
127
+ # big usage message
128
+ exec >/dev/null &&
129
+ test_must_fail "$GITP4" clone --dest="$git" --use-client-spec
130
+ ) &&
131
+ cli2="$TRASH_DIRECTORY/cli2" &&
132
+ mkdir -p "$cli2" &&
133
+ test_when_finished "rmdir \"$cli2\"" &&
134
+ (
135
+ cd "$cli2" &&
136
+ p4 client -i <<-EOF
137
+ Client: client2
138
+ Description: client2
139
+ Root: $cli2
140
+ View: //depot/sub/... //client2/bus/...
141
+ EOF
142
+ ) &&
143
+ P4CLIENT=client2 &&
144
+ test_when_finished cleanup_git &&
145
+ "$GITP4" clone --dest="$git" --use-client-spec //depot/... &&
146
+ (
147
+ cd "$git" &&
148
+ test_path_is_file bus/dir/f4 &&
149
+ test_path_is_file file1
150
+ ) &&
151
+ cleanup_git &&
152
+
153
+ # same thing again, this time with variable instead of option
154
+ mkdir "$git" &&
155
+ (
156
+ cd "$git" &&
157
+ git init &&
158
+ git config git-p4.useClientSpec true &&
159
+ "$GITP4" sync //depot/... &&
160
+ git checkout -b master p4/master &&
161
+ test_path_is_file bus/dir/f4 &&
162
+ test_path_is_file file1
163
+ )
164
+'
165
+
166
test_expect_success 'kill p4d' '
167
kill_p4d
168
'