@@ -12,85 +12,108 @@ the GIT controlled paths.
1212
1313. ./test-lib.sh
1414
15- test_expect_success \
16- ' setup' \
17- ' mkdir path1 &&
18- echo frotz >path0 &&
19- echo rezrov >path1/file1 &&
20- git update-index --add path0 path1/file1'
15+ test_expect_success ' setup' '
16+ mkdir path1 &&
17+ echo frotz >path0 &&
18+ echo rezrov >path1/file1 &&
19+ git update-index --add path0 path1/file1
20+ '
21+
22+ test_expect_success SYMLINKS ' have symlink in place where dir is expected.' '
23+ rm -fr path0 path1 &&
24+ mkdir path2 &&
25+ ln -s path2 path1 &&
26+ git checkout-index -f -a &&
27+ test ! -h path1 && test -d path1 &&
28+ test -f path1/file1 && test ! -f path2/file1
29+ '
2130
22- test_expect_success SYMLINKS \
23- ' have symlink in place where dir is expected.' \
24- ' rm -fr path0 path1 &&
25- mkdir path2 &&
26- ln -s path2 path1 &&
27- git checkout-index -f -a &&
28- test ! -h path1 && test -d path1 &&
29- test -f path1/file1 && test ! -f path2/file1'
31+ test_expect_success ' use --prefix=path2/' '
32+ rm -fr path0 path1 path2 &&
33+ mkdir path2 &&
34+ git checkout-index --prefix=path2/ -f -a &&
35+ test -f path2/path0 &&
36+ test -f path2/path1/file1 &&
37+ test ! -f path0 &&
38+ test ! -f path1/file1
39+ '
40+
41+ test_expect_success ' use --prefix=tmp-' '
42+ rm -fr path0 path1 path2 tmp* &&
43+ git checkout-index --prefix=tmp- -f -a &&
44+ test -f tmp-path0 &&
45+ test -f tmp-path1/file1 &&
46+ test ! -f path0 &&
47+ test ! -f path1/file1
48+ '
3049
31- test_expect_success \
32- ' use --prefix=path2/' \
33- ' rm -fr path0 path1 path2 &&
34- mkdir path2 &&
35- git checkout-index --prefix=path2/ -f -a &&
36- test -f path2/path0 &&
37- test -f path2/path1/file1 &&
38- test ! -f path0 &&
39- test ! -f path1/file1'
50+ test_expect_success ' use --prefix=tmp- but with a conflicting file and dir' '
51+ rm -fr path0 path1 path2 tmp* &&
52+ echo nitfol >tmp-path1 &&
53+ mkdir tmp-path0 &&
54+ git checkout-index --prefix=tmp- -f -a &&
55+ test -f tmp-path0 &&
56+ test -f tmp-path1/file1 &&
57+ test ! -f path0 &&
58+ test ! -f path1/file1
59+ '
4060
41- test_expect_success \
42- ' use --prefix=tmp-' \
43- ' rm -fr path0 path1 path2 tmp* &&
44- git checkout-index --prefix=tmp- -f -a &&
45- test -f tmp-path0 &&
46- test -f tmp-path1/file1 &&
47- test ! -f path0 &&
48- test ! -f path1/file1'
61+ test_expect_success SYMLINKS ' use --prefix=tmp/orary/ where tmp is a symlink' '
62+ rm -fr path0 path1 path2 tmp* &&
63+ mkdir tmp1 tmp1/orary &&
64+ ln -s tmp1 tmp &&
65+ git checkout-index --prefix=tmp/orary/ -f -a &&
66+ test -d tmp1/orary &&
67+ test -f tmp1/orary/path0 &&
68+ test -f tmp1/orary/path1/file1 &&
69+ test -h tmp
70+ '
4971
50- test_expect_success \
51- ' use --prefix=tmp- but with a conflicting file and dir' \
52- ' rm -fr path0 path1 path2 tmp* &&
53- echo nitfol >tmp-path1 &&
54- mkdir tmp-path0 &&
55- git checkout-index --prefix=tmp- -f -a &&
56- test -f tmp-path0 &&
57- test -f tmp-path1/file1 &&
58- test ! -f path0 &&
59- test ! -f path1/file1'
72+ test_expect_success SYMLINKS ' use --prefix=tmp/orary- where tmp is a symlink' '
73+ rm -fr path0 path1 path2 tmp* &&
74+ mkdir tmp1 &&
75+ ln -s tmp1 tmp &&
76+ git checkout-index --prefix=tmp/orary- -f -a &&
77+ test -f tmp1/orary-path0 &&
78+ test -f tmp1/orary-path1/file1 &&
79+ test -h tmp
80+ '
6081
61- # Linus fix #1
62- test_expect_success SYMLINKS \
63- ' use --prefix=tmp/orary/ where tmp is a symlink' \
64- ' rm -fr path0 path1 path2 tmp* &&
65- mkdir tmp1 tmp1/orary &&
66- ln -s tmp1 tmp &&
67- git checkout-index --prefix=tmp/orary/ -f -a &&
68- test -d tmp1/orary &&
69- test -f tmp1/orary/path0 &&
70- test -f tmp1/orary/path1/file1 &&
71- test -h tmp'
82+ test_expect_success SYMLINKS ' use --prefix=tmp- where tmp-path1 is a symlink' '
83+ rm -fr path0 path1 path2 tmp* &&
84+ mkdir tmp1 &&
85+ ln -s tmp1 tmp-path1 &&
86+ git checkout-index --prefix=tmp- -f -a &&
87+ test -f tmp-path0 &&
88+ test ! -h tmp-path1 &&
89+ test -d tmp-path1 &&
90+ test -f tmp-path1/file1
91+ '
7292
73- # Linus fix #2
74- test_expect_success SYMLINKS \
75- ' use --prefix=tmp/orary- where tmp is a symlink' \
76- ' rm -fr path0 path1 path2 tmp* &&
77- mkdir tmp1 &&
78- ln -s tmp1 tmp &&
79- git checkout-index --prefix=tmp/orary- -f -a &&
80- test -f tmp1/orary-path0 &&
81- test -f tmp1/orary-path1/file1 &&
82- test -h tmp'
93+ test_expect_success ' apply filter from working tree .gitattributes with --prefix' '
94+ rm -fr path0 path1 path2 tmp* &&
95+ mkdir path1 &&
96+ mkdir tmp &&
97+ git config filter.replace-all.smudge "sed -e s/./,/g" &&
98+ git config filter.replace-all.clean cat &&
99+ git config filter.replace-all.required true &&
100+ echo "file1 filter=replace-all" >path1/.gitattributes &&
101+ git checkout-index --prefix=tmp/ -f -a &&
102+ echo frotz >expected &&
103+ test_cmp expected tmp/path0 &&
104+ echo ,,,,,, >expected &&
105+ test_cmp expected tmp/path1/file1
106+ '
83107
84- # Linus fix #3
85- test_expect_success SYMLINKS \
86- ' use --prefix=tmp- where tmp-path1 is a symlink' \
87- ' rm -fr path0 path1 path2 tmp* &&
88- mkdir tmp1 &&
89- ln -s tmp1 tmp-path1 &&
90- git checkout-index --prefix=tmp- -f -a &&
91- test -f tmp-path0 &&
92- test ! -h tmp-path1 &&
93- test -d tmp-path1 &&
94- test -f tmp-path1/file1'
108+ test_expect_success ' apply CRLF filter from working tree .gitattributes with --prefix' '
109+ rm -fr path0 path1 path2 tmp* &&
110+ mkdir path1 &&
111+ mkdir tmp &&
112+ echo "file1 eol=crlf" >path1/.gitattributes &&
113+ git checkout-index --prefix=tmp/ -f -a &&
114+ echo rezrovQ >expected &&
115+ tr \\015 Q <tmp/path1/file1 >actual &&
116+ test_cmp expected actual
117+ '
95118
96119test_done
0 commit comments