]> git.ipfire.org Git - thirdparty/git.git/blob - t/t3100-ls-tree-restrict.sh
l10n: it.po: update the Italian translation for Git 2.24.0 round #2
[thirdparty/git.git] / t / t3100-ls-tree-restrict.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2005 Junio C Hamano
4 #
5
6 test_description='git ls-tree test.
7
8 This test runs git ls-tree with the following in a tree.
9
10 path0 - a file
11 path1 - a symlink
12 path2/foo - a file in a directory
13 path2/bazbo - a symlink in a directory
14 path2/baz/b - a file in a directory in a directory
15
16 The new path restriction code should do the right thing for path2 and
17 path2/baz. Also path0/ should snow nothing.
18 '
19 . ./test-lib.sh
20
21 test_expect_success \
22 'setup' \
23 'mkdir path2 path2/baz &&
24 echo Hi >path0 &&
25 test_ln_s_add path0 path1 &&
26 test_ln_s_add ../path1 path2/bazbo &&
27 echo Lo >path2/foo &&
28 echo Mi >path2/baz/b &&
29 find path? \( -type f -o -type l \) -print |
30 xargs git update-index --add &&
31 tree=$(git write-tree) &&
32 echo $tree'
33
34 test_output () {
35 sed -e "s/ $OID_REGEX / X /" <current >check
36 test_cmp expected check
37 }
38
39 test_expect_success \
40 'ls-tree plain' \
41 'git ls-tree $tree >current &&
42 cat >expected <<\EOF &&
43 100644 blob X path0
44 120000 blob X path1
45 040000 tree X path2
46 EOF
47 test_output'
48
49 test_expect_success \
50 'ls-tree recursive' \
51 'git ls-tree -r $tree >current &&
52 cat >expected <<\EOF &&
53 100644 blob X path0
54 120000 blob X path1
55 100644 blob X path2/baz/b
56 120000 blob X path2/bazbo
57 100644 blob X path2/foo
58 EOF
59 test_output'
60
61 test_expect_success \
62 'ls-tree recursive with -t' \
63 'git ls-tree -r -t $tree >current &&
64 cat >expected <<\EOF &&
65 100644 blob X path0
66 120000 blob X path1
67 040000 tree X path2
68 040000 tree X path2/baz
69 100644 blob X path2/baz/b
70 120000 blob X path2/bazbo
71 100644 blob X path2/foo
72 EOF
73 test_output'
74
75 test_expect_success \
76 'ls-tree recursive with -d' \
77 'git ls-tree -r -d $tree >current &&
78 cat >expected <<\EOF &&
79 040000 tree X path2
80 040000 tree X path2/baz
81 EOF
82 test_output'
83
84 test_expect_success \
85 'ls-tree filtered with path' \
86 'git ls-tree $tree path >current &&
87 cat >expected <<\EOF &&
88 EOF
89 test_output'
90
91
92 # it used to be path1 and then path0, but with pathspec semantics
93 # they are shown in canonical order.
94 test_expect_success \
95 'ls-tree filtered with path1 path0' \
96 'git ls-tree $tree path1 path0 >current &&
97 cat >expected <<\EOF &&
98 100644 blob X path0
99 120000 blob X path1
100 EOF
101 test_output'
102
103 test_expect_success \
104 'ls-tree filtered with path0/' \
105 'git ls-tree $tree path0/ >current &&
106 cat >expected <<\EOF &&
107 EOF
108 test_output'
109
110 # It used to show path2 and its immediate children but
111 # with pathspec semantics it shows only path2
112 test_expect_success \
113 'ls-tree filtered with path2' \
114 'git ls-tree $tree path2 >current &&
115 cat >expected <<\EOF &&
116 040000 tree X path2
117 EOF
118 test_output'
119
120 # ... and path2/ shows the children.
121 test_expect_success \
122 'ls-tree filtered with path2/' \
123 'git ls-tree $tree path2/ >current &&
124 cat >expected <<\EOF &&
125 040000 tree X path2/baz
126 120000 blob X path2/bazbo
127 100644 blob X path2/foo
128 EOF
129 test_output'
130
131 # The same change -- exact match does not show children of
132 # path2/baz
133 test_expect_success \
134 'ls-tree filtered with path2/baz' \
135 'git ls-tree $tree path2/baz >current &&
136 cat >expected <<\EOF &&
137 040000 tree X path2/baz
138 EOF
139 test_output'
140
141 test_expect_success \
142 'ls-tree filtered with path2/bak' \
143 'git ls-tree $tree path2/bak >current &&
144 cat >expected <<\EOF &&
145 EOF
146 test_output'
147
148 test_expect_success \
149 'ls-tree -t filtered with path2/bak' \
150 'git ls-tree -t $tree path2/bak >current &&
151 cat >expected <<\EOF &&
152 040000 tree X path2
153 EOF
154 test_output'
155
156 test_expect_success \
157 'ls-tree with one path a prefix of the other' \
158 'git ls-tree $tree path2/baz path2/bazbo >current &&
159 cat >expected <<\EOF &&
160 040000 tree X path2/baz
161 120000 blob X path2/bazbo
162 EOF
163 test_output'
164
165 test_done