@matheusbsbs / matheus-bagliano / commits / 8a8da49728
Fork 0

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 <gitster@pobox.com> Signed-off-by: Taylor Blau <me@ttaylorr.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed Apr 24, 2020 at 11:11 UTC 8a8da49728b82a54e0f76c6cceba65be18095493
1 file changed +17 -53
t/t5537-fetch-shallow.sh
+17 -53
@@ -16,7 +16,7 @@ test_expect_success 'setup' '
16 commit 3 &&
17 commit 4 &&
18 git config --global transfer.fsckObjects true &&
19 - test_oid_cache <<-EOF
19 + test_oid_cache <<-\EOF
20 perl sha1:s/0034shallow %s/0036unshallow %s/
21 perl sha256:s/004cshallow %s/004eunshallow %s/
22 EOF
@@ -25,10 +25,7 @@ test_expect_success 'setup' '
25 test_expect_success 'setup shallow clone' '
26 git clone --no-local --depth=2 .git shallow &&
27 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 &&
29 test_cmp expect actual
30 '
31
@@ -38,10 +35,7 @@ test_expect_success 'clone from shallow clone' '
35 cd shallow2 &&
36 git fsck &&
37 git log --format=%s >actual &&
41 - cat <<EOF >expect &&
42 -4
43 -3
44 -EOF
38 + test_write_lines 4 3 >expect &&
39 test_cmp expect actual
40 )
41 '
@@ -56,11 +50,7 @@ test_expect_success 'fetch from shallow clone' '
50 git fetch &&
51 git fsck &&
52 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 &&
54 test_cmp expect actual
55 )
56 '
@@ -75,10 +65,7 @@ test_expect_success 'fetch --depth from shallow clone' '
65 git fetch --depth=2 &&
66 git fsck &&
67 git log --format=%s origin/master >actual &&
78 - cat <<EOF >expect &&
79 -6
80 -5
81 -EOF
68 + test_write_lines 6 5 >expect &&
69 test_cmp expect actual
70 )
71 '
@@ -89,12 +76,7 @@ test_expect_success 'fetch --unshallow from shallow clone' '
76 git fetch --unshallow &&
77 git fsck &&
78 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 &&
80 test_cmp expect actual
81 )
82 '
@@ -111,15 +93,10 @@ test_expect_success 'fetch something upstream has but hidden by clients shallow
93 git fetch ../.git +refs/heads/master:refs/remotes/top/master &&
94 git fsck &&
95 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 &&
97 test_cmp expect actual
98 ) &&
99 git --git-dir=shallow2/.git cat-file blob $(echo 1|git hash-object --stdin) >/dev/null
122 -
100 '
101
102 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' '
110 cd notshallow &&
111 git fetch ../shallow/.git refs/heads/*:refs/remotes/shallow/*&&
112 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 &&
114 test_cmp expect.refs actual.refs &&
115 git log --format=%s shallow/no-shallow >actual &&
141 - cat <<EOF >expect &&
142 -no-shallow
143 -EOF
116 + echo no-shallow >expect &&
117 test_cmp expect actual
118 )
119 '
@@ -158,21 +131,15 @@ test_expect_success 'fetch --update-shallow' '
131 git fetch --update-shallow ../shallow/.git refs/heads/*:refs/remotes/shallow/* &&
132 git fsck &&
133 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
140 test_cmp expect.refs actual.refs &&
141 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 &&
143 test_cmp expect actual
144 )
145 '
@@ -183,10 +150,7 @@ test_expect_success POSIXPERM,SANITY 'shallow fetch from a read-only repo' '
150 find read-only.git -print | xargs chmod -w &&
151 git clone --no-local --depth=2 read-only.git from-read-only &&
152 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 &&
154 test_cmp expect actual
155 '
156