t6300: make `%(raw:size) --shell` test more robust

This test populates its `expect` file solely by appending content but
fails to ensure that the file starts out empty. The test succeeds only
because no earlier test populated a file of the exact same name, however
this is an accident waiting to happen. Make the test more robust by
ensuring that it contains exactly the intended content.

While at it, simplify the implementation via a straightforward `sed`
application and by avoiding dropping out of the single-quote context
within the test body (thus eliminating a hard-to-digest combination of
apostrophes and backslashes).

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Eric Sunshine 2021-12-09 00:11:02 -05:00 коммит произвёл Junio C Hamano
Родитель e57ea501d0
Коммит efe47c83b2
1 изменённых файлов: 1 добавлений и 4 удалений

Просмотреть файл

@ -955,10 +955,7 @@ test_expect_success '%(raw) with --shell and --sort=raw must fail' '
' '
test_expect_success '%(raw:size) with --shell' ' test_expect_success '%(raw:size) with --shell' '
git for-each-ref --format="%(raw:size)" | while read line git for-each-ref --format="%(raw:size)" | sed "s/^/$SQ/;s/$/$SQ/" >expect &&
do
echo "'\''$line'\''" >>expect
done &&
git for-each-ref --format="%(raw:size)" --shell >actual && git for-each-ref --format="%(raw:size)" --shell >actual &&
test_cmp expect actual test_cmp expect actual
' '