]>
Commit | Line | Data |
---|---|---|
d7f6ea3d JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Junio C Hamano | |
4 | # | |
5 | ||
215a7ad1 | 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 | ||
13 | . ./test-lib.sh | |
14 | ||
15 | test_expect_success \ | |
16 | 'setup' \ | |
17 | 'mkdir path1 && | |
18 | echo frotz >path0 && | |
19 | echo rezrov >path1/file1 && | |
215a7ad1 | 20 | git-update-index --add path0 path1/file1' |
d7f6ea3d JH |
21 | |
22 | test_expect_success \ | |
23 | 'have symlink in place where dir is expected.' \ | |
24 | 'rm -fr path0 path1 && | |
25 | mkdir path2 && | |
26 | ln -s path2 path1 && | |
215a7ad1 | 27 | git-checkout-index -f -a && |
d7f6ea3d JH |
28 | test ! -h path1 && test -d path1 && |
29 | test -f path1/file1 && test ! -f path2/file1' | |
30 | ||
31 | test_expect_success \ | |
32 | 'use --prefix=path2/' \ | |
33 | 'rm -fr path0 path1 path2 && | |
34 | mkdir path2 && | |
215a7ad1 | 35 | git-checkout-index --prefix=path2/ -f -a && |
d7f6ea3d JH |
36 | test -f path2/path0 && |
37 | test -f path2/path1/file1 && | |
38 | test ! -f path0 && | |
39 | test ! -f path1/file1' | |
40 | ||
41 | test_expect_success \ | |
42 | 'use --prefix=tmp-' \ | |
43 | 'rm -fr path0 path1 path2 tmp* && | |
215a7ad1 | 44 | git-checkout-index --prefix=tmp- -f -a && |
d7f6ea3d JH |
45 | test -f tmp-path0 && |
46 | test -f tmp-path1/file1 && | |
47 | test ! -f path0 && | |
48 | test ! -f path1/file1' | |
49 | ||
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 && | |
215a7ad1 | 55 | git-checkout-index --prefix=tmp- -f -a && |
d7f6ea3d JH |
56 | test -f tmp-path0 && |
57 | test -f tmp-path1/file1 && | |
58 | test ! -f path0 && | |
59 | test ! -f path1/file1' | |
60 | ||
61 | # Linus fix #1 | |
62 | test_expect_success \ | |
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 && | |
215a7ad1 | 67 | git-checkout-index --prefix=tmp/orary/ -f -a && |
d7f6ea3d JH |
68 | test -d tmp1/orary && |
69 | test -f tmp1/orary/path0 && | |
70 | test -f tmp1/orary/path1/file1 && | |
71 | test -h tmp' | |
72 | ||
73 | # Linus fix #2 | |
74 | test_expect_success \ | |
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 && | |
215a7ad1 | 79 | git-checkout-index --prefix=tmp/orary- -f -a && |
d7f6ea3d JH |
80 | test -f tmp1/orary-path0 && |
81 | test -f tmp1/orary-path1/file1 && | |
82 | test -h tmp' | |
83 | ||
84 | # Linus fix #3 | |
85 | test_expect_success \ | |
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 && | |
215a7ad1 | 90 | git-checkout-index --prefix=tmp- -f -a && |
d7f6ea3d JH |
91 | test -f tmp-path0 && |
92 | test ! -h tmp-path1 && | |
93 | test -d tmp-path1 && | |
94 | test -f tmp-path1/file1' | |
95 | ||
da7bc9b0 | 96 | test_done |