]> git.ipfire.org Git - thirdparty/git.git/blame - t/t1020-subdirectory.sh
tests: Skip tests in a way that makes sense under TAP
[thirdparty/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'
19HERE=`pwd`
20LF='
21'
22
23test_expect_success 'update-index and ls-files' '
f69e836f 24 cd "$HERE" &&
5be60078
JH
25 git update-index --add one &&
26 case "`git ls-files`" in
c43ce6d6
JH
27 one) echo ok one ;;
28 *) echo bad one; exit 1 ;;
29 esac &&
30 cd dir &&
5be60078
JH
31 git update-index --add two &&
32 case "`git ls-files`" in
c43ce6d6
JH
33 two) echo ok two ;;
34 *) echo bad two; exit 1 ;;
35 esac &&
36 cd .. &&
5be60078 37 case "`git ls-files`" in
c43ce6d6
JH
38 dir/two"$LF"one) echo ok both ;;
39 *) echo bad; exit 1 ;;
40 esac
41'
42
43test_expect_success 'cat-file' '
f69e836f 44 cd "$HERE" &&
5be60078 45 two=`git ls-files -s dir/two` &&
c43ce6d6
JH
46 two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` &&
47 echo "$two" &&
5be60078 48 git cat-file -p "$two" >actual &&
c43ce6d6
JH
49 cmp dir/two actual &&
50 cd dir &&
5be60078 51 git cat-file -p "$two" >actual &&
c43ce6d6
JH
52 cmp two actual
53'
54rm -f actual dir/actual
55
56test_expect_success 'diff-files' '
f69e836f 57 cd "$HERE" &&
c43ce6d6
JH
58 echo a >>one &&
59 echo d >>dir/two &&
5be60078 60 case "`git diff-files --name-only`" in
c43ce6d6
JH
61 dir/two"$LF"one) echo ok top ;;
62 *) echo bad top; exit 1 ;;
63 esac &&
64 # diff should not omit leading paths
65 cd dir &&
5be60078 66 case "`git diff-files --name-only`" in
c43ce6d6
JH
67 dir/two"$LF"one) echo ok subdir ;;
68 *) echo bad subdir; exit 1 ;;
69 esac &&
5be60078 70 case "`git diff-files --name-only .`" in
c43ce6d6
JH
71 dir/two) echo ok subdir limited ;;
72 *) echo bad subdir limited; exit 1 ;;
73 esac
74'
75
76test_expect_success 'write-tree' '
f69e836f 77 cd "$HERE" &&
5be60078 78 top=`git write-tree` &&
c43ce6d6
JH
79 echo $top &&
80 cd dir &&
5be60078 81 sub=`git write-tree` &&
c43ce6d6
JH
82 echo $sub &&
83 test "z$top" = "z$sub"
84'
85
86test_expect_success 'checkout-index' '
f69e836f 87 cd "$HERE" &&
5be60078 88 git checkout-index -f -u one &&
c43ce6d6
JH
89 cmp one original.one &&
90 cd dir &&
5be60078 91 git checkout-index -f -u two &&
c43ce6d6
JH
92 cmp two ../original.two
93'
94
95test_expect_success 'read-tree' '
f69e836f 96 cd "$HERE" &&
c43ce6d6 97 rm -f one dir/two &&
5be60078
JH
98 tree=`git write-tree` &&
99 git read-tree --reset -u "$tree" &&
c43ce6d6
JH
100 cmp one original.one &&
101 cmp dir/two original.two &&
102 cd dir &&
103 rm -f two &&
5be60078 104 git read-tree --reset -u "$tree" &&
c43ce6d6
JH
105 cmp two ../original.two &&
106 cmp ../one ../original.one
107'
108
3dff5379 109test_expect_success 'no file/rev ambiguity check inside .git' '
f69e836f 110 cd "$HERE" &&
68025633 111 git commit -a -m 1 &&
f69e836f 112 cd "$HERE"/.git &&
68025633
JS
113 git show -s HEAD
114'
115
3dff5379 116test_expect_success 'no file/rev ambiguity check inside a bare repo' '
f69e836f 117 cd "$HERE" &&
68025633
JS
118 git clone -s --bare .git foo.git &&
119 cd foo.git && GIT_DIR=. git show -s HEAD
120'
121
122# This still does not work as it should...
3dff5379 123: test_expect_success 'no file/rev ambiguity check inside a bare repo' '
f69e836f 124 cd "$HERE" &&
68025633
JS
125 git clone -s --bare .git foo.git &&
126 cd foo.git && git show -s HEAD
127'
128
704a3143 129test_expect_success SYMLINKS 'detection should not be fooled by a symlink' '
f69e836f 130 cd "$HERE" &&
68025633
JS
131 rm -fr foo.git &&
132 git clone -s .git another &&
133 ln -s another yetanother &&
134 cd yetanother/.git &&
135 git show -s HEAD
136'
137
c43ce6d6 138test_done