1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
56
test_description='git-checkout-cache --prefix test.
78
This test makes sure that --prefix option works as advertised, and
9also verifies that such leading path may contain symlinks, unlike
10the GIT controlled paths.
11'
1213
. ./test-lib.sh
1415
test_expect_success \
16'setup' \
17'mkdir path1 &&
18echo frotz >path0 &&
19echo rezrov >path1/file1 &&
20git-update-cache --add path0 path1/file1'
2122
test_expect_success \
23'have symlink in place where dir is expected.' \
24'rm -fr path0 path1 &&
25mkdir path2 &&
26ln -s path2 path1 &&
27git-checkout-cache -f -a &&
28test ! -h path1 && test -d path1 &&
29test -f path1/file1 && test ! -f path2/file1'
3031
test_expect_success \
32'use --prefix=path2/' \
33'rm -fr path0 path1 path2 &&
34mkdir path2 &&
35git-checkout-cache --prefix=path2/ -f -a &&
36test -f path2/path0 &&
37test -f path2/path1/file1 &&
38test ! -f path0 &&
39test ! -f path1/file1'
4041
test_expect_success \
42'use --prefix=tmp-' \
43'rm -fr path0 path1 path2 tmp* &&
44git-checkout-cache --prefix=tmp- -f -a &&
45test -f tmp-path0 &&
46test -f tmp-path1/file1 &&
47test ! -f path0 &&
48test ! -f path1/file1'
4950
test_expect_success \
51'use --prefix=tmp- but with a conflicting file and dir' \
52'rm -fr path0 path1 path2 tmp* &&
53echo nitfol >tmp-path1 &&
54mkdir tmp-path0 &&
55git-checkout-cache --prefix=tmp- -f -a &&
56test -f tmp-path0 &&
57test -f tmp-path1/file1 &&
58test ! -f path0 &&
59test ! -f path1/file1'
6061
# Linus fix #1
62test_expect_success \
63'use --prefix=tmp/orary/ where tmp is a symlink' \
64'rm -fr path0 path1 path2 tmp* &&
65mkdir tmp1 tmp1/orary &&
66ln -s tmp1 tmp &&
67git-checkout-cache --prefix=tmp/orary/ -f -a &&
68test -d tmp1/orary &&
69test -f tmp1/orary/path0 &&
70test -f tmp1/orary/path1/file1 &&
71test -h tmp'
7273
# Linus fix #2
74test_expect_success \
75'use --prefix=tmp/orary- where tmp is a symlink' \
76'rm -fr path0 path1 path2 tmp* &&
77mkdir tmp1 &&
78ln -s tmp1 tmp &&
79git-checkout-cache --prefix=tmp/orary- -f -a &&
80test -f tmp1/orary-path0 &&
81test -f tmp1/orary-path1/file1 &&
82test -h tmp'
8384
# Linus fix #3
85test_expect_success \
86'use --prefix=tmp- where tmp-path1 is a symlink' \
87'rm -fr path0 path1 path2 tmp* &&
88mkdir tmp1 &&
89ln -s tmp1 tmp-path1 &&
90git-checkout-cache --prefix=tmp- -f -a &&
91test -f tmp-path0 &&
92test ! -h tmp-path1 &&
93test -d tmp-path1 &&
94test -f tmp-path1/file1'
95