t5411: refactor check of refs using test_cmp_refs

Add new helper 'test_cmp_refs' to check references in a repository. Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jiang Xin committed Jan 20, 2021 at 21:53 UTC 822ee894f621674610a36cc9a84a9ffbbb8fb6bb
31 files changed +126 -264
t/t5411/common-functions.sh
+15
@@ -59,3 +59,18 @@ filter_out_user_friendly_and_stable_output () {
59 make_user_friendly_and_stable_output |
60 sed -n ${1+"$@"}
61 }
62 +
63 +test_cmp_refs () {
64 + indir=
65 + if test "$1" = "-C"
66 + then
67 + shift
68 + indir="$1"
69 + shift
70 + fi
71 + indir=${indir:+"$indir"/}
72 + cat >show-ref.expect &&
73 + git ${indir:+ -C "$indir"} show-ref >show-ref.pristine &&
74 + make_user_friendly_and_stable_output <show-ref.pristine >show-ref.filtered &&
75 + test_cmp show-ref.expect show-ref.filtered
76 +}
t/t5411/once-0010-report-status-v1.sh
+1 -4
@@ -83,12 +83,9 @@ test_expect_success "proc-receive: report status v1" '
83 EOF
84 test_cmp expect actual &&
85
86 - git -C "$upstream" show-ref >out &&
87 - make_user_friendly_and_stable_output <out >actual &&
88 - cat >expect <<-EOF &&
86 + test_cmp_refs -C "$upstream" <<-EOF
87 <COMMIT-A> refs/for/main/topic1
88 <COMMIT-A> refs/heads/foo
89 <COMMIT-B> refs/heads/main
90 EOF
93 - test_cmp expect actual
91 '
t/t5411/test-0000-standard-git-push.sh
+8 -16
@@ -19,13 +19,11 @@ test_expect_success "git-push ($PROTOCOL)" '
19 * [new branch] HEAD -> next
20 EOF
21 test_cmp expect actual &&
22 - git -C "$upstream" show-ref >out &&
23 - make_user_friendly_and_stable_output <out >actual &&
24 - cat >expect <<-EOF &&
22 +
23 + test_cmp_refs -C "$upstream" <<-EOF
24 <COMMIT-B> refs/heads/main
25 <COMMIT-A> refs/heads/next
26 EOF
28 - test_cmp expect actual
27 '
28
29 # Refs of upstream : main(B) next(A)
@@ -46,13 +44,11 @@ test_expect_success "git-push --atomic ($PROTOCOL)" '
44 ! [rejected] <COMMIT-B> -> next (atomic push failed)
45 EOF
46 test_cmp expect actual &&
49 - git -C "$upstream" show-ref >out &&
50 - make_user_friendly_and_stable_output <out >actual &&
51 - cat >expect <<-EOF &&
47 +
48 + test_cmp_refs -C "$upstream" <<-EOF
49 <COMMIT-B> refs/heads/main
50 <COMMIT-A> refs/heads/next
51 EOF
55 - test_cmp expect actual
52 '
53
54 # Refs of upstream : main(B) next(A)
@@ -77,13 +73,11 @@ test_expect_success "non-fast-forward git-push ($PROTOCOL)" '
73 ! [rejected] main -> main (non-fast-forward)
74 EOF
75 test_cmp expect actual &&
80 - git -C "$upstream" show-ref >out &&
81 - make_user_friendly_and_stable_output <out >actual &&
82 - cat >expect <<-EOF &&
76 +
77 + test_cmp_refs -C "$upstream" <<-EOF
78 <COMMIT-B> refs/heads/main
79 <COMMIT-B> refs/heads/next
80 EOF
86 - test_cmp expect actual
81 '
82
83 # Refs of upstream : main(B) next(B)
@@ -119,15 +113,13 @@ test_expect_success "git-push -f ($PROTOCOL)" '
113 * [new branch] HEAD -> a/b/c
114 EOF
115 test_cmp expect actual &&
122 - git -C "$upstream" show-ref >out &&
123 - make_user_friendly_and_stable_output <out >actual &&
124 - cat >expect <<-EOF &&
116 +
117 + test_cmp_refs -C "$upstream" <<-EOF
118 <COMMIT-A> refs/heads/a/b/c
119 <COMMIT-A> refs/heads/main
120 <COMMIT-A> refs/review/main/topic
121 <TAG-v123> refs/tags/v123
122 EOF
130 - test_cmp expect actual
123 '
124
125 # Refs of upstream : main(A) tags/v123 refs/review/main/topic(A) a/b/c(A)
t/t5411/test-0001-standard-git-push--porcelain.sh
+8 -16
@@ -20,13 +20,11 @@ test_expect_success "git-push ($PROTOCOL/porcelain)" '
20 Done
21 EOF
22 test_cmp expect actual &&
23 - git -C "$upstream" show-ref >out &&
24 - make_user_friendly_and_stable_output <out >actual &&
25 - cat >expect <<-EOF &&
23 +
24 + test_cmp_refs -C "$upstream" <<-EOF
25 <COMMIT-B> refs/heads/main
26 <COMMIT-A> refs/heads/next
27 EOF
29 - test_cmp expect actual
28 '
29
30 # Refs of upstream : main(B) next(A)
@@ -48,13 +46,11 @@ test_expect_success "git-push --atomic ($PROTOCOL/porcelain)" '
46 ! <COMMIT-B>:refs/heads/next [rejected] (atomic push failed)
47 EOF
48 test_cmp expect actual &&
51 - git -C "$upstream" show-ref >out &&
52 - make_user_friendly_and_stable_output <out >actual &&
53 - cat >expect <<-EOF &&
49 +
50 + test_cmp_refs -C "$upstream" <<-EOF
51 <COMMIT-B> refs/heads/main
52 <COMMIT-A> refs/heads/next
53 EOF
57 - test_cmp expect actual
54 '
55
56 # Refs of upstream : main(B) next(A)
@@ -80,13 +76,11 @@ test_expect_success "non-fast-forward git-push ($PROTOCOL/porcelain)" '
76 Done
77 EOF
78 test_cmp expect actual &&
83 - git -C "$upstream" show-ref >out &&
84 - make_user_friendly_and_stable_output <out >actual &&
85 - cat >expect <<-EOF &&
79 +
80 + test_cmp_refs -C "$upstream" <<-EOF
81 <COMMIT-B> refs/heads/main
82 <COMMIT-B> refs/heads/next
83 EOF
89 - test_cmp expect actual
84 '
85
86 # Refs of upstream : main(B) next(B)
@@ -123,15 +117,13 @@ test_expect_success "git-push -f ($PROTOCOL/porcelain)" '
117 Done
118 EOF
119 test_cmp expect actual &&
126 - git -C "$upstream" show-ref >out &&
127 - make_user_friendly_and_stable_output <out >actual &&
128 - cat >expect <<-EOF &&
120 +
121 + test_cmp_refs -C "$upstream" <<-EOF
122 <COMMIT-A> refs/heads/a/b/c
123 <COMMIT-A> refs/heads/main
124 <COMMIT-A> refs/review/main/topic
125 <TAG-v123> refs/tags/v123
126 EOF
134 - test_cmp expect actual
127 '
128
129 # Refs of upstream : main(A) tags/v123 refs/review/main/topic(A) a/b/c(A)
t/t5411/test-0002-pre-receive-declined.sh
+2 -4
@@ -20,12 +20,10 @@ test_expect_success "git-push is declined ($PROTOCOL)" '
20 ! [remote rejected] HEAD -> next (pre-receive hook declined)
21 EOF
22 test_cmp expect actual &&
23 - git -C "$upstream" show-ref >out &&
24 - make_user_friendly_and_stable_output <out >actual &&
25 - cat >expect <<-EOF &&
23 +
24 + test_cmp_refs -C "$upstream" <<-EOF
25 <COMMIT-A> refs/heads/main
26 EOF
28 - test_cmp expect actual
27 '
28
29 test_expect_success "cleanup ($PROTOCOL)" '
t/t5411/test-0003-pre-receive-declined--porcelain.sh
+2 -4
@@ -21,12 +21,10 @@ test_expect_success "git-push is declined ($PROTOCOL/porcelain)" '
21 Done
22 EOF
23 test_cmp expect actual &&
24 - git -C "$upstream" show-ref >out &&
25 - make_user_friendly_and_stable_output <out >actual &&
26 - cat >expect <<-EOF &&
24 +
25 + test_cmp_refs -C "$upstream" <<-EOF
26 <COMMIT-A> refs/heads/main
27 EOF
29 - test_cmp expect actual
28 '
29
30 test_expect_success "cleanup ($PROTOCOL/porcelain)" '
t/t5411/test-0011-no-hook-error.sh
+4 -8
@@ -19,13 +19,11 @@ test_expect_success "proc-receive: no hook, fail to push special ref ($PROTOCOL)
19 ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook)
20 EOF
21 test_cmp expect actual &&
22 - git -C "$upstream" show-ref >out &&
23 - make_user_friendly_and_stable_output <out >actual &&
24 - cat >expect <<-EOF &&
22 +
23 + test_cmp_refs -C "$upstream" <<-EOF
24 <COMMIT-A> refs/heads/main
25 <COMMIT-A> refs/heads/next
26 EOF
28 - test_cmp expect actual
27 '
28
29 # Refs of upstream : main(A) next(A)
@@ -55,10 +53,8 @@ test_expect_success "proc-receive: no hook, all failed for atomic push ($PROTOCO
53 ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook)
54 EOF
55 test_cmp expect actual &&
58 - git -C "$upstream" show-ref >out &&
59 - make_user_friendly_and_stable_output <out >actual &&
60 - cat >expect <<-EOF &&
56 +
57 + test_cmp_refs -C "$upstream" <<-EOF
58 <COMMIT-A> refs/heads/main
59 EOF
63 - test_cmp expect actual
60 '
t/t5411/test-0012-no-hook-error--porcelain.sh
+4 -8
@@ -20,13 +20,11 @@ test_expect_success "proc-receive: no hook, fail to push special ref ($PROTOCOL/
20 Done
21 EOF
22 test_cmp expect actual &&
23 - git -C "$upstream" show-ref >out &&
24 - make_user_friendly_and_stable_output <out >actual &&
25 - cat >expect <<-EOF &&
23 +
24 + test_cmp_refs -C "$upstream" <<-EOF
25 <COMMIT-A> refs/heads/main
26 <COMMIT-A> refs/heads/next
27 EOF
29 - test_cmp expect actual
28 '
29
30 # Refs of upstream : main(A) next(A)
@@ -57,10 +55,8 @@ test_expect_success "proc-receive: no hook, all failed for atomic push ($PROTOCO
55 Done
56 EOF
57 test_cmp expect actual &&
60 - git -C "$upstream" show-ref >out &&
61 - make_user_friendly_and_stable_output <out >actual &&
62 - cat >expect <<-EOF &&
58 +
59 + test_cmp_refs -C "$upstream" <<-EOF
60 <COMMIT-A> refs/heads/main
61 EOF
65 - test_cmp expect actual
62 '
t/t5411/test-0013-bad-protocol.sh
+9 -36
@@ -34,12 +34,9 @@ test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL)" '
34 EOF
35 test_cmp expect actual-error &&
36
37 - git -C "$upstream" show-ref >out &&
38 - make_user_friendly_and_stable_output <out >actual &&
39 - cat >expect <<-EOF &&
37 + test_cmp_refs -C "$upstream" <<-EOF
38 <COMMIT-A> refs/heads/main
39 EOF
42 - test_cmp expect actual
40 '
41
42 test_expect_success "setup proc-receive hook (hook --die-read-version, $PROTOCOL)" '
@@ -68,12 +65,9 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-version, $PROTO
65 grep "remote: fatal: die with the --die-read-version option" out-$test_count &&
66 grep "remote: error: fail to negotiate version with proc-receive hook" out-$test_count &&
67
71 - git -C "$upstream" show-ref >out &&
72 - make_user_friendly_and_stable_output <out >actual &&
73 - cat >expect <<-EOF &&
68 + test_cmp_refs -C "$upstream" <<-EOF
69 <COMMIT-A> refs/heads/main
70 EOF
76 - test_cmp expect actual
71 '
72
73 test_expect_success "setup proc-receive hook (hook --die-write-version, $PROTOCOL)" '
@@ -102,12 +96,9 @@ test_expect_success "proc-receive: bad protocol (hook --die-write-version, $PROT
96 grep "remote: fatal: die with the --die-write-version option" out-$test_count &&
97 grep "remote: error: fail to negotiate version with proc-receive hook" out-$test_count &&
98
105 - git -C "$upstream" show-ref >out &&
106 - make_user_friendly_and_stable_output <out >actual &&
107 - cat >expect <<-EOF &&
99 + test_cmp_refs -C "$upstream" <<-EOF
100 <COMMIT-A> refs/heads/main
101 EOF
110 - test_cmp expect actual
102 '
103
104 test_expect_success "setup proc-receive hook (hook --die-read-commands, $PROTOCOL)" '
@@ -135,12 +126,9 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-commands, $PROT
126 test_cmp expect actual &&
127 grep "remote: fatal: die with the --die-read-commands option" out-$test_count &&
128
138 - git -C "$upstream" show-ref >out &&
139 - make_user_friendly_and_stable_output <out >actual &&
140 - cat >expect <<-EOF &&
129 + test_cmp_refs -C "$upstream" <<-EOF
130 <COMMIT-A> refs/heads/main
131 EOF
143 - test_cmp expect actual
132 '
133
134 test_expect_success "setup proc-receive hook (hook --die-read-push-options, $PROTOCOL)" '
@@ -170,12 +158,9 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-push-options, $
158 test_cmp expect actual &&
159 grep "remote: fatal: die with the --die-read-push-options option" out-$test_count &&
160
173 - git -C "$upstream" show-ref >out &&
174 - make_user_friendly_and_stable_output <out >actual &&
175 - cat >expect <<-EOF &&
161 + test_cmp_refs -C "$upstream" <<-EOF
162 <COMMIT-A> refs/heads/main
163 EOF
178 - test_cmp expect actual
164 '
165
166 test_expect_success "setup proc-receive hook (hook --die-write-report, $PROTOCOL)" '
@@ -203,12 +188,9 @@ test_expect_success "proc-receive: bad protocol (hook --die-write-report, $PROTO
188 test_cmp expect actual &&
189 grep "remote: fatal: die with the --die-write-report option" out-$test_count &&
190
206 - git -C "$upstream" show-ref >out &&
207 - make_user_friendly_and_stable_output <out >actual &&
208 - cat >expect <<-EOF &&
191 + test_cmp_refs -C "$upstream" <<-EOF
192 <COMMIT-A> refs/heads/main
193 EOF
211 - test_cmp expect actual
194 '
195
196 test_expect_success "setup proc-receive hook (no report, $PROTOCOL)" '
@@ -240,13 +222,10 @@ test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL)" '
222 EOF
223 test_cmp expect actual &&
224
243 - git -C "$upstream" show-ref >out &&
244 - make_user_friendly_and_stable_output <out >actual &&
245 - cat >expect <<-EOF &&
225 + test_cmp_refs -C "$upstream" <<-EOF
226 <COMMIT-A> refs/heads/main
227 <COMMIT-A> refs/heads/next
228 EOF
249 - test_cmp expect actual
229 '
230
231 # Refs of upstream : main(A) next(A)
@@ -284,12 +263,9 @@ test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL)" '
263 EOF
264 test_cmp expect actual &&
265
287 - git -C "$upstream" show-ref >out &&
288 - make_user_friendly_and_stable_output <out >actual &&
289 - cat >expect <<-EOF &&
266 + test_cmp_refs -C "$upstream" <<-EOF
267 <COMMIT-A> refs/heads/main
268 EOF
292 - test_cmp expect actual
269 '
270
271 test_expect_success "setup proc-receive hook (unknown status, $PROTOCOL)" '
@@ -320,10 +296,7 @@ test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL)" '
296 EOF
297 test_cmp expect actual &&
298
323 - git -C "$upstream" show-ref >out &&
324 - make_user_friendly_and_stable_output <out >actual &&
325 - cat >expect <<-EOF &&
299 + test_cmp_refs -C "$upstream" <<-EOF
300 <COMMIT-A> refs/heads/main
301 EOF
328 - test_cmp expect actual
302 '
t/t5411/test-0014-bad-protocol--porcelain.sh
+9 -36
@@ -34,12 +34,9 @@ test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL/porc
34 EOF
35 test_cmp expect actual-error &&
36
37 - git -C "$upstream" show-ref >out &&
38 - make_user_friendly_and_stable_output <out >actual &&
39 - cat >expect <<-EOF &&
37 + test_cmp_refs -C "$upstream" <<-EOF
38 <COMMIT-A> refs/heads/main
39 EOF
42 - test_cmp expect actual
40 '
41
42 test_expect_success "setup proc-receive hook (hook --die-read-version, $PROTOCOL/porcelain)" '
@@ -68,12 +65,9 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-version, $PROTO
65 grep "remote: fatal: die with the --die-read-version option" out-$test_count &&
66 grep "remote: error: fail to negotiate version with proc-receive hook" out-$test_count &&
67
71 - git -C "$upstream" show-ref >out &&
72 - make_user_friendly_and_stable_output <out >actual &&
73 - cat >expect <<-EOF &&
68 + test_cmp_refs -C "$upstream" <<-EOF
69 <COMMIT-A> refs/heads/main
70 EOF
76 - test_cmp expect actual
71 '
72
73 test_expect_success "setup proc-receive hook (hook --die-write-version, $PROTOCOL/porcelain)" '
@@ -102,12 +96,9 @@ test_expect_success "proc-receive: bad protocol (hook --die-write-version, $PROT
96 grep "remote: fatal: die with the --die-write-version option" out-$test_count &&
97 grep "remote: error: fail to negotiate version with proc-receive hook" out-$test_count &&
98
105 - git -C "$upstream" show-ref >out &&
106 - make_user_friendly_and_stable_output <out >actual &&
107 - cat >expect <<-EOF &&
99 + test_cmp_refs -C "$upstream" <<-EOF
100 <COMMIT-A> refs/heads/main
101 EOF
110 - test_cmp expect actual
102 '
103
104 test_expect_success "setup proc-receive hook (hook --die-read-commands, $PROTOCOL/porcelain)" '
@@ -135,12 +126,9 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-commands, $PROT
126 test_cmp expect actual &&
127 grep "remote: fatal: die with the --die-read-commands option" out-$test_count &&
128
138 - git -C "$upstream" show-ref >out &&
139 - make_user_friendly_and_stable_output <out >actual &&
140 - cat >expect <<-EOF &&
129 + test_cmp_refs -C "$upstream" <<-EOF
130 <COMMIT-A> refs/heads/main
131 EOF
143 - test_cmp expect actual
132 '
133
134 test_expect_success "setup proc-receive hook (hook --die-read-push-options, $PROTOCOL/porcelain)" '
@@ -170,12 +158,9 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-push-options, $
158 test_cmp expect actual &&
159 grep "remote: fatal: die with the --die-read-push-options option" out-$test_count &&
160
173 - git -C "$upstream" show-ref >out &&
174 - make_user_friendly_and_stable_output <out >actual &&
175 - cat >expect <<-EOF &&
161 + test_cmp_refs -C "$upstream" <<-EOF
162 <COMMIT-A> refs/heads/main
163 EOF
178 - test_cmp expect actual
164 '
165
166 test_expect_success "setup proc-receive hook (hook --die-write-report, $PROTOCOL/porcelain)" '
@@ -203,12 +188,9 @@ test_expect_success "proc-receive: bad protocol (hook --die-write-report, $PROTO
188 test_cmp expect actual &&
189 grep "remote: fatal: die with the --die-write-report option" out-$test_count &&
190
206 - git -C "$upstream" show-ref >out &&
207 - make_user_friendly_and_stable_output <out >actual &&
208 - cat >expect <<-EOF &&
191 + test_cmp_refs -C "$upstream" <<-EOF
192 <COMMIT-A> refs/heads/main
193 EOF
211 - test_cmp expect actual
194 '
195
196 test_expect_success "setup proc-receive hook (no report, $PROTOCOL/porcelain)" '
@@ -241,13 +223,10 @@ test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL/porcelain)
223 EOF
224 test_cmp expect actual &&
225
244 - git -C "$upstream" show-ref >out &&
245 - make_user_friendly_and_stable_output <out >actual &&
246 - cat >expect <<-EOF &&
226 + test_cmp_refs -C "$upstream" <<-EOF
227 <COMMIT-A> refs/heads/main
228 <COMMIT-A> refs/heads/next
229 EOF
250 - test_cmp expect actual
230 '
231
232 # Refs of upstream : main(A) next(A)
@@ -285,12 +264,9 @@ test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL/porcelain)" '
264 EOF
265 test_cmp expect actual &&
266
288 - git -C "$upstream" show-ref >out &&
289 - make_user_friendly_and_stable_output <out >actual &&
290 - cat >expect <<-EOF &&
267 + test_cmp_refs -C "$upstream" <<-EOF
268 <COMMIT-A> refs/heads/main
269 EOF
293 - test_cmp expect actual
270 '
271
272 test_expect_success "setup proc-receive hook (unknown status, $PROTOCOL/porcelain)" '
@@ -322,10 +298,7 @@ test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL/porce
298 EOF
299 test_cmp expect actual &&
300
325 - git -C "$upstream" show-ref >out &&
326 - make_user_friendly_and_stable_output <out >actual &&
327 - cat >expect <<-EOF &&
301 + test_cmp_refs -C "$upstream" <<-EOF
302 <COMMIT-A> refs/heads/main
303 EOF
330 - test_cmp expect actual
304 '
t/t5411/test-0020-report-ng.sh
+4 -8
@@ -24,12 +24,10 @@ test_expect_success "proc-receive: fail to update (ng, no message, $PROTOCOL)" '
24 ! [remote rejected] HEAD -> refs/for/main/topic (failed)
25 EOF
26 test_cmp expect actual &&
27 - git -C "$upstream" show-ref >out &&
28 - make_user_friendly_and_stable_output <out >actual &&
29 - cat >expect <<-EOF &&
27 +
28 + test_cmp_refs -C "$upstream" <<-EOF
29 <COMMIT-A> refs/heads/main
30 EOF
32 - test_cmp expect actual
31 '
32
33 test_expect_success "setup proc-receive hook (ng message, $PROTOCOL)" '
@@ -58,10 +56,8 @@ test_expect_success "proc-receive: fail to update (ng, with message, $PROTOCOL)"
56 ! [remote rejected] HEAD -> refs/for/main/topic (error msg)
57 EOF
58 test_cmp expect actual &&
61 - git -C "$upstream" show-ref >out &&
62 - make_user_friendly_and_stable_output <out >actual &&
63 - cat >expect <<-EOF &&
59 +
60 + test_cmp_refs -C "$upstream" <<-EOF
61 <COMMIT-A> refs/heads/main
62 EOF
66 - test_cmp expect actual
63 '
t/t5411/test-0021-report-ng--porcelain.sh
+4 -8
@@ -25,12 +25,10 @@ test_expect_success "proc-receive: fail to update (ng, no message, $PROTOCOL/por
25 Done
26 EOF
27 test_cmp expect actual &&
28 - git -C "$upstream" show-ref >out &&
29 - make_user_friendly_and_stable_output <out >actual &&
30 - cat >expect <<-EOF &&
28 +
29 + test_cmp_refs -C "$upstream" <<-EOF
30 <COMMIT-A> refs/heads/main
31 EOF
33 - test_cmp expect actual
32 '
33
34 test_expect_success "setup proc-receive hook (ng message, $PROTOCOL/porcelain)" '
@@ -60,10 +58,8 @@ test_expect_success "proc-receive: fail to update (ng, with message, $PROTOCOL/p
58 Done
59 EOF
60 test_cmp expect actual &&
63 - git -C "$upstream" show-ref >out &&
64 - make_user_friendly_and_stable_output <out >actual &&
65 - cat >expect <<-EOF &&
61 +
62 + test_cmp_refs -C "$upstream" <<-EOF
63 <COMMIT-A> refs/heads/main
64 EOF
68 - test_cmp expect actual
65 '
t/t5411/test-0022-report-unexpect-ref.sh
+2 -4
@@ -30,12 +30,10 @@ test_expect_success "proc-receive: report unexpected ref ($PROTOCOL)" '
30 ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status)
31 EOF
32 test_cmp expect actual &&
33 - git -C "$upstream" show-ref >out &&
34 - make_user_friendly_and_stable_output <out >actual &&
35 - cat >expect <<-EOF &&
33 +
34 + test_cmp_refs -C "$upstream" <<-EOF
35 <COMMIT-B> refs/heads/main
36 EOF
38 - test_cmp expect actual
37 '
38
39 # Refs of upstream : main(B)
t/t5411/test-0023-report-unexpect-ref--porcelain.sh
+2 -4
@@ -31,12 +31,10 @@ test_expect_success "proc-receive: report unexpected ref ($PROTOCOL/porcelain)"
31 Done
32 EOF
33 test_cmp expect actual &&
34 - git -C "$upstream" show-ref >out &&
35 - make_user_friendly_and_stable_output <out >actual &&
36 - cat >expect <<-EOF &&
34 +
35 + test_cmp_refs -C "$upstream" <<-EOF
36 <COMMIT-B> refs/heads/main
37 EOF
39 - test_cmp expect actual
38 '
39
40 # Refs of upstream : main(B)
t/t5411/test-0024-report-unknown-ref.sh
+2 -4
@@ -25,10 +25,8 @@ test_expect_success "proc-receive: report unknown reference ($PROTOCOL)" '
25 ! [remote rejected] HEAD -> refs/for/a/b/c/my/topic (proc-receive failed to report status)
26 EOF
27 test_cmp expect actual &&
28 - git -C "$upstream" show-ref >out &&
29 - make_user_friendly_and_stable_output <out >actual &&
30 - cat >expect <<-EOF &&
28 +
29 + test_cmp_refs -C "$upstream" <<-EOF
30 <COMMIT-A> refs/heads/main
31 EOF
33 - test_cmp expect actual
32 '
t/t5411/test-0025-report-unknown-ref--porcelain.sh
+2 -4
@@ -26,10 +26,8 @@ test_expect_success "proc-receive: report unknown reference ($PROTOCOL/porcelain
26 Done
27 EOF
28 test_cmp expect actual &&
29 - git -C "$upstream" show-ref >out &&
30 - make_user_friendly_and_stable_output <out >actual &&
31 - cat >expect <<-EOF &&
29 +
30 + test_cmp_refs -C "$upstream" <<-EOF
31 <COMMIT-A> refs/heads/main
32 EOF
34 - test_cmp expect actual
33 '
t/t5411/test-0026-push-options.sh
+6 -12
@@ -20,12 +20,10 @@ test_expect_success "proc-receive: not support push options ($PROTOCOL)" '
20 make_user_friendly_and_stable_output <out-$test_count >actual &&
21 test_i18ngrep "fatal: the receiving end does not support push options" \
22 actual &&
23 - git -C "$upstream" show-ref >out &&
24 - make_user_friendly_and_stable_output <out >actual &&
25 - cat >expect <<-EOF &&
23 +
24 + test_cmp_refs -C "$upstream" <<-EOF
25 <COMMIT-A> refs/heads/main
26 EOF
28 - test_cmp expect actual
27 '
28
29 test_expect_success "enable push options ($PROTOCOL)" '
@@ -69,13 +67,11 @@ test_expect_success "proc-receive: ignore push-options for version 0 ($PROTOCOL)
67 * [new reference] HEAD -> refs/for/main/topic
68 EOF
69 test_cmp expect actual &&
72 - git -C "$upstream" show-ref >out &&
73 - make_user_friendly_and_stable_output <out >actual &&
74 - cat >expect <<-EOF &&
70 +
71 + test_cmp_refs -C "$upstream" <<-EOF
72 <COMMIT-A> refs/heads/main
73 <COMMIT-A> refs/heads/next
74 EOF
78 - test_cmp expect actual
75 '
76
77 test_expect_success "restore proc-receive hook ($PROTOCOL)" '
@@ -123,13 +119,11 @@ test_expect_success "proc-receive: push with options ($PROTOCOL)" '
119 * [new reference] HEAD -> refs/for/main/topic
120 EOF
121 test_cmp expect actual &&
126 - git -C "$upstream" show-ref >out &&
127 - make_user_friendly_and_stable_output <out >actual &&
128 - cat >expect <<-EOF &&
122 +
123 + test_cmp_refs -C "$upstream" <<-EOF
124 <COMMIT-A> refs/heads/main
125 <COMMIT-A> refs/heads/next
126 EOF
132 - test_cmp expect actual
127 '
128
129 # Refs of upstream : main(A) next(A)
t/t5411/test-0027-push-options--porcelain.sh
+6 -12
@@ -21,12 +21,10 @@ test_expect_success "proc-receive: not support push options ($PROTOCOL/porcelain
21 make_user_friendly_and_stable_output <out-$test_count >actual &&
22 test_i18ngrep "fatal: the receiving end does not support push options" \
23 actual &&
24 - git -C "$upstream" show-ref >out &&
25 - make_user_friendly_and_stable_output <out >actual &&
26 - cat >expect <<-EOF &&
24 +
25 + test_cmp_refs -C "$upstream" <<-EOF
26 <COMMIT-A> refs/heads/main
27 EOF
29 - test_cmp expect actual
28 '
29
30 test_expect_success "enable push options ($PROTOCOL/porcelain)" '
@@ -72,13 +70,11 @@ test_expect_success "proc-receive: ignore push-options for version 0 ($PROTOCOL/
70 Done
71 EOF
72 test_cmp expect actual &&
75 - git -C "$upstream" show-ref >out &&
76 - make_user_friendly_and_stable_output <out >actual &&
77 - cat >expect <<-EOF &&
73 +
74 + test_cmp_refs -C "$upstream" <<-EOF
75 <COMMIT-A> refs/heads/main
76 <COMMIT-A> refs/heads/next
77 EOF
81 - test_cmp expect actual
78 '
79
80 test_expect_success "restore proc-receive hook ($PROTOCOL/porcelain)" '
@@ -128,13 +124,11 @@ test_expect_success "proc-receive: push with options ($PROTOCOL/porcelain)" '
124 Done
125 EOF
126 test_cmp expect actual &&
131 - git -C "$upstream" show-ref >out &&
132 - make_user_friendly_and_stable_output <out >actual &&
133 - cat >expect <<-EOF &&
127 +
128 + test_cmp_refs -C "$upstream" <<-EOF
129 <COMMIT-A> refs/heads/main
130 <COMMIT-A> refs/heads/next
131 EOF
137 - test_cmp expect actual
132 '
133
134 # Refs of upstream : main(A) next(A)
t/t5411/test-0030-report-ok.sh
+2 -4
@@ -26,10 +26,8 @@ test_expect_success "proc-receive: ok ($PROTOCOL)" '
26 * [new reference] HEAD -> refs/for/main/topic
27 EOF
28 test_cmp expect actual &&
29 - git -C "$upstream" show-ref >out &&
30 - make_user_friendly_and_stable_output <out >actual &&
31 - cat >expect <<-EOF &&
29 +
30 + test_cmp_refs -C "$upstream" <<-EOF
31 <COMMIT-A> refs/heads/main
32 EOF
34 - test_cmp expect actual
33 '
t/t5411/test-0031-report-ok--porcelain.sh
+2 -4
@@ -27,10 +27,8 @@ test_expect_success "proc-receive: ok ($PROTOCOL/porcelain)" '
27 Done
28 EOF
29 test_cmp expect actual &&
30 - git -C "$upstream" show-ref >out &&
31 - make_user_friendly_and_stable_output <out >actual &&
32 - cat >expect <<-EOF &&
30 +
31 + test_cmp_refs -C "$upstream" <<-EOF
32 <COMMIT-A> refs/heads/main
33 EOF
35 - test_cmp expect actual
34 '
t/t5411/test-0032-report-with-options.sh
+1 -4
@@ -247,10 +247,7 @@ test_expect_success "proc-receive: report with multiple rewrites ($PROTOCOL)" '
247 EOF
248 test_cmp expect actual &&
249
250 - git -C "$upstream" show-ref >out &&
251 - make_user_friendly_and_stable_output <out >actual &&
252 - cat >expect <<-EOF &&
250 + test_cmp_refs -C "$upstream" <<-EOF
251 <COMMIT-A> refs/heads/main
252 EOF
255 - test_cmp expect actual
253 '
t/t5411/test-0033-report-with-options--porcelain.sh
+1 -4
@@ -256,10 +256,7 @@ test_expect_success "proc-receive: report with multiple rewrites ($PROTOCOL/porc
256 EOF
257 test_cmp expect actual &&
258
259 - git -C "$upstream" show-ref >out &&
260 - make_user_friendly_and_stable_output <out >actual &&
261 - cat >expect <<-EOF &&
259 + test_cmp_refs -C "$upstream" <<-EOF
260 <COMMIT-A> refs/heads/main
261 EOF
264 - test_cmp expect actual
262 '
t/t5411/test-0034-report-ft.sh
+2 -4
@@ -28,13 +28,11 @@ test_expect_success "proc-receive: fall throught, let receive-pack to execute ($
28 * [new reference] <COMMIT-B> -> refs/for/main/topic
29 EOF
30 test_cmp expect actual &&
31 - git -C "$upstream" show-ref >out &&
32 - make_user_friendly_and_stable_output <out >actual &&
33 - cat >expect <<-EOF &&
31 +
32 + test_cmp_refs -C "$upstream" <<-EOF
33 <COMMIT-B> refs/for/main/topic
34 <COMMIT-A> refs/heads/main
35 EOF
37 - test_cmp expect actual
36 '
37
38 # Refs of upstream : main(A) refs/for/main/topic(A)
t/t5411/test-0035-report-ft--porcelain.sh
+2 -4
@@ -29,13 +29,11 @@ test_expect_success "proc-receive: fall throught, let receive-pack to execute ($
29 Done
30 EOF
31 test_cmp expect actual &&
32 - git -C "$upstream" show-ref >out &&
33 - make_user_friendly_and_stable_output <out >actual &&
34 - cat >expect <<-EOF &&
32 +
33 + test_cmp_refs -C "$upstream" <<-EOF
34 <COMMIT-B> refs/for/main/topic
35 <COMMIT-A> refs/heads/main
36 EOF
38 - test_cmp expect actual
37 '
38
39 # Refs of upstream : main(A) refs/for/main/topic(A)
t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh
+6 -12
@@ -65,12 +65,10 @@ test_expect_success "proc-receive: multiple rewrite for one ref, no refname for
65 <OID-A>..<OID-B> HEAD -> refs/changes/25/125/1
66 EOF
67 test_cmp expect actual &&
68 - git -C "$upstream" show-ref >out &&
69 - make_user_friendly_and_stable_output <out >actual &&
70 - cat >expect <<-EOF &&
68 +
69 + test_cmp_refs -C "$upstream" <<-EOF
70 <COMMIT-A> refs/heads/main
71 EOF
73 - test_cmp expect actual
72 '
73
74 test_expect_success "proc-receive: check remote-tracking #1 ($PROTOCOL)" '
@@ -142,12 +140,10 @@ test_expect_success "proc-receive: multiple rewrites for one ref, no refname for
140 + <OID-B>...<OID-A> HEAD -> refs/changes/25/125/1 (forced update)
141 EOF
142 test_cmp expect actual &&
145 - git -C "$upstream" show-ref >out &&
146 - make_user_friendly_and_stable_output <out >actual &&
147 - cat >expect <<-EOF &&
143 +
144 + test_cmp_refs -C "$upstream" <<-EOF
145 <COMMIT-A> refs/heads/main
146 EOF
150 - test_cmp expect actual
147 '
148
149 test_expect_success "proc-receive: check remote-tracking #2 ($PROTOCOL)" '
@@ -205,12 +201,10 @@ test_expect_success "proc-receive: multiple rewrites for one ref ($PROTOCOL)" '
201 <OID-A>..<OID-B> HEAD -> refs/changes/24/124/2
202 EOF
203 test_cmp expect actual &&
208 - git -C "$upstream" show-ref >out &&
209 - make_user_friendly_and_stable_output <out >actual &&
210 - cat >expect <<-EOF &&
204 +
205 + test_cmp_refs -C "$upstream" <<-EOF
206 <COMMIT-A> refs/heads/main
207 EOF
213 - test_cmp expect actual
208 '
209
210 test_expect_success "proc-receive: check remote-tracking #3 ($PROTOCOL)" '
t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh
+6 -12
@@ -51,12 +51,10 @@ test_expect_success "proc-receive: multiple rewrite for one ref, no refname for
51 Done
52 EOF
53 test_cmp expect actual &&
54 - git -C "$upstream" show-ref >out &&
55 - make_user_friendly_and_stable_output <out >actual &&
56 - cat >expect <<-EOF &&
54 +
55 + test_cmp_refs -C "$upstream" <<-EOF
56 <COMMIT-A> refs/heads/main
57 EOF
59 - test_cmp expect actual
58 '
59
60 test_expect_success "setup proc-receive hook (multiple rewrites for one ref, no refname for the 2nd rewrite, $PROTOCOL/porcelain)" '
@@ -114,12 +112,10 @@ test_expect_success "proc-receive: multiple rewrites for one ref, no refname for
112 Done
113 EOF
114 test_cmp expect actual &&
117 - git -C "$upstream" show-ref >out &&
118 - make_user_friendly_and_stable_output <out >actual &&
119 - cat >expect <<-EOF &&
115 +
116 + test_cmp_refs -C "$upstream" <<-EOF
117 <COMMIT-A> refs/heads/main
118 EOF
122 - test_cmp expect actual
119 '
120
121 test_expect_success "setup proc-receive hook (multiple rewrites for one ref, $PROTOCOL/porcelain)" '
@@ -163,10 +159,8 @@ test_expect_success "proc-receive: multiple rewrites for one ref ($PROTOCOL/porc
159 Done
160 EOF
161 test_cmp expect actual &&
166 - git -C "$upstream" show-ref >out &&
167 - make_user_friendly_and_stable_output <out >actual &&
168 - cat >expect <<-EOF &&
162 +
163 + test_cmp_refs -C "$upstream" <<-EOF
164 <COMMIT-A> refs/heads/main
165 EOF
171 - test_cmp expect actual
166 '
t/t5411/test-0038-report-mixed-refs.sh
+2 -4
@@ -65,15 +65,13 @@ test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL)" '
65 ! [remote rejected] HEAD -> refs/for/next/topic3 (proc-receive failed to report status)
66 EOF
67 test_cmp expect actual &&
68 - git -C "$upstream" show-ref >out &&
69 - make_user_friendly_and_stable_output <out >actual &&
70 - cat >expect <<-EOF &&
68 +
69 + test_cmp_refs -C "$upstream" <<-EOF
70 <COMMIT-A> refs/heads/bar
71 <COMMIT-A> refs/heads/baz
72 <COMMIT-A> refs/heads/foo
73 <COMMIT-B> refs/heads/main
74 EOF
76 - test_cmp expect actual
75 '
76
77 # Refs of upstream : main(B) foo(A) bar(A)) baz(A)
t/t5411/test-0039-report-mixed-refs--porcelain.sh
+2 -4
@@ -66,15 +66,13 @@ test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL/porcel
66 Done
67 EOF
68 test_cmp expect actual &&
69 - git -C "$upstream" show-ref >out &&
70 - make_user_friendly_and_stable_output <out >actual &&
71 - cat >expect <<-EOF &&
69 +
70 + test_cmp_refs -C "$upstream" <<-EOF
71 <COMMIT-A> refs/heads/bar
72 <COMMIT-A> refs/heads/baz
73 <COMMIT-A> refs/heads/foo
74 <COMMIT-B> refs/heads/main
75 EOF
77 - test_cmp expect actual
76 '
77
78 # Refs of upstream : main(B) foo(A) bar(A)) baz(A)
t/t5411/test-0040-process-all-refs.sh
+2 -4
@@ -92,14 +92,12 @@ test_expect_success "proc-receive: process all refs ($PROTOCOL)" '
92 + <OID-B>...<OID-A> HEAD -> refs/pull/124/head (forced update)
93 EOF
94 test_cmp expect actual &&
95 - git -C "$upstream" show-ref >out &&
96 - make_user_friendly_and_stable_output <out >actual &&
97 - cat >expect <<-EOF &&
95 +
96 + test_cmp_refs -C "$upstream" <<-EOF
97 <COMMIT-B> refs/heads/bar
98 <COMMIT-A> refs/heads/baz
99 <COMMIT-A> refs/heads/main
100 EOF
102 - test_cmp expect actual
101 '
102
103 # Refs of upstream : main(A) bar(A) baz(B)
t/t5411/test-0041-process-all-refs--porcelain.sh
+2 -4
@@ -93,14 +93,12 @@ test_expect_success "proc-receive: process all refs ($PROTOCOL/porcelain)" '
93 Done
94 EOF
95 test_cmp expect actual &&
96 - git -C "$upstream" show-ref >out &&
97 - make_user_friendly_and_stable_output <out >actual &&
98 - cat >expect <<-EOF &&
96 +
97 + test_cmp_refs -C "$upstream" <<-EOF
98 <COMMIT-B> refs/heads/bar
99 <COMMIT-A> refs/heads/baz
100 <COMMIT-A> refs/heads/main
101 EOF
103 - test_cmp expect actual
102 '
103
104 # Refs of upstream : main(A) bar(A) baz(B)
t/t5411/test-0050-proc-receive-refs-with-modifiers.sh
+6 -12
@@ -50,12 +50,10 @@ test_expect_success "proc-receive: update branch and new tag ($PROTOCOL)" '
50 * [new reference] v123 -> refs/pull/124/head
51 EOF
52 test_cmp expect actual &&
53 - git -C "$upstream" show-ref >out &&
54 - make_user_friendly_and_stable_output <out >actual &&
55 - cat >expect <<-EOF &&
53 +
54 + test_cmp_refs -C "$upstream" <<-EOF
55 <COMMIT-A> refs/heads/main
56 EOF
58 - test_cmp expect actual
57 '
58
59 # Refs of upstream : main(A)
@@ -63,14 +61,12 @@ test_expect_success "proc-receive: update branch and new tag ($PROTOCOL)" '
61 test_expect_success "setup upstream: create tags/v123 ($PROTOCOL)" '
62 git -C "$upstream" update-ref refs/heads/topic $A &&
63 git -C "$upstream" update-ref refs/tags/v123 $TAG &&
66 - git -C "$upstream" show-ref >out &&
67 - make_user_friendly_and_stable_output <out >actual &&
68 - cat >expect <<-EOF &&
64 +
65 + test_cmp_refs -C "$upstream" <<-EOF
66 <COMMIT-A> refs/heads/main
67 <COMMIT-A> refs/heads/topic
68 <TAG-v123> refs/tags/v123
69 EOF
73 - test_cmp expect actual
70 '
71
72 test_expect_success "setup proc-receive hook ($PROTOCOL)" '
@@ -125,11 +121,9 @@ test_expect_success "proc-receive: create/delete branch, and delete tag ($PROTOC
121 * [new reference] <COMMIT-A> -> refs/pull/124/head
122 EOF
123 test_cmp expect actual &&
128 - git -C "$upstream" show-ref >out &&
129 - make_user_friendly_and_stable_output <out >actual &&
130 - cat >expect <<-EOF &&
124 +
125 + test_cmp_refs -C "$upstream" <<-EOF
126 <COMMIT-A> refs/heads/main
127 <COMMIT-B> refs/heads/topic
128 EOF
134 - test_cmp expect actual
129 '