Skip to content

Commit 9c7650c

Browse files
charvi-077gitster
authored andcommitted
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 <[email protected]> Mentored-by: Phillip Wood <[email protected]> Helped-by: Eric Sunshine <[email protected]> Signed-off-by: Charvi Mendiratta <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d8bd080 commit 9c7650c

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

t/t3437-rebase-fixup-options.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ test_expect_success 'setup' '
7070
echo B1 >B &&
7171
test_tick &&
7272
git commit --fixup=HEAD -a &&
73+
git tag B1 &&
7374
test_tick &&
7475
git commit --allow-empty -F - <<-EOF &&
7576
amend! B
@@ -91,6 +92,7 @@ test_expect_success 'setup' '
9192
echo B2 >B &&
9293
test_tick &&
9394
FAKE_COMMIT_AMEND="edited squash" git commit --squash=HEAD -a &&
95+
git tag B2 &&
9496
echo B3 >B &&
9597
test_tick &&
9698
git commit -a -F - <<-EOF &&
@@ -104,6 +106,7 @@ test_expect_success 'setup' '
104106
$EMPTY
105107
edited 3
106108
EOF
109+
git tag B3 &&
107110
108111
GIT_AUTHOR_NAME="Rebase Author" &&
109112
GIT_AUTHOR_EMAIL="[email protected]" &&
@@ -171,20 +174,20 @@ test_expect_success 'skipping fixup -C after fixup gives correct message' '
171174
'
172175

173176
test_expect_success 'sequence of fixup, fixup -C & squash --signoff works' '
174-
git checkout --detach branch &&
177+
git checkout --detach B3 &&
175178
FAKE_LINES="1 fixup 2 fixup_-C 3 fixup_-C 4 squash 5 fixup_-C 6" \
176179
FAKE_COMMIT_AMEND=squashed \
177180
FAKE_MESSAGE_COPY=actual-squash-message \
178181
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 -- &&
180183
test_cmp_rev HEAD^ A &&
181184
test_i18ncmp "$TEST_DIRECTORY/t3437/expected-squash-message" \
182185
actual-squash-message
183186
'
184187

185188
test_expect_success 'first fixup -C commented out in sequence fixup fixup -C fixup -C' '
186189
test_when_finished "test_might_fail git rebase --abort" &&
187-
git checkout branch && git checkout --detach branch~2 &&
190+
git checkout --detach B2~ &&
188191
git log -1 --pretty=format:%b >expected-message &&
189192
FAKE_LINES="1 fixup 2 fixup_-C 3 fixup_-C 4" git rebase -i A &&
190193
test_cmp_rev HEAD^ A &&
@@ -194,12 +197,11 @@ test_expect_success 'first fixup -C commented out in sequence fixup fixup -C fix
194197
test_expect_success 'multiple fixup -c opens editor once' '
195198
test_when_finished "test_might_fail git rebase --abort" &&
196199
git checkout --detach A3 &&
197-
base=$(git rev-parse HEAD~4) &&
198200
FAKE_COMMIT_MESSAGE="Modified-A3" \
199201
FAKE_LINES="1 fixup_-C 2 fixup_-c 3 fixup_-c 4" \
200202
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 &&
203205
get_author HEAD >actual-author &&
204206
test_cmp expected-author actual-author &&
205207
test 1 = $(git show | grep Modified-A3 | wc -l)
@@ -217,12 +219,12 @@ test_expect_success 'sequence squash, fixup & fixup -c gives combined message' '
217219
'
218220

219221
test_expect_success 'fixup -C works upon --autosquash with amend!' '
220-
git checkout --detach branch &&
222+
git checkout --detach B3 &&
221223
FAKE_COMMIT_AMEND=squashed \
222224
FAKE_MESSAGE_COPY=actual-squash-message \
223225
git -c commit.status=false rebase -ik --autosquash \
224226
--signoff A &&
225-
git diff-tree --exit-code --patch HEAD branch -- &&
227+
git diff-tree --exit-code --patch HEAD B3 -- &&
226228
test_cmp_rev HEAD^ A &&
227229
test_i18ncmp "$TEST_DIRECTORY/t3437/expected-squash-message" \
228230
actual-squash-message

0 commit comments

Comments
 (0)