Skip to content

Commit efe47c8

Browse files
sunshinecogitster
authored andcommitted
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 <[email protected]> Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e57ea50 commit efe47c8

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

t/t6300-for-each-ref.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -955,10 +955,7 @@ test_expect_success '%(raw) with --shell and --sort=raw must fail' '
955955
'
956956

957957
test_expect_success '%(raw:size) with --shell' '
958-
git for-each-ref --format="%(raw:size)" | while read line
959-
do
960-
echo "'\''$line'\''" >>expect
961-
done &&
958+
git for-each-ref --format="%(raw:size)" | sed "s/^/$SQ/;s/$/$SQ/" >expect &&
962959
git for-each-ref --format="%(raw:size)" --shell >actual &&
963960
test_cmp expect actual
964961
'

0 commit comments

Comments
 (0)