]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-p4: add failing test for "don't exclude other files with same prefix"
authorMazo, Andrey <amazo@checkvideo.com>
Mon, 1 Apr 2019 18:02:29 +0000 (18:02 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 2 Apr 2019 02:25:41 +0000 (11:25 +0900)
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 <amazo@checkvideo.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t9817-git-p4-exclude.sh

index aac568eadfcab6198877d211d3e706cead68e302..1c225707976d215426bdddffe76583d63a44e885 100755 (executable)
@@ -22,7 +22,9 @@ test_expect_success 'create exclude repo' '
                mkdir -p wanted discard &&
                echo wanted >wanted/foo &&
                echo discard >discard/foo &&
-               p4 add wanted/foo discard/foo &&
+               echo discard_file >discard_file &&
+               echo discard_file_not >discard_file_not &&
+               p4 add wanted/foo discard/foo discard_file discard_file_not &&
                p4 submit -d "initial revision"
        )
 '
@@ -33,7 +35,9 @@ test_expect_success 'check the repo was created correctly' '
        (
                cd "$git" &&
                test_path_is_file wanted/foo &&
-               test_path_is_file discard/foo
+               test_path_is_file discard/foo &&
+               test_path_is_file discard_file &&
+               test_path_is_file discard_file_not
        )
 '
 
@@ -43,7 +47,21 @@ test_expect_success 'clone, excluding part of repo' '
        (
                cd "$git" &&
                test_path_is_file wanted/foo &&
-               test_path_is_missing discard/foo
+               test_path_is_missing discard/foo &&
+               test_path_is_file discard_file &&
+               test_path_is_file discard_file_not
+       )
+'
+
+test_expect_failure 'clone, excluding single file, no trailing /' '
+       test_when_finished cleanup_git &&
+       git p4 clone -//depot/discard_file --dest="$git" //depot/...@all &&
+       (
+               cd "$git" &&
+               test_path_is_file wanted/foo &&
+               test_path_is_file discard/foo &&
+               test_path_is_missing discard_file &&
+               test_path_is_file discard_file_not
        )
 '
 
@@ -52,15 +70,38 @@ test_expect_success 'clone, then sync with exclude' '
        git p4 clone -//depot/discard/... --dest="$git" //depot/...@all &&
        (
                cd "$cli" &&
-               p4 edit wanted/foo discard/foo &&
+               p4 edit wanted/foo discard/foo discard_file_not &&
                date >>wanted/foo &&
                date >>discard/foo &&
+               date >>discard_file_not &&
                p4 submit -d "updating" &&
 
                cd "$git" &&
                git p4 sync -//depot/discard/... &&
                test_path_is_file wanted/foo &&
-               test_path_is_missing discard/foo
+               test_path_is_missing discard/foo &&
+               test_path_is_file discard_file &&
+               test_path_is_file discard_file_not
+       )
+'
+
+test_expect_failure 'clone, then sync with exclude, no trailing /' '
+       test_when_finished cleanup_git &&
+       git p4 clone -//depot/discard/... -//depot/discard_file --dest="$git" //depot/...@all &&
+       (
+               cd "$cli" &&
+               p4 edit wanted/foo discard/foo discard_file_not &&
+               date >>wanted/foo &&
+               date >>discard/foo &&
+               date >>discard_file_not &&
+               p4 submit -d "updating" &&
+
+               cd "$git" &&
+               git p4 sync -//depot/discard/... -//depot/discard_file &&
+               test_path_is_file wanted/foo &&
+               test_path_is_missing discard/foo &&
+               test_path_is_missing discard_file &&
+               test_path_is_file discard_file_not
        )
 '