3 # Copyright (c) 2006 Junio C Hamano
6 test_description='Try various core-level commands in subdirectory.
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 &&
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
23 test_expect_success 'update-index and ls-files' '
24 git update-index --add one &&
25 case "`git ls-files`" in
27 *) echo bad one; exit 1 ;;
31 git update-index --add two &&
32 case "`git ls-files`" in
34 *) echo bad two; exit 1 ;;
37 case "`git ls-files`" in
38 dir/two"$LF"one) echo pass both ;;
39 *) echo bad; exit 1 ;;
43 test_expect_success 'cat-file' '
44 two=`git ls-files -s dir/two` &&
45 two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` &&
47 git cat-file -p "$two" >actual &&
51 git cat-file -p "$two" >actual &&
55 rm -f actual dir/actual
57 test_expect_success 'diff-files' '
60 case "`git diff-files --name-only`" in
61 dir/two"$LF"one) echo pass top ;;
62 *) echo bad top; exit 1 ;;
64 # diff should not omit leading paths
67 case "`git diff-files --name-only`" in
68 dir/two"$LF"one) echo pass subdir ;;
69 *) echo bad subdir; exit 1 ;;
71 case "`git diff-files --name-only .`" in
72 dir/two) echo pass subdir limited ;;
73 *) echo bad subdir limited; exit 1 ;;
78 test_expect_success 'write-tree' '
79 top=`git write-tree` &&
83 sub=`git write-tree` &&
85 test "z$top" = "z$sub"
89 test_expect_success 'checkout-index' '
90 git checkout-index -f -u one &&
91 cmp one original.one &&
94 git checkout-index -f -u two &&
95 cmp two ../original.two
99 test_expect_success 'read-tree' '
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 &&
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 &&
123 test_expect_success '!alias expansion' '
126 git config alias.test !pwd &&
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\"" &&
140 test_cmp expect actual
143 test_expect_success 'no file/rev ambiguity check inside .git' '
144 git commit -a -m 1 &&
151 test_expect_success 'no file/rev ambiguity check inside a bare repo' '
152 git clone -s --bare .git 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 &&
168 test_expect_success SYMLINKS 'detection should not be fooled by a symlink' '
170 git clone -s .git another &&
171 ln -s another yetanother &&
173 cd yetanother/.git &&