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