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 <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed Jul 22, 2022 at 19:29 UTC 3639fefe7d1d7bf881ea6128cedc4fc503164edc
1 file changed +16 -14
t/t1006-cat-file.sh
+16 -14
@@ -418,6 +418,12 @@ test_expect_success "--batch-check with multiple sha1s gives correct format" '
418 "$(echo_without_newline "$batch_check_input" | git cat-file --batch-check)"
419 '
420
421 +batch_command_multiple_info="info $hello_sha1
422 +info $tree_sha1
423 +info $commit_sha1
424 +info $tag_sha1
425 +info deadbeef"
426 +
427 test_expect_success '--batch-command with multiple info calls gives correct format' '
428 cat >expect <<-EOF &&
429 $hello_sha1 blob $hello_size
@@ -427,17 +433,18 @@ test_expect_success '--batch-command with multiple info calls gives correct form
433 deadbeef missing
434 EOF
435
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 &&
438
439 test_cmp expect actual
440 '
441
442 +batch_command_multiple_contents="contents $hello_sha1
443 +contents $commit_sha1
444 +contents $tag_sha1
445 +contents deadbeef
446 +flush"
447 +
448 test_expect_success '--batch-command with multiple command calls gives correct format' '
449 remove_timestamp >expect <<-EOF &&
450 $hello_sha1 blob $hello_size
@@ -449,13 +456,8 @@ test_expect_success '--batch-command with multiple command calls gives correct f
456 deadbeef missing
457 EOF
458
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 &&
461
462 remove_timestamp <actual_raw >actual &&
463 test_cmp expect actual