Skip to content

Commit 347c47e

Browse files
committed
Merge branch 'jl/maint-fix-test'
* jl/maint-fix-test: Several tests: cd inside subshell instead of around Conflicts: t/t9600-cvsimport.sh
2 parents c2e0940 + fd4ec4f commit 347c47e

32 files changed

+256
-260
lines changed

t/t1020-subdirectory.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ test_expect_success 'update-index and ls-files' '
2727
one) echo pass one ;;
2828
*) echo bad one; exit 1 ;;
2929
esac &&
30-
cd dir &&
30+
(cd dir &&
3131
git update-index --add two &&
3232
case "`git ls-files`" in
3333
two) echo pass two ;;
3434
*) echo bad two; exit 1 ;;
35-
esac &&
36-
cd .. &&
35+
esac
36+
) &&
3737
case "`git ls-files`" in
3838
dir/two"$LF"one) echo pass both ;;
3939
*) echo bad; exit 1 ;;

t/t1302-repo-version.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ test_expect_success 'gitdir selection on unsupported repo' '
3232
test "$(git config core.repositoryformatversion)" = 99)'
3333

3434
test_expect_success 'gitdir not required mode' '
35-
(git apply --stat test.patch &&
36-
cd test && git apply --stat ../test.patch &&
37-
cd ../test2 && git apply --stat ../test.patch)'
35+
git apply --stat test.patch &&
36+
(cd test && git apply --stat ../test.patch) &&
37+
(cd test2 && git apply --stat ../test.patch)'
3838

3939
test_expect_success 'gitdir required mode on normal repos' '
4040
(git apply --check --index test.patch &&

t/t2101-update-index-reupdate.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ cat > expected <<\EOF
6363
EOF
6464
test_expect_success 'update-index --update from subdir' \
6565
'echo not so happy >file2 &&
66-
cd dir1 &&
66+
(cd dir1 &&
6767
cat ../file2 >file3 &&
68-
git update-index --again &&
69-
cd .. &&
68+
git update-index --again
69+
) &&
7070
git ls-files -s >current &&
7171
cmp current expected'
7272

t/t3060-ls-files-with-tree.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,13 @@ test_expect_success setup '
5555

5656
# We have to run from a sub-directory to trigger prune_path
5757
# Then we finally get to run our --with-tree test
58-
cd sub
5958

6059
test_expect_success 'git -ls-files --with-tree should succeed from subdir' '
6160
62-
git ls-files --with-tree=HEAD~1 >../output
61+
(cd sub && git ls-files --with-tree=HEAD~1 >../output)
6362
6463
'
6564

66-
cd ..
6765
test_expect_success \
6866
'git -ls-files --with-tree should add entries from named tree.' \
6967
'test_cmp expected output'

t/t3409-rebase-preserve-merges.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,23 @@ test_expect_success 'setup for merge-preserving rebase' \
4242
git commit -a -m "Modify A2" &&
4343
4444
git clone ./. clone1 &&
45-
cd clone1 &&
45+
(cd clone1 &&
4646
git checkout -b topic origin/topic &&
47-
git merge origin/master &&
48-
cd .. &&
47+
git merge origin/master
48+
) &&
4949
5050
echo Fifth > B &&
5151
git add B &&
5252
git commit -m "Add different B" &&
5353
5454
git clone ./. clone2 &&
55-
cd clone2 &&
55+
(cd clone2 &&
5656
git checkout -b topic origin/topic &&
5757
test_must_fail git merge origin/master &&
5858
echo Resolved > B &&
5959
git add B &&
60-
git commit -m "Merge origin/master into topic" &&
61-
cd .. &&
60+
git commit -m "Merge origin/master into topic"
61+
) &&
6262
6363
git checkout topic &&
6464
echo Fourth >> B &&

t/t3903-stash.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ test_expect_success 'apply stashed changes (including index)' '
6969
test_expect_success 'unstashing in a subdirectory' '
7070
git reset --hard HEAD &&
7171
mkdir subdir &&
72-
cd subdir &&
73-
git stash apply &&
74-
cd ..
72+
(cd subdir &&
73+
git stash apply
74+
)
7575
'
7676

7777
test_expect_success 'drop top stash' '

t/t4041-diff-submodule-option.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ EOF
8585
"
8686

8787
commit_file sm1 &&
88-
cd sm1 &&
88+
head3=$(cd sm1 &&
8989
git reset --hard HEAD~2 >/dev/null &&
90-
head3=$(git rev-parse --verify HEAD | cut -c1-7) &&
91-
cd ..
90+
git rev-parse --verify HEAD | cut -c1-7
91+
)
9292

9393
test_expect_success 'modified submodule(backward)' "
9494
git diff-index -p --submodule=log HEAD >actual &&

t/t5510-fetch.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,27 @@ test_expect_success setup '
2121

2222
test_expect_success "clone and setup child repos" '
2323
git clone . one &&
24-
cd one &&
24+
(cd one &&
2525
echo >file updated by one &&
26-
git commit -a -m "updated by one" &&
27-
cd .. &&
26+
git commit -a -m "updated by one"
27+
) &&
2828
git clone . two &&
29-
cd two &&
29+
(cd two &&
3030
git config branch.master.remote one &&
3131
git config remote.one.url ../one/.git/ &&
32-
git config remote.one.fetch refs/heads/master:refs/heads/one &&
33-
cd .. &&
32+
git config remote.one.fetch refs/heads/master:refs/heads/one
33+
) &&
3434
git clone . three &&
35-
cd three &&
35+
(cd three &&
3636
git config branch.master.remote two &&
3737
git config branch.master.merge refs/heads/one &&
3838
mkdir -p .git/remotes &&
3939
{
4040
echo "URL: ../two/.git/"
4141
echo "Pull: refs/heads/master:refs/heads/two"
4242
echo "Pull: refs/heads/one:refs/heads/one"
43-
} >.git/remotes/two &&
44-
cd .. &&
43+
} >.git/remotes/two
44+
) &&
4545
git clone . bundle &&
4646
git clone . seven
4747
'

