hook tests: use a modern style for "pre-push" tests

Indent the here-docs and use "test_cmp" instead of "diff" in tests added in ec55559f937 (push: Add support for pre-push hooks, 2013-01-13). Let's also use the more typical "expect" instead of "expected" to be consistent with the rest of the test file. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Feb 18, 2022 at 21:52 UTC 445401576787091ec78c0c5531027e7952668bfd
1 file changed +35 -36
t/t5571-pre-push-hook.sh
+35 -36
@@ -61,15 +61,15 @@ echo "$2" >>actual
61 cat >>actual
62 EOF
63
64 -cat >expected <<EOF
65 -parent1
66 -repo1
67 -refs/heads/main $COMMIT2 refs/heads/foreign $COMMIT1
68 -EOF
69 -
64 test_expect_success 'push with hook' '
65 + cat >expect <<-EOF &&
66 + parent1
67 + repo1
68 + refs/heads/main $COMMIT2 refs/heads/foreign $COMMIT1
69 + EOF
70 +
71 git push parent1 main:foreign &&
72 - diff expected actual
72 + test_cmp expect actual
73 '
74
75 test_expect_success 'add a branch' '
@@ -80,49 +80,48 @@ test_expect_success 'add a branch' '
80 COMMIT3="$(git rev-parse HEAD)"
81 export COMMIT3
82
83 -cat >expected <<EOF
84 -parent1
85 -repo1
86 -refs/heads/other $COMMIT3 refs/heads/foreign $COMMIT2
87 -EOF
88 -
83 test_expect_success 'push to default' '
84 + cat >expect <<-EOF &&
85 + parent1
86 + repo1
87 + refs/heads/other $COMMIT3 refs/heads/foreign $COMMIT2
88 + EOF
89 git push &&
91 - diff expected actual
90 + test_cmp expect actual
91 '
92
94 -cat >expected <<EOF
95 -parent1
96 -repo1
97 -refs/tags/one $COMMIT1 refs/tags/tag1 $ZERO_OID
98 -HEAD~ $COMMIT2 refs/heads/prev $ZERO_OID
99 -EOF
100 -
93 test_expect_success 'push non-branches' '
94 + cat >expect <<-EOF &&
95 + parent1
96 + repo1
97 + refs/tags/one $COMMIT1 refs/tags/tag1 $ZERO_OID
98 + HEAD~ $COMMIT2 refs/heads/prev $ZERO_OID
99 + EOF
100 +
101 git push parent1 one:tag1 HEAD~:refs/heads/prev &&
103 - diff expected actual
102 + test_cmp expect actual
103 '
104
106 -cat >expected <<EOF
107 -parent1
108 -repo1
109 -(delete) $ZERO_OID refs/heads/prev $COMMIT2
110 -EOF
111 -
105 test_expect_success 'push delete' '
106 + cat >expect <<-EOF &&
107 + parent1
108 + repo1
109 + (delete) $ZERO_OID refs/heads/prev $COMMIT2
110 + EOF
111 +
112 git push parent1 :prev &&
114 - diff expected actual
113 + test_cmp expect actual
114 '
115
117 -cat >expected <<EOF
118 -repo1
119 -repo1
120 -HEAD $COMMIT3 refs/heads/other $ZERO_OID
121 -EOF
122 -
116 test_expect_success 'push to URL' '
117 + cat >expect <<-EOF &&
118 + repo1
119 + repo1
120 + HEAD $COMMIT3 refs/heads/other $ZERO_OID
121 + EOF
122 +
123 git push repo1 HEAD &&
125 - diff expected actual
124 + test_cmp expect actual
125 '
126
127 test_expect_success 'set up many-ref tests' '