diff: Fix rename pretty-print when suffix and prefix overlap
[git/jnareb-git.git] / t / t1020-subdirectory.sh
blobf6a44c9ee07329c8909662d2a807acf0dd6a8e43
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 'no file/rev ambiguity check inside .git' '
144 git commit -a -m 1 &&
146 cd .git &&
147 git show -s HEAD
151 test_expect_success 'no file/rev ambiguity check inside a bare repo' '
152 git clone -s --bare .git foo.git &&
154 cd foo.git &&
155 GIT_DIR=. git show -s HEAD
159 # This still does not work as it should...
160 : test_expect_success 'no file/rev ambiguity check inside a bare repo' '
161 git clone -s --bare .git foo.git &&
163 cd foo.git &&
164 git show -s HEAD
168 test_expect_success SYMLINKS 'detection should not be fooled by a symlink' '
169 rm -fr foo.git &&
170 git clone -s .git another &&
171 ln -s another yetanother &&
173 cd yetanother/.git &&
174 git show -s HEAD
178 test_done