Skip to content

Commit da191d1

Browse files
Pete Wyckoffgitster
authored andcommitted
git-p4: test cloning with two dirs, clarify doc
Document how git-p4 currently works when specifying multiple depot paths: 1. No branches or directories are named. 2. Conflicting files are silently ignored---the last change wins. 2. Option --destination is required, else the last path is construed to be a directory. 3. Revision specifiers must be the same on all paths for them to take effect. Test this behavior. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent ef86890 commit da191d1

File tree

2 files changed

+69
-2
lines changed

2 files changed

+69
-2
lines changed

Documentation/git-p4.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,15 @@ p4 revision specifier on the end:
276276
"//depot/my/project@1,6"::
277277
Import only changes 1 through 6.
278278

279-
"//depot/proj1 //depot/proj2@all"::
280-
Import all changes from both named depot paths.
279+
"//depot/proj1@all //depot/proj2@all"::
280+
Import all changes from both named depot paths into a single
281+
repository. Only files below these directories are included.
282+
There is not a subdirectory in git for each "proj1" and "proj2".
283+
You must use the '--destination' option when specifying more
284+
than one depot path. The revision specifier must be specified
285+
identically on each depot path. If there are files in the
286+
depot paths with the same name, the path with the most recently
287+
updated version of the file is the one that appears in git.
281288

282289
See 'p4 help revisions' for the full syntax of p4 revision specifiers.
283290

t/t9800-git-p4-basic.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,66 @@ test_expect_success 'git-p4 sync new branch' '
6565
)
6666
'
6767

68+
test_expect_success 'clone two dirs' '
69+
(
70+
cd "$cli" &&
71+
mkdir sub1 sub2 &&
72+
echo sub1/f1 >sub1/f1 &&
73+
echo sub2/f2 >sub2/f2 &&
74+
p4 add sub1/f1 &&
75+
p4 submit -d "sub1/f1" &&
76+
p4 add sub2/f2 &&
77+
p4 submit -d "sub2/f2"
78+
) &&
79+
"$GITP4" clone --dest="$git" //depot/sub1 //depot/sub2 &&
80+
test_when_finished cleanup_git &&
81+
(
82+
cd "$git" &&
83+
git ls-files >lines &&
84+
test_line_count = 2 lines &&
85+
git log --oneline p4/master >lines &&
86+
test_line_count = 1 lines
87+
)
88+
'
89+
90+
test_expect_success 'clone two dirs, @all' '
91+
(
92+
cd "$cli" &&
93+
echo sub1/f3 >sub1/f3 &&
94+
p4 add sub1/f3 &&
95+
p4 submit -d "sub1/f3"
96+
) &&
97+
"$GITP4" clone --dest="$git" //depot/sub1@all //depot/sub2@all &&
98+
test_when_finished cleanup_git &&
99+
(
100+
cd "$git" &&
101+
git ls-files >lines &&
102+
test_line_count = 3 lines &&
103+
git log --oneline p4/master >lines &&
104+
test_line_count = 3 lines
105+
)
106+
'
107+
108+
test_expect_success 'clone two dirs, @all, conflicting files' '
109+
(
110+
cd "$cli" &&
111+
echo sub2/f3 >sub2/f3 &&
112+
p4 add sub2/f3 &&
113+
p4 submit -d "sub2/f3"
114+
) &&
115+
"$GITP4" clone --dest="$git" //depot/sub1@all //depot/sub2@all &&
116+
test_when_finished cleanup_git &&
117+
(
118+
cd "$git" &&
119+
git ls-files >lines &&
120+
test_line_count = 3 lines &&
121+
git log --oneline p4/master >lines &&
122+
test_line_count = 4 lines &&
123+
echo sub2/f3 >expected &&
124+
test_cmp expected f3
125+
)
126+
'
127+
68128
test_expect_success 'exit when p4 fails to produce marshaled output' '
69129
badp4dir="$TRASH_DIRECTORY/badp4dir" &&
70130
mkdir "$badp4dir" &&

0 commit comments

Comments
 (0)