Skip to content

Commit 3639fef

Browse files
ttaylorrgitster
authored andcommitted
t1006: extract --batch-command inputs to variables
A future commit will want to ensure that various `--batch`-related options produce the same output whether their input is newline terminated, or NUL terminated (and a to-be-implemented `-z` option exists). To prepare for this, extract the given input(s) into separate variables to that their LF characters can easily be converted into NUL bytes when testing the new `-z` mode. This is consistent with other tests in t1006 (which these days is no longer a shining example of our CodingGuidelines). Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6a475b7 commit 3639fef

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

t/t1006-cat-file.sh

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,12 @@ test_expect_success "--batch-check with multiple sha1s gives correct format" '
418418
"$(echo_without_newline "$batch_check_input" | git cat-file --batch-check)"
419419
'
420420

421+
batch_command_multiple_info="info $hello_sha1
422+
info $tree_sha1
423+
info $commit_sha1
424+
info $tag_sha1
425+
info deadbeef"
426+
421427
test_expect_success '--batch-command with multiple info calls gives correct format' '
422428
cat >expect <<-EOF &&
423429
$hello_sha1 blob $hello_size
@@ -427,17 +433,18 @@ test_expect_success '--batch-command with multiple info calls gives correct form
427433
deadbeef missing
428434
EOF
429435
430-
git cat-file --batch-command --buffer >actual <<-EOF &&
431-
info $hello_sha1
432-
info $tree_sha1
433-
info $commit_sha1
434-
info $tag_sha1
435-
info deadbeef
436-
EOF
436+
echo "$batch_command_multiple_info" >in &&
437+
git cat-file --batch-command --buffer <in >actual &&
437438
438439
test_cmp expect actual
439440
'
440441

442+
batch_command_multiple_contents="contents $hello_sha1
443+
contents $commit_sha1
444+
contents $tag_sha1
445+
contents deadbeef
446+
flush"
447+
441448
test_expect_success '--batch-command with multiple command calls gives correct format' '
442449
remove_timestamp >expect <<-EOF &&
443450
$hello_sha1 blob $hello_size
@@ -449,13 +456,8 @@ test_expect_success '--batch-command with multiple command calls gives correct f
449456
deadbeef missing
450457
EOF
451458
452-
git cat-file --batch-command --buffer >actual_raw <<-EOF &&
453-
contents $hello_sha1
454-
contents $commit_sha1
455-
contents $tag_sha1
456-
contents deadbeef
457-
flush
458-
EOF
459+
echo "$batch_command_multiple_contents" >in &&
460+
git cat-file --batch-command --buffer <in >actual_raw &&
459461
460462
remove_timestamp <actual_raw >actual &&
461463
test_cmp expect actual

0 commit comments

Comments
 (0)