Allow querying all attributes on a file
[alt-git.git] / t / t1020-subdirectory.sh
blob865b8ed26d577e154276887f88c8af9d13e62170
1 #!/bin/sh
3 # Copyright (c) 2006 Junio C Hamano
6 test_description='Try various core-level commands in subdirectory.
9 . ./test-lib.sh
10 . "$TEST_DIRECTORY"/lib-read-tree.sh
12 test_expect_success setup '
13 long="a b c d e f g h i j k l m n o p q r s t u v w x y z" &&
14 for c in $long; do echo $c; done >one &&
15 mkdir dir &&
16 for c in x y z $long a b c; do echo $c; done >dir/two &&
17 cp one original.one &&
18 cp dir/two original.two
20 LF='
23 test_expect_success 'update-index and ls-files' '
24 git update-index --add one &&
25 case "`git ls-files`" in
26 one) echo pass one ;;
27 *) echo bad one; exit 1 ;;
28 esac &&
30 cd dir &&
31 git update-index --add two &&
32 case "`git ls-files`" in
33 two) echo pass two ;;
34 *) echo bad two; exit 1 ;;
35 esac
36 ) &&
37 case "`git ls-files`" in
38 dir/two"$LF"one) echo pass both ;;
39 *) echo bad; exit 1 ;;
40 esac
43 test_expect_success 'cat-file' '
44 two=`git ls-files -s dir/two` &&
45 two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` &&
46 echo "$two" &&
47 git cat-file -p "$two" >actual &&
48 cmp dir/two actual &&
50 cd dir &&
51 git cat-file -p "$two" >actual &&
52 cmp two actual
55 rm -f actual dir/actual
57 test_expect_success 'diff-files' '
58 echo a >>one &&
59 echo d >>dir/two &&
60 case "`git diff-files --name-only`" in
61 dir/two"$LF"one) echo pass top ;;
62 *) echo bad top; exit 1 ;;
63 esac &&
64 # diff should not omit leading paths
66 cd dir &&
67 case "`git diff-files --name-only`" in
68 dir/two"$LF"one) echo pass subdir ;;
69 *) echo bad subdir; exit 1 ;;
70 esac &&
71 case "`git diff-files --name-only .`" in
72 dir/two) echo pass subdir limited ;;
73 *) echo bad subdir limited; exit 1 ;;
74 esac
78 test_expect_success 'write-tree' '
79 top=`git write-tree` &&
80 echo $top &&
82 cd dir &&
83 sub=`git write-tree` &&
84 echo $sub &&
85 test "z$top" = "z$sub"
89 test_expect_success 'checkout-index' '
90 git checkout-index -f -u one &&
91 cmp one original.one &&
93 cd dir &&
94 git checkout-index -f -u two &&
95 cmp two ../original.two
99 test_expect_success 'read-tree' '
100 rm -f one dir/two &&
101 tree=`git write-tree` &&
102 read_tree_u_must_succeed --reset -u "$tree" &&
103 cmp one original.one &&
104 cmp dir/two original.two &&
106 cd dir &&
107 rm -f two &&
108 read_tree_u_must_succeed --reset -u "$tree" &&
109 cmp two ../original.two &&
110 cmp ../one ../original.one
114 test_expect_success 'alias expansion' '
116 git config alias.ss status &&
117 cd dir &&
118 git status &&
119 git ss
123 test_expect_success '!alias expansion' '
124 pwd >expect &&
126 git config alias.test !pwd &&
127 cd dir &&
128 git test >../actual
129 ) &&
130 test_cmp expect actual
133 test_expect_success 'GIT_PREFIX for !alias' '
134 printf "dir/" >expect &&
136 git config alias.test "!sh -c \"printf \$GIT_PREFIX\"" &&
137 cd dir &&
138 git test >../actual
139 ) &&
140 test_cmp expect actual
143 test_expect_success 'GIT_PREFIX for built-ins' '
144 # Use GIT_EXTERNAL_DIFF to test that the "diff" built-in
145 # receives the GIT_PREFIX variable.
146 printf "dir/" >expect &&
147 printf "#!/bin/sh\n" >diff &&
148 printf "printf \"\$GIT_PREFIX\"" >>diff &&
149 chmod +x diff &&
151 cd dir &&
152 printf "change" >two &&
153 env GIT_EXTERNAL_DIFF=./diff git diff >../actual
154 git checkout -- two
155 ) &&
156 test_cmp expect actual
159 test_expect_success 'no file/rev ambiguity check inside .git' '
160 git commit -a -m 1 &&
162 cd .git &&
163 git show -s HEAD
167 test_expect_success 'no file/rev ambiguity check inside a bare repo' '
168 git clone -s --bare .git foo.git &&
170 cd foo.git &&
171 GIT_DIR=. git show -s HEAD
175 # This still does not work as it should...
176 : test_expect_success 'no file/rev ambiguity check inside a bare repo' '
177 git clone -s --bare .git foo.git &&
179 cd foo.git &&
180 git show -s HEAD
184 test_expect_success SYMLINKS 'detection should not be fooled by a symlink' '
185 rm -fr foo.git &&
186 git clone -s .git another &&
187 ln -s another yetanother &&
189 cd yetanother/.git &&
190 git show -s HEAD
194 test_done