]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3100-ls-tree-restrict.sh
Big tool rename.
[thirdparty/git.git] / t / t3100-ls-tree-restrict.sh
CommitLineData
6d3a5077
JM
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6test_description='git-ls-tree test.
7
8This 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
16The new path restriction code should do the right thing for path2 and
66204988 17path2/baz. Also path0/ should snow nothing.
6d3a5077
JM
18'
19. ./test-lib.sh
20
21test_expect_success \
22 'setup' \
23 'mkdir path2 path2/baz &&
24 echo Hi >path0 &&
25 ln -s path0 path1 &&
26 echo Lo >path2/foo &&
27 ln -s ../path1 path2/bazbo &&
28 echo Mi >path2/baz/b &&
29 find path? \( -type f -o -type l \) -print |
215a7ad1 30 xargs git-update-index --add &&
6d3a5077
JM
31 tree=`git-write-tree` &&
32 echo $tree'
33
34_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
35_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
36test_output () {
2eab945e 37 sed -e "s/ $_x40 / X /" <current >check
6d3a5077
JM
38 diff -u expected check
39}
40
41test_expect_success \
42 'ls-tree plain' \
43 'git-ls-tree $tree >current &&
44 cat >expected <<\EOF &&
2eab945e
JH
45100644 blob X path0
46120000 blob X path1
47040000 tree X path2
6d3a5077
JM
48EOF
49 test_output'
50
51test_expect_success \
52 'ls-tree recursive' \
53 'git-ls-tree -r $tree >current &&
54 cat >expected <<\EOF &&
2eab945e
JH
55100644 blob X path0
56120000 blob X path1
57040000 tree X path2
58040000 tree X path2/baz
59100644 blob X path2/baz/b
60120000 blob X path2/bazbo
61100644 blob X path2/foo
6d3a5077
JM
62EOF
63 test_output'
64
65test_expect_success \
66204988 66 'ls-tree filtered with path' \
6d3a5077
JM
67 'git-ls-tree $tree path >current &&
68 cat >expected <<\EOF &&
69EOF
70 test_output'
71
72
73test_expect_success \
66204988 74 'ls-tree filtered with path1 path0' \
6d3a5077
JM
75 'git-ls-tree $tree path1 path0 >current &&
76 cat >expected <<\EOF &&
2eab945e 77120000 blob X path1
6af1f019 78100644 blob X path0
6d3a5077
JM
79EOF
80 test_output'
81
82test_expect_success \
66204988
JH
83 'ls-tree filtered with path0/' \
84 'git-ls-tree $tree path0/ >current &&
85 cat >expected <<\EOF &&
86EOF
87 test_output'
88
89test_expect_success \
90 'ls-tree filtered with path2' \
6d3a5077
JM
91 'git-ls-tree $tree path2 >current &&
92 cat >expected <<\EOF &&
2eab945e
JH
93040000 tree X path2
94040000 tree X path2/baz
2eab945e
JH
95120000 blob X path2/bazbo
96100644 blob X path2/foo
6d3a5077
JM
97EOF
98 test_output'
99
100test_expect_success \
66204988 101 'ls-tree filtered with path2/baz' \
6d3a5077
JM
102 'git-ls-tree $tree path2/baz >current &&
103 cat >expected <<\EOF &&
2eab945e
JH
104040000 tree X path2/baz
105100644 blob X path2/baz/b
6d3a5077
JM
106EOF
107 test_output'
108
66204988
JH
109test_expect_success \
110 'ls-tree filtered with path2' \
111 'git-ls-tree $tree path2 >current &&
112 cat >expected <<\EOF &&
113040000 tree X path2
114040000 tree X path2/baz
115120000 blob X path2/bazbo
116100644 blob X path2/foo
117EOF
118 test_output'
119
120test_expect_success \
121 'ls-tree filtered with path2/' \
122 'git-ls-tree $tree path2/ >current &&
123 cat >expected <<\EOF &&
124040000 tree X path2
125040000 tree X path2/baz
126120000 blob X path2/bazbo
127100644 blob X path2/foo
128EOF
129 test_output'
130
6d3a5077 131test_done