Skip to content

Commit 09fca77

Browse files
Pete Wyckoffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ae3f41f commit 09fca77

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

Documentation/git-p4.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,10 @@ git repository:
232232
Use a client spec to find the list of interesting files in p4.
233233
The client spec is discovered using 'p4 client -o' which checks
234234
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.
236239

237240
Clone options
238241
~~~~~~~~~~~~~

contrib/fast-import/git-p4

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1951,7 +1951,10 @@ class P4Sync(Command, P4UserMap):
19511951
if not gitBranchExists(self.refPrefix + "HEAD") and self.importIntoRemotes and gitBranchExists(self.branch):
19521952
system("git symbolic-ref %sHEAD %s" % (self.refPrefix, self.branch))
19531953

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:
19551958
self.getClientSpec()
19561959

19571960
# TODO: should always look at previous commits,
@@ -2380,6 +2383,7 @@ def main():
23802383

23812384
if not cmd.run(args):
23822385
parser.print_help()
2386+
sys.exit(2)
23832387

23842388

23852389
if __name__ == '__main__':

t/t9806-git-p4-options.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,52 @@ test_expect_success 'clone --keep-path' '
117117
)
118118
'
119119

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+
120166
test_expect_success 'kill p4d' '
121167
kill_p4d
122168
'

0 commit comments

Comments
 (0)