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 <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Mar 25, 2018 at 19:20 UTC
ae2f8d5bd6bacd5d7a1316170efd93a7bdadb6f1
1 file changed
+24
-16
t/t2020-checkout-detach.sh
+24
-16
@@ -189,8 +189,12 @@ test_expect_success 'no advice given for explicit detached head state' '
189
# Detached HEAD tests for GIT_PRINT_SHA1_ELLIPSIS (new format)
190
test_expect_success 'describe_detached_head prints no SHA-1 ellipsis when not asked to' "
191
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
+
196
# The first detach operation is more chatty than the following ones.
193
- cat >1st_detach <<-'EOF' &&
197
+ cat >1st_detach <<-EOF &&
198
Note: checking out 'HEAD^'.
199
200
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
206
207
git checkout -b <new-branch-name>
208
205
- HEAD is now at 7c7cd714e262 three
209
+ HEAD is now at \$commit three
210
EOF
211
212
# 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
216
EOF
217
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
221
EOF
222
223
reset &&
@@ -261,8 +265,12 @@ test_expect_success 'describe_detached_head prints no SHA-1 ellipsis when not as
265
# Detached HEAD tests for GIT_PRINT_SHA1_ELLIPSIS (old format)
266
test_expect_success 'describe_detached_head does print SHA-1 ellipsis when asked to' "
267
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
+
272
# The first detach operation is more chatty than the following ones.
265
- cat >1st_detach <<-'EOF' &&
273
+ cat >1st_detach <<-EOF &&
274
Note: checking out 'HEAD^'.
275
276
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
282
283
git checkout -b <new-branch-name>
284
277
- HEAD is now at 7c7cd714e262... three
285
+ HEAD is now at \$commit... three
286
EOF
287
288
# 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
292
EOF
293
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
297
EOF
298
299
reset &&