Skip to content

Commit 8a8da49

Browse files
ttaylorrgitster
authored andcommitted
t5537: use test_write_lines and indented heredocs for readability
A number of spots in t5537 use the non-indented heredoc '<<EOF' when they would benefit from instead using '<<-EOF' or simply test_write_lines. In preparation for adding new tests in a good style and being consistent with the surrounding code, update the existing tests to improve their readability. Suggested-by: Junio C Hamano <[email protected]> Signed-off-by: Taylor Blau <[email protected]> Reviewed-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 274b9cc commit 8a8da49

File tree

1 file changed

+17
-53
lines changed

1 file changed

+17
-53
lines changed

t/t5537-fetch-shallow.sh

Lines changed: 17 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test_expect_success 'setup' '
1616
commit 3 &&
1717
commit 4 &&
1818
git config --global transfer.fsckObjects true &&
19-
test_oid_cache <<-EOF
19+
test_oid_cache <<-\EOF
2020
perl sha1:s/0034shallow %s/0036unshallow %s/
2121
perl sha256:s/004cshallow %s/004eunshallow %s/
2222
EOF
@@ -25,10 +25,7 @@ test_expect_success 'setup' '
2525
test_expect_success 'setup shallow clone' '
2626
git clone --no-local --depth=2 .git shallow &&
2727
git --git-dir=shallow/.git log --format=%s >actual &&
28-
cat <<EOF >expect &&
29-
4
30-
3
31-
EOF
28+
test_write_lines 4 3 >expect &&
3229
test_cmp expect actual
3330
'
3431

@@ -38,10 +35,7 @@ test_expect_success 'clone from shallow clone' '
3835
cd shallow2 &&
3936
git fsck &&
4037
git log --format=%s >actual &&
41-
cat <<EOF >expect &&
42-
4
43-
3
44-
EOF
38+
test_write_lines 4 3 >expect &&
4539
test_cmp expect actual
4640
)
4741
'
@@ -56,11 +50,7 @@ test_expect_success 'fetch from shallow clone' '
5650
git fetch &&
5751
git fsck &&
5852
git log --format=%s origin/master >actual &&
59-
cat <<EOF >expect &&
60-
5
61-
4
62-
3
63-
EOF
53+
test_write_lines 5 4 3 >expect &&
6454
test_cmp expect actual
6555
)
6656
'
@@ -75,10 +65,7 @@ test_expect_success 'fetch --depth from shallow clone' '
7565
git fetch --depth=2 &&
7666
git fsck &&
7767
git log --format=%s origin/master >actual &&
78-
cat <<EOF >expect &&
79-
6
80-
5
81-
EOF
68+
test_write_lines 6 5 >expect &&
8269
test_cmp expect actual
8370
)
8471
'
@@ -89,12 +76,7 @@ test_expect_success 'fetch --unshallow from shallow clone' '
8976
git fetch --unshallow &&
9077
git fsck &&
9178
git log --format=%s origin/master >actual &&
92-
cat <<EOF >expect &&
93-
6
94-
5
95-
4
96-
3
97-
EOF
79+
test_write_lines 6 5 4 3 >expect &&
9880
test_cmp expect actual
9981
)
10082
'
@@ -111,15 +93,10 @@ test_expect_success 'fetch something upstream has but hidden by clients shallow
11193
git fetch ../.git +refs/heads/master:refs/remotes/top/master &&
11294
git fsck &&
11395
git log --format=%s top/master >actual &&
114-
cat <<EOF >expect &&
115-
add-1-back
116-
4
117-
3
118-
EOF
96+
test_write_lines add-1-back 4 3 >expect &&
11997
test_cmp expect actual
12098
) &&
12199
git --git-dir=shallow2/.git cat-file blob $(echo 1|git hash-object --stdin) >/dev/null
122-
123100
'
124101

125102
test_expect_success 'fetch that requires changes in .git/shallow is filtered' '
@@ -133,14 +110,10 @@ test_expect_success 'fetch that requires changes in .git/shallow is filtered' '
133110
cd notshallow &&
134111
git fetch ../shallow/.git refs/heads/*:refs/remotes/shallow/*&&
135112
git for-each-ref --format="%(refname)" >actual.refs &&
136-
cat <<EOF >expect.refs &&
137-
refs/remotes/shallow/no-shallow
138-
EOF
113+
echo refs/remotes/shallow/no-shallow >expect.refs &&
139114
test_cmp expect.refs actual.refs &&
140115
git log --format=%s shallow/no-shallow >actual &&
141-
cat <<EOF >expect &&
142-
no-shallow
143-
EOF
116+
echo no-shallow >expect &&
144117
test_cmp expect actual
145118
)
146119
'
@@ -158,21 +131,15 @@ test_expect_success 'fetch --update-shallow' '
158131
git fetch --update-shallow ../shallow/.git refs/heads/*:refs/remotes/shallow/* &&
159132
git fsck &&
160133
git for-each-ref --sort=refname --format="%(refname)" >actual.refs &&
161-
cat <<EOF >expect.refs &&
162-
refs/remotes/shallow/master
163-
refs/remotes/shallow/no-shallow
164-
refs/tags/heavy-tag
165-
refs/tags/light-tag
166-
EOF
134+
cat <<-\EOF >expect.refs &&
135+
refs/remotes/shallow/master
136+
refs/remotes/shallow/no-shallow
137+
refs/tags/heavy-tag
138+
refs/tags/light-tag
139+
EOF
167140
test_cmp expect.refs actual.refs &&
168141
git log --format=%s shallow/master >actual &&
169-
cat <<EOF >expect &&
170-
7
171-
6
172-
5
173-
4
174-
3
175-
EOF
142+
test_write_lines 7 6 5 4 3 >expect &&
176143
test_cmp expect actual
177144
)
178145
'
@@ -183,10 +150,7 @@ test_expect_success POSIXPERM,SANITY 'shallow fetch from a read-only repo' '
183150
find read-only.git -print | xargs chmod -w &&
184151
git clone --no-local --depth=2 read-only.git from-read-only &&
185152
git --git-dir=from-read-only/.git log --format=%s >actual &&
186-
cat >expect <<EOF &&
187-
add-1-back
188-
4
189-
EOF
153+
test_write_lines add-1-back 4 >expect &&
190154
test_cmp expect actual
191155
'
192156

0 commit comments

Comments
 (0)