summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2022-07-22 23:29:02 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-07-23 04:42:05 (GMT)
commit3639fefe7d1d7bf881ea6128cedc4fc503164edc (patch)
tree4c03edb5d3b31a031f2e92db2ab1fb7dcc8be388
parent6a475b71f8c4ce708d69fdc9317aefbde3769e25 (diff)
downloadgit-3639fefe7d1d7bf881ea6128cedc4fc503164edc.zip
git-3639fefe7d1d7bf881ea6128cedc4fc503164edc.tar.gz
git-3639fefe7d1d7bf881ea6128cedc4fc503164edc.tar.bz2
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>
-rwxr-xr-xt/t1006-cat-file.sh30
1 files changed, 16 insertions, 14 deletions
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index dadf3b1..01c0535 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -418,6 +418,12 @@ test_expect_success "--batch-check with multiple sha1s gives correct format" '
"$(echo_without_newline "$batch_check_input" | git cat-file --batch-check)"
'
+batch_command_multiple_info="info $hello_sha1
+info $tree_sha1
+info $commit_sha1
+info $tag_sha1
+info deadbeef"
+
test_expect_success '--batch-command with multiple info calls gives correct format' '
cat >expect <<-EOF &&
$hello_sha1 blob $hello_size
@@ -427,17 +433,18 @@ test_expect_success '--batch-command with multiple info calls gives correct form
deadbeef missing
EOF
- git cat-file --batch-command --buffer >actual <<-EOF &&
- info $hello_sha1
- info $tree_sha1
- info $commit_sha1
- info $tag_sha1
- info deadbeef
- EOF
+ echo "$batch_command_multiple_info" >in &&
+ git cat-file --batch-command --buffer <in >actual &&
test_cmp expect actual
'
+batch_command_multiple_contents="contents $hello_sha1
+contents $commit_sha1
+contents $tag_sha1
+contents deadbeef
+flush"
+
test_expect_success '--batch-command with multiple command calls gives correct format' '
remove_timestamp >expect <<-EOF &&
$hello_sha1 blob $hello_size
@@ -449,13 +456,8 @@ test_expect_success '--batch-command with multiple command calls gives correct f
deadbeef missing
EOF
- git cat-file --batch-command --buffer >actual_raw <<-EOF &&
- contents $hello_sha1
- contents $commit_sha1
- contents $tag_sha1
- contents deadbeef
- flush
- EOF
+ echo "$batch_command_multiple_contents" >in &&
+ git cat-file --batch-command --buffer <in >actual_raw &&
remove_timestamp <actual_raw >actual &&
test_cmp expect actual