t/t3437: use named commits in the tests

Use the named commits in the tests so that they will still refer to the same commit if the setup gets changed in the future whereas 'branch~2' will change which commit it points to. Mentored-by: Christian Couder <chriscool@tuxfamily.org> Mentored-by: Phillip Wood <phillip.wood@dunelm.org.uk> Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Charvi Mendiratta <charvi077@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Charvi Mendiratta committed Feb 10, 2021 at 17:06 UTC 9c7650c45ce54ae1998b979703b9baa48406145c
1 file changed +10 -8
t/t3437-rebase-fixup-options.sh
+10 -8
@@ -70,6 +70,7 @@ test_expect_success 'setup' '
70 echo B1 >B &&
71 test_tick &&
72 git commit --fixup=HEAD -a &&
73 + git tag B1 &&
74 test_tick &&
75 git commit --allow-empty -F - <<-EOF &&
76 amend! B
@@ -91,6 +92,7 @@ test_expect_success 'setup' '
92 echo B2 >B &&
93 test_tick &&
94 FAKE_COMMIT_AMEND="edited squash" git commit --squash=HEAD -a &&
95 + git tag B2 &&
96 echo B3 >B &&
97 test_tick &&
98 git commit -a -F - <<-EOF &&
@@ -104,6 +106,7 @@ test_expect_success 'setup' '
106 $EMPTY
107 edited 3
108 EOF
109 + git tag B3 &&
110
111 GIT_AUTHOR_NAME="Rebase Author" &&
112 GIT_AUTHOR_EMAIL="rebase.author@example.com" &&
@@ -171,12 +174,12 @@ test_expect_success 'skipping fixup -C after fixup gives correct message' '
174 '
175
176 test_expect_success 'sequence of fixup, fixup -C & squash --signoff works' '
174 - git checkout --detach branch &&
177 + git checkout --detach B3 &&
178 FAKE_LINES="1 fixup 2 fixup_-C 3 fixup_-C 4 squash 5 fixup_-C 6" \
179 FAKE_COMMIT_AMEND=squashed \
180 FAKE_MESSAGE_COPY=actual-squash-message \
181 git -c commit.status=false rebase -ik --signoff A &&
179 - git diff-tree --exit-code --patch HEAD branch -- &&
182 + git diff-tree --exit-code --patch HEAD B3 -- &&
183 test_cmp_rev HEAD^ A &&
184 test_i18ncmp "$TEST_DIRECTORY/t3437/expected-squash-message" \
185 actual-squash-message
@@ -184,7 +187,7 @@ test_expect_success 'sequence of fixup, fixup -C & squash --signoff works' '
187
188 test_expect_success 'first fixup -C commented out in sequence fixup fixup -C fixup -C' '
189 test_when_finished "test_might_fail git rebase --abort" &&
187 - git checkout branch && git checkout --detach branch~2 &&
190 + git checkout --detach B2~ &&
191 git log -1 --pretty=format:%b >expected-message &&
192 FAKE_LINES="1 fixup 2 fixup_-C 3 fixup_-C 4" git rebase -i A &&
193 test_cmp_rev HEAD^ A &&
@@ -194,12 +197,11 @@ test_expect_success 'first fixup -C commented out in sequence fixup fixup -C fix
197 test_expect_success 'multiple fixup -c opens editor once' '
198 test_when_finished "test_might_fail git rebase --abort" &&
199 git checkout --detach A3 &&
197 - base=$(git rev-parse HEAD~4) &&
200 FAKE_COMMIT_MESSAGE="Modified-A3" \
201 FAKE_LINES="1 fixup_-C 2 fixup_-c 3 fixup_-c 4" \
202 EXPECT_HEADER_COUNT=4 \
201 - git rebase -i $base &&
202 - test_cmp_rev $base HEAD^ &&
203 + git rebase -i A &&
204 + test_cmp_rev HEAD^ A &&
205 get_author HEAD >actual-author &&
206 test_cmp expected-author actual-author &&
207 test 1 = $(git show | grep Modified-A3 | wc -l)
@@ -217,12 +219,12 @@ test_expect_success 'sequence squash, fixup & fixup -c gives combined message' '
219 '
220
221 test_expect_success 'fixup -C works upon --autosquash with amend!' '
220 - git checkout --detach branch &&
222 + git checkout --detach B3 &&
223 FAKE_COMMIT_AMEND=squashed \
224 FAKE_MESSAGE_COPY=actual-squash-message \
225 git -c commit.status=false rebase -ik --autosquash \
226 --signoff A &&
225 - git diff-tree --exit-code --patch HEAD branch -- &&
227 + git diff-tree --exit-code --patch HEAD B3 -- &&
228 test_cmp_rev HEAD^ A &&
229 test_i18ncmp "$TEST_DIRECTORY/t3437/expected-squash-message" \
230 actual-squash-message