t/t6050-replace.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ test_expect_success '"git fsck" works' '
104104
test_expect_success 'repack, clone and fetch work' '
105105
git repack -a -d &&
106106
git clone --no-hardlinks . clone_dir &&
107-
cd clone_dir &&
107+
(cd clone_dir &&
108108
git show HEAD~5 | grep "A U Thor" &&
109109
git show $HASH2 | grep "A U Thor" &&
110110
git cat-file commit $R &&
@@ -113,8 +113,8 @@ test_expect_success 'repack, clone and fetch work' '
113113
git fetch ../ "refs/replace/*:refs/replace/*" &&
114114
git show HEAD~5 | grep "O Thor" &&
115115
git show $HASH2 | grep "O Thor" &&
116-
git cat-file commit $R &&
117-
cd ..
116+
git cat-file commit $R
117+
)
118118
'
119119

120120
test_expect_success '"git replace" listing and deleting' '
@@ -177,10 +177,10 @@ test_expect_success 'create parallel branch without the bug' '
177177

178178
test_expect_success 'push to cloned repo' '
179179
git push cloned $HASH6^:refs/heads/parallel &&
180-
cd clone_dir &&
180+
(cd clone_dir &&
181181
git checkout parallel &&
182-
git log --pretty=oneline | grep $PARA2 &&
183-
cd ..
182+
git log --pretty=oneline | grep $PARA2
183+
)
184184
'
185185

186186
test_expect_success 'push branch with replacement' '
@@ -191,20 +191,20 @@ test_expect_success 'push branch with replacement' '
191191
git show $HASH6~2 | grep "O Thor" &&
192192
git show $PARA3 | grep "O Thor" &&
193193
git push cloned $HASH6^:refs/heads/parallel2 &&
194-
cd clone_dir &&
194+
(cd clone_dir &&
195195
git checkout parallel2 &&
196196
git log --pretty=oneline | grep $PARA3 &&
197-
git show $PARA3 | grep "A U Thor" &&
198-
cd ..
197+
git show $PARA3 | grep "A U Thor"
198+
)
199199
'
200200

201201
test_expect_success 'fetch branch with replacement' '
202202
git branch tofetch $HASH6 &&
203-
cd clone_dir &&
203+
(cd clone_dir &&
204204
git fetch origin refs/heads/tofetch:refs/heads/parallel3
205205
git log --pretty=oneline parallel3 | grep $PARA3
206206
git show $PARA3 | grep "A U Thor"
207-
cd ..
207+
)
208208
'
209209

210210
test_expect_success 'bisect and replacements' '

t/t7400-submodule-basic.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,12 +413,12 @@ test_expect_success 'submodule <invalid-path> warns' '
413413

414414
test_expect_success 'add submodules without specifying an explicit path' '
415415
mkdir repo &&
416-
cd repo &&
416+
(cd repo &&
417417
git init &&
418418
echo r >r &&
419419
git add r &&
420-
git commit -m "repo commit 1" &&
421-
cd .. &&
420+
git commit -m "repo commit 1"
421+
) &&
422422
git clone --bare repo/ bare.git &&
423423
cd addtest &&
424424
git submodule add "$submodurl/repo" &&

0 commit comments

Comments
 (0)