diff mbox series

[v1,1/1] t0003: Call dd with portable blocksize

Message ID 20230121110505.21362-1-tboegi@web.de (mailing list archive)
State Superseded
Headers show
Series [v1,1/1] t0003: Call dd with portable blocksize | expand

Commit Message

Torsten Bögershausen Jan. 21, 2023, 11:05 a.m. UTC
From: Torsten Bögershausen <tboegi@web.de>

The command `dd -bs=101M count=1` is not portable.
Use `bs=1048576 count=101`, which does the same, instead.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
---
 t/t0003-attributes.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--
2.39.1.254.g904d404274

Comments

Junio C Hamano Jan. 22, 2023, 12:08 a.m. UTC | #1
tboegi@web.de writes:

> From: Torsten Bögershausen <tboegi@web.de>
>
> The command `dd -bs=101M count=1` is not portable.

No need for '-'; the UI of dd was meant as a joke and deliberately
deviates from UNIX norm to use '-' as an option introducer.

> Use `bs=1048576 count=101`, which does the same, instead.

Thanks for catching this.  It always is hard to catch these mistakes
made in code that was cooked behind embargo, as there aren't many
eyeballs on the changes.

Strictly speaking, "bs=1048576 count=101" does not do the same thing
(unlike the original that does a single write(2)system call of a
huge buffer, it issues 101 smaller write(2)).

It definitely is an improvement, independently from the portability
issues, to rewrite it like you did.  Unnecessarily large an I/O
should be avoided.

Will queue.  Thanks.

> Signed-off-by: Torsten Bögershausen <tboegi@web.de>
> ---
>  t/t0003-attributes.sh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
> index d0284fe2d7..394a08e6d6 100755
> --- a/t/t0003-attributes.sh
> +++ b/t/t0003-attributes.sh
> @@ -400,7 +400,7 @@ test_expect_success 'large attributes line ignores trailing content in tree' '
>
>  test_expect_success EXPENSIVE 'large attributes file ignored in tree' '
>  	test_when_finished "rm .gitattributes" &&
> -	dd if=/dev/zero of=.gitattributes bs=101M count=1 2>/dev/null &&
> +	dd if=/dev/zero of=.gitattributes bs=1048576 count=101 2>/dev/null &&
>  	git check-attr --all path >/dev/null 2>err &&
>  	echo "warning: ignoring overly large gitattributes file ${SQ}.gitattributes${SQ}" >expect &&
>  	test_cmp expect err
> @@ -428,7 +428,7 @@ test_expect_success 'large attributes line ignores trailing content in index' '
>
>  test_expect_success EXPENSIVE 'large attributes file ignored in index' '
>  	test_when_finished "git update-index --remove .gitattributes" &&
> -	blob=$(dd if=/dev/zero bs=101M count=1 2>/dev/null | git hash-object -w --stdin) &&
> +	blob=$(dd if=/dev/zero bs=1048576 count=101 2>/dev/null | git hash-object -w --stdin) &&
>  	git update-index --add --cacheinfo 100644,$blob,.gitattributes &&
>  	git check-attr --cached --all path >/dev/null 2>err &&
>  	echo "warning: ignoring overly large gitattributes blob ${SQ}.gitattributes${SQ}" >expect &&
> --
> 2.39.1.254.g904d404274
diff mbox series

Patch

diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index d0284fe2d7..394a08e6d6 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -400,7 +400,7 @@  test_expect_success 'large attributes line ignores trailing content in tree' '

 test_expect_success EXPENSIVE 'large attributes file ignored in tree' '
 	test_when_finished "rm .gitattributes" &&
-	dd if=/dev/zero of=.gitattributes bs=101M count=1 2>/dev/null &&
+	dd if=/dev/zero of=.gitattributes bs=1048576 count=101 2>/dev/null &&
 	git check-attr --all path >/dev/null 2>err &&
 	echo "warning: ignoring overly large gitattributes file ${SQ}.gitattributes${SQ}" >expect &&
 	test_cmp expect err
@@ -428,7 +428,7 @@  test_expect_success 'large attributes line ignores trailing content in index' '

 test_expect_success EXPENSIVE 'large attributes file ignored in index' '
 	test_when_finished "git update-index --remove .gitattributes" &&
-	blob=$(dd if=/dev/zero bs=101M count=1 2>/dev/null | git hash-object -w --stdin) &&
+	blob=$(dd if=/dev/zero bs=1048576 count=101 2>/dev/null | git hash-object -w --stdin) &&
 	git update-index --add --cacheinfo 100644,$blob,.gitattributes &&
 	git check-attr --cached --all path >/dev/null 2>err &&
 	echo "warning: ignoring overly large gitattributes blob ${SQ}.gitattributes${SQ}" >expect &&