Skip to content

Commit 7f71a6a

Browse files
jrngitster
authored andcommitted
t1011 (sparse checkout): style nitpicks
Tweak the rest of the script to more closely follow the test style guide. Guarding setup commands with test_expect_success makes it easy to see the scope in which some particular data is used; removal of whitespace after >redirection operators is just for consistency. Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e923eae commit 7f71a6a

File tree

1 file changed

+55
-47
lines changed

1 file changed

+55
-47
lines changed

t/t1011-read-tree-sparse-checkout.sh

Lines changed: 55 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
11
#!/bin/sh
22

3-
test_description='sparse checkout tests'
3+
test_description='sparse checkout tests
4+
5+
* (tag: removed, master) removed
6+
| D sub/added
7+
* (HEAD, tag: top) modified and added
8+
| M init.t
9+
| A sub/added
10+
* (tag: init) init
11+
A init.t
12+
'
413

514
. ./test-lib.sh
615

7-
cat >expected <<EOF
8-
100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0 init.t
9-
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sub/added
10-
EOF
1116
test_expect_success 'setup' '
17+
cat >expected <<-\EOF &&
18+
100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0 init.t
19+
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sub/added
20+
EOF
21+
cat >expected.swt <<-\EOF &&
22+
H init.t
23+
H sub/added
24+
EOF
25+
1226
test_commit init &&
13-
echo modified >> init.t &&
27+
echo modified >>init.t &&
1428
mkdir sub &&
1529
touch sub/added &&
1630
git add init.t sub/added &&
@@ -20,129 +34,123 @@ test_expect_success 'setup' '
2034
git commit -m removed &&
2135
git tag removed &&
2236
git checkout top &&
23-
git ls-files --stage > result &&
37+
git ls-files --stage >result &&
2438
test_cmp expected result
2539
'
2640

27-
cat >expected.swt <<EOF
28-
H init.t
29-
H sub/added
30-
EOF
3141
test_expect_success 'read-tree without .git/info/sparse-checkout' '
3242
git read-tree -m -u HEAD &&
33-
git ls-files --stage > result &&
43+
git ls-files --stage >result &&
3444
test_cmp expected result &&
35-
git ls-files -t > result &&
45+
git ls-files -t >result &&
3646
test_cmp expected.swt result
3747
'
3848

3949
test_expect_success 'read-tree with .git/info/sparse-checkout but disabled' '
40-
echo > .git/info/sparse-checkout
50+
echo >.git/info/sparse-checkout
4151
git read-tree -m -u HEAD &&
42-
git ls-files -t > result &&
52+
git ls-files -t >result &&
4353
test_cmp expected.swt result &&
4454
test -f init.t &&
4555
test -f sub/added
4656
'
4757

4858
test_expect_success 'read-tree --no-sparse-checkout with empty .git/info/sparse-checkout and enabled' '
4959
git config core.sparsecheckout true &&
50-
echo > .git/info/sparse-checkout &&
60+
echo >.git/info/sparse-checkout &&
5161
git read-tree --no-sparse-checkout -m -u HEAD &&
52-
git ls-files -t > result &&
62+
git ls-files -t >result &&
5363
test_cmp expected.swt result &&
5464
test -f init.t &&
5565
test -f sub/added
5666
'
5767

5868
test_expect_success 'read-tree with empty .git/info/sparse-checkout' '
5969
git config core.sparsecheckout true &&
60-
echo > .git/info/sparse-checkout &&
70+
echo >.git/info/sparse-checkout &&
6171
test_must_fail git read-tree -m -u HEAD &&
62-
git ls-files --stage > result &&
72+
git ls-files --stage >result &&
6373
test_cmp expected result &&
64-
git ls-files -t > result &&
74+
git ls-files -t >result &&
6575
test_cmp expected.swt result &&
6676
test -f init.t &&
6777
test -f sub/added
6878
'
6979

