summaryrefslogtreecommitdiff
path: root/t/t2003-checkout-cache-mkdir.sh
blob: 02a4fc5d36a08d1046b9384c799f697640da0c4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/sh
#
# Copyright (c) 2005 Junio C Hamano
#

test_description='git checkout-index --prefix test.

This test makes sure that --prefix option works as advertised, and
also verifies that such leading path may contain symlinks, unlike
the GIT controlled paths.
'

. ./test-lib.sh

test_expect_success \
    'setup' \
    'mkdir path1 &&
    echo frotz >path0 &&
    echo rezrov >path1/file1 &&
    git update-index --add path0 path1/file1'

test_expect_success SYMLINKS \
    'have symlink in place where dir is expected.' \
    'rm -fr path0 path1 &&
     mkdir path2 &&
     ln -s path2 path1 &&
     git checkout-index -f -a &&
     test ! -h path1 && test -d path1 &&
     test -f path1/file1 && test ! -f path2/file1'

test_expect_success \
    'use --prefix=path2/' \
    'rm -fr path0 path1 path2 &&
     mkdir path2 &&
     git checkout-index --prefix=path2/ -f -a &&
     test -f path2/path0 &&
     test -f path2/path1/file1 &&
     test ! -f path0 &&
     test ! -f path1/file1'

test_expect_success \
    'use --prefix=tmp-' \
    'rm -fr path0 path1 path2 tmp* &&
     git checkout-index --prefix=tmp- -f -a &&
     test -f tmp-path0 &&
     test -f tmp-path1/file1 &&
     test ! -f path0 &&
     test ! -f path1/file1'

test_expect_success \
    'use --prefix=tmp- but with a conflicting file and dir' \
    'rm -fr path0 path1 path2 tmp* &&
     echo nitfol >tmp-path1 &&
     mkdir tmp-path0 &&
     git checkout-index --prefix=tmp- -f -a &&
     test -f tmp-path0 &&
     test -f tmp-path1/file1 &&
     test ! -f path0 &&
     test ! -f path1/file1'

# Linus fix #1
test_expect_success SYMLINKS \
    'use --prefix=tmp/orary/ where tmp is a symlink' \
    'rm -fr path0 path1 path2 tmp* &&
     mkdir tmp1 tmp1/orary &&
     ln -s tmp1 tmp &&
     git checkout-index --prefix=tmp/orary/ -f -a &&
     test -d tmp1/orary &&
     test -f tmp1/orary/path0 &&
     test -f tmp1/orary/path1/file1 &&
     test -h tmp'

# Linus fix #2
test_expect_success SYMLINKS \
    'use --prefix=tmp/orary- where tmp is a symlink' \
    'rm -fr path0 path1 path2 tmp* &&
     mkdir tmp1 &&
     ln -s tmp1 tmp &&
     git checkout-index --prefix=tmp/orary- -f -a &&
     test -f tmp1/orary-path0 &&
     test -f tmp1/orary-path1/file1 &&
     test -h tmp'

# Linus fix #3
test_expect_success SYMLINKS \
    'use --prefix=tmp- where tmp-path1 is a symlink' \
    'rm -fr path0 path1 path2 tmp* &&
     mkdir tmp1 &&
     ln -s tmp1 tmp-path1 &&
     git checkout-index --prefix=tmp- -f -a &&
     test -f tmp-path0 &&
     test ! -h tmp-path1 &&
     test -d tmp-path1 &&
     test -f tmp-path1/file1'

test_done