Skip to content

Commit ae2f8d5

Browse files
bk2204gitster
authored andcommitted
t2020: abstract away SHA-1 specific constants
Adjust the test so that it uses variables for the revisions we're checking out instead of hard-coded hashes. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 60e0dc0 commit ae2f8d5

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

t/t2020-checkout-detach.sh

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,12 @@ test_expect_success 'no advice given for explicit detached head state' '
189189
# Detached HEAD tests for GIT_PRINT_SHA1_ELLIPSIS (new format)
190190
test_expect_success 'describe_detached_head prints no SHA-1 ellipsis when not asked to' "
191191
192+
commit=$(git rev-parse --short=12 master^) &&
193+
commit2=$(git rev-parse --short=12 master~2) &&
194+
commit3=$(git rev-parse --short=12 master~3) &&
195+
192196
# The first detach operation is more chatty than the following ones.
193-
cat >1st_detach <<-'EOF' &&
197+
cat >1st_detach <<-EOF &&
194198
Note: checking out 'HEAD^'.
195199
196200
You are in 'detached HEAD' state. You can look around, make experimental
@@ -202,18 +206,18 @@ test_expect_success 'describe_detached_head prints no SHA-1 ellipsis when not as
202206
203207
git checkout -b <new-branch-name>
204208
205-
HEAD is now at 7c7cd714e262 three
209+
HEAD is now at \$commit three
206210
EOF
207211
208212
# The remaining ones just show info about previous and current HEADs.
209-
cat >2nd_detach <<-'EOF' &&
210-
Previous HEAD position was 7c7cd714e262 three
211-
HEAD is now at 139b20d8e6c5 two
213+
cat >2nd_detach <<-EOF &&
214+
Previous HEAD position was \$commit three
215+
HEAD is now at \$commit2 two
212216
EOF
213217
214-
cat >3rd_detach <<-'EOF' &&
215-
Previous HEAD position was 139b20d8e6c5 two
216-
HEAD is now at d79ce1670bdc one
218+
cat >3rd_detach <<-EOF &&
219+
Previous HEAD position was \$commit2 two
220+
HEAD is now at \$commit3 one
217221
EOF
218222
219223
reset &&
@@ -261,8 +265,12 @@ test_expect_success 'describe_detached_head prints no SHA-1 ellipsis when not as
261265
# Detached HEAD tests for GIT_PRINT_SHA1_ELLIPSIS (old format)
262266
test_expect_success 'describe_detached_head does print SHA-1 ellipsis when asked to' "
263267
268+
commit=$(git rev-parse --short=12 master^) &&
269+
commit2=$(git rev-parse --short=12 master~2) &&
270+
commit3=$(git rev-parse --short=12 master~3) &&
271+
264272
# The first detach operation is more chatty than the following ones.
265-
cat >1st_detach <<-'EOF' &&
273+
cat >1st_detach <<-EOF &&
266274
Note: checking out 'HEAD^'.
267275
268276
You are in 'detached HEAD' state. You can look around, make experimental
@@ -274,18 +282,18 @@ test_expect_success 'describe_detached_head does print SHA-1 ellipsis when asked
274282
275283
git checkout -b <new-branch-name>
276284
277-
HEAD is now at 7c7cd714e262... three
285+
HEAD is now at \$commit... three
278286
EOF
279287
280288
# The remaining ones just show info about previous and current HEADs.
281-
cat >2nd_detach <<-'EOF' &&
282-
Previous HEAD position was 7c7cd714e262... three
283-
HEAD is now at 139b20d8e6c5... two
289+
cat >2nd_detach <<-EOF &&
290+
Previous HEAD position was \$commit... three
291+
HEAD is now at \$commit2... two
284292
EOF
285293
286-
cat >3rd_detach <<-'EOF' &&
287-
Previous HEAD position was 139b20d8e6c5... two
288-
HEAD is now at d79ce1670bdc... one
294+
cat >3rd_detach <<-EOF &&
295+
Previous HEAD position was \$commit2... two
296+
HEAD is now at \$commit3... one
289297
EOF
290298
291299
reset &&

0 commit comments

Comments
 (0)