t1020: Get rid of 'cd "$HERE"' at the start of each test
To achieve that, all cd commands which weren't inside a subshell had to be put into a new one. Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jens Lehmann committed
Sep 7, 2010 at 12:29 UTC
fd3c32c9815441ebbc3d46a3ff4ef862b3a9688c
1 file changed
+50
-41
t/t1020-subdirectory.sh
+50
-41
@@ -16,12 +16,10 @@ test_expect_success setup '
16
cp one original.one &&
17
cp dir/two original.two
18
'
19
-HERE=`pwd`
19
LF='
20
'
21
22
test_expect_success 'update-index and ls-files' '
24
- cd "$HERE" &&
23
git update-index --add one &&
24
case "`git ls-files`" in
25
one) echo pass one ;;
@@ -42,20 +40,20 @@ test_expect_success 'update-index and ls-files' '
40
'
41
42
test_expect_success 'cat-file' '
45
- cd "$HERE" &&
43
two=`git ls-files -s dir/two` &&
44
two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` &&
45
echo "$two" &&
46
git cat-file -p "$two" >actual &&
47
cmp dir/two actual &&
51
- cd dir &&
52
- git cat-file -p "$two" >actual &&
53
- cmp two actual
48
+ (
49
+ cd dir &&
50
+ git cat-file -p "$two" >actual &&
51
+ cmp two actual
52
+ )
53
'
54
rm -f actual dir/actual
55
56
test_expect_success 'diff-files' '
58
- cd "$HERE" &&
57
echo a >>one &&
58
echo d >>dir/two &&
59
case "`git diff-files --name-only`" in
@@ -63,77 +61,88 @@ test_expect_success 'diff-files' '
61
*) echo bad top; exit 1 ;;
62
esac &&
63
# 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
64
+ (
65
+ cd dir &&
66
+ case "`git diff-files --name-only`" in
67
+ dir/two"$LF"one) echo pass subdir ;;
68
+ *) echo bad subdir; exit 1 ;;
69
+ esac &&
70
+ case "`git diff-files --name-only .`" in
71
+ dir/two) echo pass subdir limited ;;
72
+ *) echo bad subdir limited; exit 1 ;;
73
+ esac
74
+ )
75
'
76
77
test_expect_success 'write-tree' '
78
- cd "$HERE" &&
78
top=`git write-tree` &&
79
echo $top &&
81
- cd dir &&
82
- sub=`git write-tree` &&
83
- echo $sub &&
84
- test "z$top" = "z$sub"
80
+ (
81
+ cd dir &&
82
+ sub=`git write-tree` &&
83
+ echo $sub &&
84
+ test "z$top" = "z$sub"
85
+ )
86
'
87
88
test_expect_success 'checkout-index' '
88
- cd "$HERE" &&
89
git checkout-index -f -u one &&
90
cmp one original.one &&
91
- cd dir &&
92
- git checkout-index -f -u two &&
93
- cmp two ../original.two
91
+ (
92
+ cd dir &&
93
+ git checkout-index -f -u two &&
94
+ cmp two ../original.two
95
+ )
96
'
97
98
test_expect_success 'read-tree' '
97
- cd "$HERE" &&
99
rm -f one dir/two &&
100
tree=`git write-tree` &&
101
git read-tree --reset -u "$tree" &&
102
cmp one original.one &&
103
cmp dir/two original.two &&
103
- cd dir &&
104
- rm -f two &&
105
- git read-tree --reset -u "$tree" &&
106
- cmp two ../original.two &&
107
- cmp ../one ../original.one
104
+ (
105
+ cd dir &&
106
+ rm -f two &&
107
+ git read-tree --reset -u "$tree" &&
108
+ cmp two ../original.two &&
109
+ cmp ../one ../original.one
110
+ )
111
'
112
113
test_expect_success 'no file/rev ambiguity check inside .git' '
111
- cd "$HERE" &&
114
git commit -a -m 1 &&
113
- cd "$HERE"/.git &&
114
- git show -s HEAD
115
+ (
116
+ cd .git &&
117
+ git show -s HEAD
118
+ )
119
'
120
121
test_expect_success 'no file/rev ambiguity check inside a bare repo' '
118
- cd "$HERE" &&
122
git clone -s --bare .git foo.git &&
120
- cd foo.git && GIT_DIR=. git show -s HEAD
123
+ (
124
+ cd foo.git &&
125
+ GIT_DIR=. git show -s HEAD
126
+ )
127
'
128
129
# This still does not work as it should...
130
: test_expect_success 'no file/rev ambiguity check inside a bare repo' '
125
- cd "$HERE" &&
131
git clone -s --bare .git foo.git &&
127
- cd foo.git && git show -s HEAD
132
+ (
133
+ cd foo.git &&
134
+ git show -s HEAD
135
+ )
136
'
137
138
test_expect_success SYMLINKS 'detection should not be fooled by a symlink' '
131
- cd "$HERE" &&
139
rm -fr foo.git &&
140
git clone -s .git another &&
141
ln -s another yetanother &&
135
- cd yetanother/.git &&
136
- git show -s HEAD
142
+ (
143
+ cd yetanother/.git &&
144
+ git show -s HEAD
145
+ )
146
'
147
148
test_done