|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +test_description='checkout symlinks with `symlink` attribute on Windows |
| 4 | +
|
| 5 | +Ensures that Git for Windows creates symlinks of the right type, |
| 6 | +as specified by the `symlink` attribute in `.gitattributes`.' |
| 7 | + |
| 8 | +# Tell MSYS to create native symlinks. Without this flag test-lib's |
| 9 | +# prerequisite detection for SYMLINKS doesn't detect the right thing. |
| 10 | +MSYS=winsymlinks:nativestrict && export MSYS |
| 11 | + |
| 12 | +. ./test-lib.sh |
| 13 | + |
| 14 | +if ! test_have_prereq MINGW,SYMLINKS |
| 15 | +then |
| 16 | + skip_all='skipping $0: MinGW-only test, which requires symlink support.' |
| 17 | + test_done |
| 18 | +fi |
| 19 | + |
| 20 | +# Adds a symlink to the index without clobbering the work tree. |
| 21 | +cache_symlink () { |
| 22 | + sha=$(printf '%s' "$1" | git hash-object --stdin -w) && |
| 23 | + git update-index --add --cacheinfo 120000,$sha,"$2" |
| 24 | +} |
| 25 | + |
| 26 | +test_expect_success 'checkout symlinks with attr' ' |
| 27 | + cache_symlink file1 file-link && |
| 28 | + cache_symlink dir dir-link && |
| 29 | +
|
| 30 | + printf "file-link symlink=file\ndir-link symlink=dir\n" >.gitattributes && |
| 31 | + git add .gitattributes && |
| 32 | +
|
| 33 | + git checkout . && |
| 34 | +
|
| 35 | + mkdir dir && |
| 36 | + echo "[a]b=c" >file1 && |
| 37 | + echo "[x]y=z" >dir/file2 && |
| 38 | +
|
| 39 | + # MSYS2 is very forgiving, it will resolve symlinks even if the |
| 40 | + # symlink type is incorrect. To make this test meaningful, try |
| 41 | + # them with a native, non-MSYS executable, such as `git config`. |
| 42 | + test "$(git config -f file-link a.b)" = "c" && |
| 43 | + test "$(git config -f dir-link/file2 x.y)" = "z" |
| 44 | +' |
| 45 | + |
| 46 | +test_done |
0 commit comments