Skip to content

Commit 012c8b3

Browse files
committed
t4126: make sure a directory with SP at the end is usable
As afb31ad (t1010: fix unnoticed failure on Windows, 2021-12-11) said: On Microsoft Windows, a directory name should never end with a period. Quoting from Microsoft documentation[1]: Do not end a file or directory name with a space or a period. Although the underlying file system may support such names, the Windows shell and user interface does not. [1]: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file and the condition addressed by this change is exactly that. If the platform is unable to properly create these sample patches about a file that lives in a directory whose name ends with a SP, there is no point testing how "git apply" behaves there on the filesystem. Even though the ultimate purpose of "git apply" is to apply a patch and to update the filesystem entities, this particular test is mainly about parsing a patch on a funny pathname correctly, and even on a system that is incapable of checking out the resulting state correctly on its filesystem, at least the parsing can and should work fine. Rewrite the test to work inside the index without touching the filesystem. Helped-by: Jeff King <[email protected]> Helped-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5ea0176 commit 012c8b3

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

t/t4126-apply-empty.sh

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,29 @@ test_expect_success 'apply --index create' '
6666
git diff --exit-code
6767
'
6868

69-
test_expect_success 'apply with no-contents and a funny pathname' '
70-
mkdir "funny " &&
71-
>"funny /empty" &&
72-
git add "funny /empty" &&
73-
git diff HEAD "funny /" >sample.patch &&
74-
git diff -R HEAD "funny /" >elpmas.patch &&
69+
test_expect_success 'parsing a patch with no-contents and a funny pathname' '
7570
git reset --hard &&
76-
rm -fr "funny " &&
71+
empty_blob=$(test_oid empty_blob) &&
72+
echo "$empty_blob" >expect &&
7773
78-
git apply --stat --check --apply sample.patch &&
79-
test_must_be_empty "funny /empty" &&
74+
git update-index --add --cacheinfo "100644,$empty_blob,funny /empty" &&
75+
git diff --cached HEAD -- "funny /" >sample.patch &&
76+
git diff --cached -R HEAD -- "funny /" >elpmas.patch &&
77+
git reset &&
8078
81-
git apply --stat --check --apply elpmas.patch &&
82-
test_path_is_missing "funny /empty" &&
79+
git apply --cached --stat --check --apply sample.patch &&
80+
git rev-parse --verify ":funny /empty" >actual &&
81+
test_cmp expect actual &&
8382
84-
git apply -R --stat --check --apply elpmas.patch &&
85-
test_must_be_empty "funny /empty" &&
83+
git apply --cached --stat --check --apply elpmas.patch &&
84+
test_must_fail git rev-parse --verify ":funny /empty" &&
8685
87-
git apply -R --stat --check --apply sample.patch &&
88-
test_path_is_missing "funny /empty"
86+
git apply -R --cached --stat --check --apply elpmas.patch &&
87+
git rev-parse --verify ":funny /empty" >actual &&
88+
test_cmp expect actual &&
89+
90+
git apply -R --cached --stat --check --apply sample.patch &&
91+
test_must_fail git rev-parse --verify ":funny /empty"
8992
'
9093

9194
test_done

0 commit comments

Comments
 (0)