Skip to content

Commit fd3c32c

Browse files
jlehmanngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a814615 commit fd3c32c

File tree

1 file changed

+50
-41
lines changed

1 file changed

+50
-41
lines changed

t/t1020-subdirectory.sh

Lines changed: 50 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ test_expect_success setup '
1616
cp one original.one &&
1717
cp dir/two original.two
1818
'
19-
HERE=`pwd`
2019
LF='
2120
'
2221

2322
test_expect_success 'update-index and ls-files' '
24-
cd "$HERE" &&
2523
git update-index --add one &&
2624
case "`git ls-files`" in
2725
one) echo pass one ;;
@@ -42,98 +40,109 @@ test_expect_success 'update-index and ls-files' '
4240
'
4341

4442
test_expect_success 'cat-file' '
45-
cd "$HERE" &&
4643
two=`git ls-files -s dir/two` &&
4744
two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` &&
4845
echo "$two" &&
4946
git cat-file -p "$two" >actual &&
5047
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+
)
5453
'
5554
rm -f actual dir/actual
5655

5756
test_expect_success 'diff-files' '
58-
cd "$HERE" &&
5957
echo a >>one &&
6058
echo d >>dir/two &&
6159
case "`git diff-files --name-only`" in
6260
dir/two"$LF"one) echo pass top ;;
6361
*) echo bad top; exit 1 ;;
6462
esac &&
6563
# 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+
)
7575
'
7676

7777
test_expect_success 'write-tree' '
78-
cd "$HERE" &&
7978
top=`git write-tree` &&
8079
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+
)
8586
'
8687

8788
test_expect_success 'checkout-index' '
88-
cd "$HERE" &&
8989
git checkout-index -f -u one &&
9090
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+
)
9496
'
9597

9698
test_expect_success 'read-tree' '
97-
cd "$HERE" &&
9899
rm -f one dir/two &&
99100
tree=`git write-tree` &&
100101
git read-tree --reset -u "$tree" &&
101102
cmp one original.one &&
102103
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+
)
108111
'
109112

110113
test_expect_success 'no file/rev ambiguity check inside .git' '
111-
cd "$HERE" &&
112114
git commit -a -m 1 &&
113-
cd "$HERE"/.git &&
114-
git show -s HEAD
115+
(
116+
cd .git &&
117+
git show -s HEAD
118+
)
115119
'
116120

117121
test_expect_success 'no file/rev ambiguity check inside a bare repo' '
118-
cd "$HERE" &&
119122
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+
)
121127
'
122128

123129
# This still does not work as it should...
124130
: test_expect_success 'no file/rev ambiguity check inside a bare repo' '
125-
cd "$HERE" &&
126131
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+
)
128136
'
129137

130138
test_expect_success SYMLINKS 'detection should not be fooled by a symlink' '
131-
cd "$HERE" &&
132139
rm -fr foo.git &&
133140
git clone -s .git another &&
134141
ln -s another yetanother &&
135-
cd yetanother/.git &&
136-
git show -s HEAD
142+
(
143+
cd yetanother/.git &&
144+
git show -s HEAD
145+
)
137146
'
138147

139148
test_done

0 commit comments

Comments
 (0)