70-
cat >expected.swt <<EOF
71-
S init.t
72-
H sub/added
73-
EOF
7480
test_expect_success 'match directories with trailing slash' '
81+
cat >expected.swt-noinit <<-\EOF &&
82+
S init.t
83+
H sub/added
84+
EOF
85+
7586
echo sub/ > .git/info/sparse-checkout &&
7687
git read-tree -m -u HEAD &&
7788
git ls-files -t > result &&
78-
test_cmp expected.swt result &&
89+
test_cmp expected.swt-noinit result &&
7990
test ! -f init.t &&
8091
test -f sub/added
8192
'
8293

83-
cat >expected.swt <<EOF
84-
H init.t
85-
H sub/added
86-
EOF
8794
test_expect_failure 'match directories without trailing slash' '
88-
echo init.t > .git/info/sparse-checkout &&
89-
echo sub >> .git/info/sparse-checkout &&
95+
echo init.t >.git/info/sparse-checkout &&
96+
echo sub >>.git/info/sparse-checkout &&
9097
git read-tree -m -u HEAD &&
91-
git ls-files -t > result &&
98+
git ls-files -t >result &&
9299
test_cmp expected.swt result &&
93100
test ! -f init.t &&
94101
test -f sub/added
95102
'
96103

97-
cat >expected.swt <<EOF
98-
H init.t
99-
S sub/added
100-
EOF
101104
test_expect_success 'checkout area changes' '
102-
echo init.t > .git/info/sparse-checkout &&
105+
cat >expected.swt-nosub <<-\EOF &&
106+
H init.t
107+
S sub/added
108+
EOF
109+
110+
echo init.t >.git/info/sparse-checkout &&
103111
git read-tree -m -u HEAD &&
104-
git ls-files -t > result &&
105-
test_cmp expected.swt result &&
112+
git ls-files -t >result &&
113+
test_cmp expected.swt-nosub result &&
106114
test -f init.t &&
107115
test ! -f sub/added
108116
'
109117

110118
test_expect_success 'read-tree updates worktree, absent case' '
111-
echo sub/added > .git/info/sparse-checkout &&
119+
echo sub/added >.git/info/sparse-checkout &&
112120
git checkout -f top &&
113121
git read-tree -m -u HEAD^ &&
114122
test ! -f init.t
115123
'
116124

117125
test_expect_success 'read-tree updates worktree, dirty case' '
118-
echo sub/added > .git/info/sparse-checkout &&
126+
echo sub/added >.git/info/sparse-checkout &&
119127
git checkout -f top &&
120-
echo dirty > init.t &&
128+
echo dirty >init.t &&
121129
git read-tree -m -u HEAD^ &&
122130
grep -q dirty init.t &&
123131
rm init.t
124132
'
125133

126134
test_expect_success 'read-tree removes worktree, dirty case' '
127-
echo init.t > .git/info/sparse-checkout &&
135+
echo init.t >.git/info/sparse-checkout &&
128136
git checkout -f top &&
129-
echo dirty > added &&
137+
echo dirty >added &&
130138
git read-tree -m -u HEAD^ &&
131139
grep -q dirty added
132140
'
133141

134142
test_expect_success 'read-tree adds to worktree, absent case' '
135-
echo init.t > .git/info/sparse-checkout &&
143+
echo init.t >.git/info/sparse-checkout &&
136144
git checkout -f removed &&
137145
git read-tree -u -m HEAD^ &&
138146
test ! -f sub/added
139147
'
140148

141149
test_expect_success 'read-tree adds to worktree, dirty case' '
142-
echo init.t > .git/info/sparse-checkout &&
150+
echo init.t >.git/info/sparse-checkout &&
143151
git checkout -f removed &&
144152
mkdir sub &&
145-
echo dirty > sub/added &&
153+
echo dirty >sub/added &&
146154
git read-tree -u -m HEAD^ &&
147155
grep -q dirty sub/added
148156
'

0 commit comments

Comments
 (0)