3 # Copyright (c) 2006 Junio C Hamano
6 test_description
='Try various core-level commands in subdirectory.
11 test_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 &&
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
23 test_expect_success
'update-index and ls-files' '
25 git update-index --add one &&
26 case "`git ls-files`" in
28 *) 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 ok both ;;
39 *) echo bad; exit 1 ;;
43 test_expect_success
'cat-file' '
45 two=`git ls-files -s dir/two` &&
46 two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` &&
48 git cat-file -p "$two" >actual &&
51 git cat-file -p "$two" >actual &&
54 rm -f actual dir
/actual
56 test_expect_success
'diff-files' '
60 case "`git diff-files --name-only`" in
61 dir/two"$LF"one) echo ok top ;;
62 *) echo bad top; exit 1 ;;
64 # diff should not omit leading paths
66 case "`git diff-files --name-only`" in
67 dir/two"$LF"one) echo ok subdir ;;
68 *) echo bad subdir; exit 1 ;;
70 case "`git diff-files --name-only .`" in
71 dir/two) echo ok subdir limited ;;
72 *) echo bad subdir limited; exit 1 ;;
76 test_expect_success
'write-tree' '
78 top=`git write-tree` &&
81 sub=`git write-tree` &&
83 test "z$top" = "z$sub"
86 test_expect_success
'checkout-index' '
88 git checkout-index -f -u one &&
89 cmp one original.one &&
91 git checkout-index -f -u two &&
92 cmp two ../original.two
95 test_expect_success
'read-tree' '
98 tree=`git write-tree` &&
99 git read-tree --reset -u "$tree" &&
100 cmp one original.one &&
101 cmp dir/two original.two &&
104 git read-tree --reset -u "$tree" &&
105 cmp two ../original.two &&
106 cmp ../one ../original.one
109 test_expect_success
'no file/rev ambiguity check inside .git' '
111 git commit -a -m 1 &&
116 test_expect_success
'no file/rev ambiguity check inside a bare repo' '
118 git clone -s --bare .git foo.git &&
119 cd foo.git && GIT_DIR=. git show -s HEAD
122 # This still does not work as it should...
123 : test_expect_success
'no file/rev ambiguity check inside a bare repo' '
125 git clone -s --bare .git foo.git &&
126 cd foo.git && git show -s HEAD
129 test "$no_symlinks" ||
130 test_expect_success
'detection should not be fooled by a symlink' '
133 git clone -s .git another &&
134 ln -s another yetanother &&
135 cd yetanother/.git &&