66test_description=' test transitive info/alternate entries'
77. ./test-lib.sh
88
9- base_dir=$( pwd)
10-
119test_expect_success ' preparing first repository' '
12- test_create_repo A &&
13- cd A &&
14- echo "Hello World" > file1 &&
15- git add file1 &&
16- git commit -m "Initial commit" file1 &&
17- git repack -a -d &&
18- git prune
10+ test_create_repo A && (
11+ cd A &&
12+ echo "Hello World" > file1 &&
13+ git add file1 &&
14+ git commit -m "Initial commit" file1 &&
15+ git repack -a -d &&
16+ git prune
17+ )
1918'
2019
21- cd " $base_dir "
22-
2320test_expect_success ' preparing second repository' '
24- git clone -l -s A B &&
25- cd B &&
26- echo "foo bar" > file2 &&
27- git add file2 &&
28- git commit -m "next commit" file2 &&
29- git repack -a -d -l &&
30- git prune
21+ git clone -l -s A B && (
22+ cd B &&
23+ echo "foo bar" > file2 &&
24+ git add file2 &&
25+ git commit -m "next commit" file2 &&
26+ git repack -a -d -l &&
27+ git prune
28+ )
3129'
3230
33- cd " $base_dir "
34-
3531test_expect_success ' preparing third repository' '
36- git clone -l -s B C &&
37- cd C &&
38- echo "Goodbye, cruel world" > file3 &&
39- git add file3 &&
40- git commit -m "one more" file3 &&
41- git repack -a -d -l &&
42- git prune
32+ git clone -l -s B C && (
33+ cd C &&
34+ echo "Goodbye, cruel world" > file3 &&
35+ git add file3 &&
36+ git commit -m "one more" file3 &&
37+ git repack -a -d -l &&
38+ git prune
39+ )
4340'
4441
45- cd " $base_dir "
46-
4742test_expect_success ' creating too deep nesting' '
4843 git clone -l -s C D &&
4944 git clone -l -s D E &&
@@ -53,55 +48,34 @@ test_expect_success 'creating too deep nesting' '
5348'
5449
5550test_expect_success ' invalidity of deepest repository' '
56- cd H &&
57- test_must_fail git fsck
51+ test_must_fail git -C H fsck
5852'
5953
60- cd " $base_dir "
61-
6254test_expect_success ' validity of third repository' '
63- cd C &&
64- git fsck
55+ git -C C fsck
6556'
6657
67- cd " $base_dir "
68-
6958test_expect_success ' validity of fourth repository' '
70- cd D &&
71- git fsck
59+ git -C D fsck
7260'
7361
74- cd " $base_dir "
75-
7662test_expect_success ' breaking of loops' '
77- echo "$base_dir"/B/.git/objects >>"$base_dir"/A/.git/objects/info/alternatesi &&
78- cd C &&
79- git fsck
63+ echo "$(pwd)"/B/.git/objects >>A/.git/objects/info/alternates &&
64+ git -C C fsck
8065'
8166
82- cd " $base_dir "
83-
8467test_expect_success ' that info/alternates is necessary' '
85- cd C &&
86- rm -f .git/objects/info/alternates &&
87- test_must_fail git fsck
68+ rm -f C/.git/objects/info/alternates &&
69+ test_must_fail git -C C fsck
8870'
8971
90- cd " $base_dir "
91-
9272test_expect_success ' that relative alternate is possible for current dir' '
93- cd C &&
94- echo "../../../B/.git/objects" > .git/objects/info/alternates &&
73+ echo "../../../B/.git/objects" >C/.git/objects/info/alternates &&
9574 git fsck
9675'
9776
98- cd " $base_dir "
99-
10077test_expect_success ' that relative alternate is only possible for current dir' '
101- cd D &&
102- test_must_fail git fsck
78+ test_must_fail git -C D fsck
10379'
10480
105- cd " $base_dir "
106-
10781test_done
0 commit comments