]>
Commit | Line | Data |
---|---|---|
d7f6ea3d JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Junio C Hamano | |
4 | # | |
5 | ||
5be60078 | 6 | test_description='git checkout-index --prefix test. |
d7f6ea3d JH |
7 | |
8 | This test makes sure that --prefix option works as advertised, and | |
9 | also verifies that such leading path may contain symlinks, unlike | |
10 | the GIT controlled paths. | |
11 | ' | |
12 | ||
b7bcdbdb | 13 | TEST_PASSES_SANITIZE_LEAK=true |
d7f6ea3d JH |
14 | . ./test-lib.sh |
15 | ||
013c3bb8 JK |
16 | test_expect_success 'setup' ' |
17 | mkdir path1 && | |
18 | echo frotz >path0 && | |
19 | echo rezrov >path1/file1 && | |
20 | git update-index --add path0 path1/file1 | |
21 | ' | |
d7f6ea3d | 22 | |
013c3bb8 JK |
23 | test_expect_success SYMLINKS '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 | |
30 | ' | |
d7f6ea3d | 31 | |
013c3bb8 JK |
32 | test_expect_success '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 | |
40 | ' | |
d7f6ea3d | 41 | |
013c3bb8 JK |
42 | test_expect_success '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 | |
49 | ' | |
d7f6ea3d | 50 | |
013c3bb8 JK |
51 | test_expect_success '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 | |
60 | ' | |
d7f6ea3d | 61 | |
013c3bb8 JK |
62 | test_expect_success SYMLINKS 'use --prefix=tmp/orary/ where tmp is a symlink' ' |
63 | rm -fr path0 path1 path2 tmp* && | |
64 | mkdir tmp1 tmp1/orary && | |
65 | ln -s tmp1 tmp && | |
66 | git checkout-index --prefix=tmp/orary/ -f -a && | |
67 | test -d tmp1/orary && | |
68 | test -f tmp1/orary/path0 && | |
69 | test -f tmp1/orary/path1/file1 && | |
70 | test -h tmp | |
71 | ' | |
d7f6ea3d | 72 | |
013c3bb8 JK |
73 | test_expect_success SYMLINKS 'use --prefix=tmp/orary- where tmp is a symlink' ' |
74 | rm -fr path0 path1 path2 tmp* && | |
75 | mkdir tmp1 && | |
76 | ln -s tmp1 tmp && | |
77 | git checkout-index --prefix=tmp/orary- -f -a && | |
78 | test -f tmp1/orary-path0 && | |
79 | test -f tmp1/orary-path1/file1 && | |
80 | test -h tmp | |
81 | ' | |
d7f6ea3d | 82 | |
013c3bb8 JK |
83 | test_expect_success SYMLINKS 'use --prefix=tmp- where tmp-path1 is a symlink' ' |
84 | rm -fr path0 path1 path2 tmp* && | |
85 | mkdir tmp1 && | |
86 | ln -s tmp1 tmp-path1 && | |
87 | git checkout-index --prefix=tmp- -f -a && | |
88 | test -f tmp-path0 && | |
89 | test ! -h tmp-path1 && | |
90 | test -d tmp-path1 && | |
91 | test -f tmp-path1/file1 | |
92 | ' | |
d7f6ea3d | 93 | |
7297a440 JK |
94 | test_expect_success 'apply filter from working tree .gitattributes with --prefix' ' |
95 | rm -fr path0 path1 path2 tmp* && | |
96 | mkdir path1 && | |
97 | mkdir tmp && | |
8be412a7 | 98 | git config filter.replace-all.smudge "sed -e s/./,/g" && |
7297a440 JK |
99 | git config filter.replace-all.clean cat && |
100 | git config filter.replace-all.required true && | |
101 | echo "file1 filter=replace-all" >path1/.gitattributes && | |
102 | git checkout-index --prefix=tmp/ -f -a && | |
103 | echo frotz >expected && | |
104 | test_cmp expected tmp/path0 && | |
8be412a7 | 105 | echo ,,,,,, >expected && |
7297a440 JK |
106 | test_cmp expected tmp/path1/file1 |
107 | ' | |
108 | ||
109 | test_expect_success 'apply CRLF filter from working tree .gitattributes with --prefix' ' | |
110 | rm -fr path0 path1 path2 tmp* && | |
111 | mkdir path1 && | |
112 | mkdir tmp && | |
113 | echo "file1 eol=crlf" >path1/.gitattributes && | |
114 | git checkout-index --prefix=tmp/ -f -a && | |
115 | echo rezrovQ >expected && | |
116 | tr \\015 Q <tmp/path1/file1 >actual && | |
117 | test_cmp expected actual | |
118 | ' | |
119 | ||
da7bc9b0 | 120 | test_done |