interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t2003-checkout-cache-mkdir.sh

119 lines · 3419 bytes Raw Blame History
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6test_description='git checkout-index --prefix test.
7
8This 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'
12
13. ./test-lib.sh
14
15test_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
22test_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_path_is_dir_not_symlink path1 &&
28 test_path_is_file path1/file1 &&
29 test_path_is_missing path2/file1
30'
31
32test_expect_success 'use --prefix=path2/' '
33 rm -fr path0 path1 path2 &&
34 mkdir path2 &&
35 git checkout-index --prefix=path2/ -f -a &&
36 test_path_is_file path2/path0 &&
37 test_path_is_file path2/path1/file1 &&
38 test_path_is_missing path0 &&
39 test_path_is_missing path1/file1
40'
41
42test_expect_success 'use --prefix=tmp-' '
43 rm -fr path0 path1 path2 tmp* &&
44 git checkout-index --prefix=tmp- -f -a &&
45 test_path_is_file tmp-path0 &&
46 test_path_is_file tmp-path1/file1 &&
47 test_path_is_missing path0 &&
48 test_path_is_missing path1/file1
49'
50
51test_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_path_is_file tmp-path0 &&
57 test_path_is_file tmp-path1/file1 &&
58 test_path_is_missing path0 &&
59 test_path_is_missing path1/file1
60'
61
62test_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_path_is_dir tmp1/orary &&
68 test_path_is_file tmp1/orary/path0 &&
69 test_path_is_file tmp1/orary/path1/file1 &&
70 test_path_is_symlink tmp
71'
72
73test_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_path_is_file tmp1/orary-path0 &&
79 test_path_is_file tmp1/orary-path1/file1 &&
80 test_path_is_symlink tmp
81'
82
83test_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_path_is_file tmp-path0 &&
89 test_path_is_dir_not_symlink tmp-path1 &&
90 test_path_is_file tmp-path1/file1
91'
92
93test_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'
107
108test_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'
118
119test_done