t1020: test !alias in subdirectory
[git/git.git] / t / t1020-subdirectory.sh
CommitLineData
c43ce6d6
JH
1#!/bin/sh
2#
3# Copyright (c) 2006 Junio C Hamano
4#
5
6test_description='Try various core-level commands in subdirectory.
7'
8
9. ./test-lib.sh
10
11test_expect_success setup '
12 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" &&
13 for c in $long; do echo $c; done >one &&
14 mkdir dir &&
15 for c in x y z $long a b c; do echo $c; done >dir/two &&
16 cp one original.one &&
17 cp dir/two original.two
18'
c43ce6d6
JH
19LF='
20'
21
22test_expect_success 'update-index and ls-files' '
5be60078
JH
23 git update-index --add one &&
24 case "`git ls-files`" in
335f8787 25 one) echo pass one ;;
c43ce6d6
JH
26 *) echo bad one; exit 1 ;;
27 esac &&
18a82692
JN
28 (
29 cd dir &&
30 git update-index --add two &&
31 case "`git ls-files`" in
32 two) echo pass two ;;
33 *) echo bad two; exit 1 ;;
34 esac
fd4ec4f2 35 ) &&
5be60078 36 case "`git ls-files`" in
335f8787 37 dir/two"$LF"one) echo pass both ;;
c43ce6d6
JH
38 *) echo bad; exit 1 ;;
39 esac
40'
41
42test_expect_success 'cat-file' '
5be60078 43 two=`git ls-files -s dir/two` &&
c43ce6d6
JH
44 two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` &&
45 echo "$two" &&
5be60078 46 git cat-file -p "$two" >actual &&
c43ce6d6 47 cmp dir/two actual &&
fd3c32c9
JL
48 (
49 cd dir &&
50 git cat-file -p "$two" >actual &&
51 cmp two actual
52 )
c43ce6d6
JH
53'
54rm -f actual dir/actual
55
56test_expect_success 'diff-files' '
c43ce6d6
JH
57 echo a >>one &&
58 echo d >>dir/two &&
5be60078 59 case "`git diff-files --name-only`" in
335f8787 60 dir/two"$LF"one) echo pass top ;;
c43ce6d6
JH
61 *) echo bad top; exit 1 ;;
62 esac &&
63 # diff should not omit leading paths
fd3c32c9
JL
64 (
65 cd dir &&
66 case "`git diff-files --name-only`" in
67 dir/two"$LF"one) echo pass subdir ;;
68 *) echo bad subdir; exit 1 ;;
69 esac &&
70 case "`git diff-files --name-only .`" in
71 dir/two) echo pass subdir limited ;;
72 *) echo bad subdir limited; exit 1 ;;
73 esac
74 )
c43ce6d6
JH
75'
76
77test_expect_success 'write-tree' '
5be60078 78 top=`git write-tree` &&
c43ce6d6 79 echo $top &&
fd3c32c9
JL
80 (
81 cd dir &&
82 sub=`git write-tree` &&
83 echo $sub &&
84 test "z$top" = "z$sub"
85 )
c43ce6d6
JH
86'
87
88test_expect_success 'checkout-index' '
5be60078 89 git checkout-index -f -u one &&
c43ce6d6 90 cmp one original.one &&
fd3c32c9
JL
91 (
92 cd dir &&
93 git checkout-index -f -u two &&
94 cmp two ../original.two
95 )
c43ce6d6
JH
96'
97
98test_expect_success 'read-tree' '
c43ce6d6 99 rm -f one dir/two &&
5be60078
JH
100 tree=`git write-tree` &&
101 git read-tree --reset -u "$tree" &&
c43ce6d6
JH
102 cmp one original.one &&
103 cmp dir/two original.two &&
fd3c32c9
JL
104 (
105 cd dir &&
106 rm -f two &&
107 git read-tree --reset -u "$tree" &&
108 cmp two ../original.two &&
109 cmp ../one ../original.one
110 )
c43ce6d6
JH
111'
112
101662c2
MG
113test_expect_success 'alias expansion' '
114 (
115 git config alias.ss status &&
116 cd dir &&
117 git status &&
118 git ss
119 )
120'
0daed417
MG
121
122test_expect_success '!alias expansion' '
123 pwd >expect &&
124 (
125 git config alias.test !pwd &&
126 cd dir &&
127 git test >../actual
128 ) &&
129 test_cmp expect actual
130'
131
3dff5379 132test_expect_success 'no file/rev ambiguity check inside .git' '
68025633 133 git commit -a -m 1 &&
fd3c32c9
JL
134 (
135 cd .git &&
136 git show -s HEAD
137 )
68025633
JS
138'
139
3dff5379 140test_expect_success 'no file/rev ambiguity check inside a bare repo' '
68025633 141 git clone -s --bare .git foo.git &&
fd3c32c9
JL
142 (
143 cd foo.git &&
144 GIT_DIR=. git show -s HEAD
145 )
68025633
JS
146'
147
148# This still does not work as it should...
3dff5379 149: test_expect_success 'no file/rev ambiguity check inside a bare repo' '
68025633 150 git clone -s --bare .git foo.git &&
fd3c32c9
JL
151 (
152 cd foo.git &&
153 git show -s HEAD
154 )
68025633
JS
155'
156
704a3143 157test_expect_success SYMLINKS 'detection should not be fooled by a symlink' '
68025633
JS
158 rm -fr foo.git &&
159 git clone -s .git another &&
160 ln -s another yetanother &&
fd3c32c9
JL
161 (
162 cd yetanother/.git &&
163 git show -s HEAD
164 )
68025633
JS
165'
166
c43ce6d6 167test_done