Skip to content

Commit d604520

Browse files
Mazo, Andreygitster
authored andcommitted
git-p4: add failing test for "don't exclude other files with same prefix"
In preparation for a fix, add a failing test case to test that git-p4 doesn't exclude files with the same prefix unintentionally when exclude paths are specified without a trailing /. I.e., don't exclude "//depot/file_dont_exclude" if run with "-//depot/file". or don't exclude "//depot/discard_file_not" if run with "-//depot/discard_file". Signed-off-by: Andrey Mazo <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ff8c50e commit d604520

File tree

1 file changed

+46
-5
lines changed

1 file changed

+46
-5
lines changed

t/t9817-git-p4-exclude.sh

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ test_expect_success 'create exclude repo' '
2222
mkdir -p wanted discard &&
2323
echo wanted >wanted/foo &&
2424
echo discard >discard/foo &&
25-
p4 add wanted/foo discard/foo &&
25+
echo discard_file >discard_file &&
26+
echo discard_file_not >discard_file_not &&
27+
p4 add wanted/foo discard/foo discard_file discard_file_not &&
2628
p4 submit -d "initial revision"
2729
)
2830
'
@@ -33,7 +35,9 @@ test_expect_success 'check the repo was created correctly' '
3335
(
3436
cd "$git" &&
3537
test_path_is_file wanted/foo &&
36-
test_path_is_file discard/foo
38+
test_path_is_file discard/foo &&
39+
test_path_is_file discard_file &&
40+
test_path_is_file discard_file_not
3741
)
3842
'
3943

@@ -43,7 +47,21 @@ test_expect_success 'clone, excluding part of repo' '
4347
(
4448
cd "$git" &&
4549
test_path_is_file wanted/foo &&
46-
test_path_is_missing discard/foo
50+
test_path_is_missing discard/foo &&
51+
test_path_is_file discard_file &&
52+
test_path_is_file discard_file_not
53+
)
54+
'
55+
56+
test_expect_failure 'clone, excluding single file, no trailing /' '
57+
test_when_finished cleanup_git &&
58+
git p4 clone -//depot/discard_file --dest="$git" //depot/...@all &&
59+
(
60+
cd "$git" &&
61+
test_path_is_file wanted/foo &&
62+
test_path_is_file discard/foo &&
63+
test_path_is_missing discard_file &&
64+
test_path_is_file discard_file_not
4765
)
4866
'
4967

@@ -52,15 +70,38 @@ test_expect_success 'clone, then sync with exclude' '
5270
git p4 clone -//depot/discard/... --dest="$git" //depot/...@all &&
5371
(
5472
cd "$cli" &&
55-
p4 edit wanted/foo discard/foo &&
73+
p4 edit wanted/foo discard/foo discard_file_not &&
5674
date >>wanted/foo &&
5775
date >>discard/foo &&
76+
date >>discard_file_not &&
5877
p4 submit -d "updating" &&
5978
6079
cd "$git" &&
6180
git p4 sync -//depot/discard/... &&
6281
test_path_is_file wanted/foo &&
63-
test_path_is_missing discard/foo
82+
test_path_is_missing discard/foo &&
83+
test_path_is_file discard_file &&
84+
test_path_is_file discard_file_not
85+
)
86+
'
87+
88+
test_expect_failure 'clone, then sync with exclude, no trailing /' '
89+
test_when_finished cleanup_git &&
90+
git p4 clone -//depot/discard/... -//depot/discard_file --dest="$git" //depot/...@all &&
91+
(
92+
cd "$cli" &&
93+
p4 edit wanted/foo discard/foo discard_file_not &&
94+
date >>wanted/foo &&
95+
date >>discard/foo &&
96+
date >>discard_file_not &&
97+
p4 submit -d "updating" &&
98+
99+
cd "$git" &&
100+
git p4 sync -//depot/discard/... -//depot/discard_file &&
101+
test_path_is_file wanted/foo &&
102+
test_path_is_missing discard/foo &&
103+
test_path_is_missing discard_file &&
104+
test_path_is_file discard_file_not
64105
)
65106
'
66107

0 commit comments

Comments
 (0)