Junio C Hamano wrote:
> Ævar Arnfjörð Bjarmason <[email protected]> writes:
>
>> It was my reading of the seek=* section ("the implementation shall seek
>> to the specified offset"). I didn't spot that bit covered in of=*. Yeah,
>> I see that's defined & safe after reading that.
>
> OK, so...
>
> -- >8 --
> From: Ævar Arnfjörð Bjarmason <[email protected]>
> Date: Thu, 21 Feb 2019 20:28:49 +0100
> Subject: [PATCH] commit-graph tests: fix cryptic unportable "dd" invocation
>
> Change an unportable invocation of "dd" with count=0, that wanted to
> truncate the commit-graph file. In POSIX it is unspecified what
> happens when count=0 is provided[1]. The NetBSD "dd" behavior
> differs from GNU (and seemingly other BSDs), which as left this test
s/ as/ has/ ?
> broken since d2b86fbaa1 ("commit-graph: fix buffer read-overflow",
> 2019-01-15).
>
> Copying from /dev/null would seek/truncate to seek=$zero_pos and
> stop immediately after that (without being able to copy anything),
> which is the right way to truncate the file.
>
> 1. http://pubs.opengroup.org/onlinepubs/9699919799/utilities/dd.html
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]>
> Helped-by: SZEDER Gábor <[email protected]>
> Signed-off-by: Junio C Hamano <[email protected]>
> ---
> t/t5318-commit-graph.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh
> index d4bd1522fe..561796f280 100755
> --- a/t/t5318-commit-graph.sh
> +++ b/t/t5318-commit-graph.sh
> @@ -382,7 +382,7 @@ corrupt_graph_and_verify() {
> test_when_finished mv commit-graph-backup $objdir/info/commit-graph &&
> cp $objdir/info/commit-graph commit-graph-backup &&
> printf "$data" | dd of="$objdir/info/commit-graph" bs=1 seek="$pos"
> conv=notrunc &&
> - dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" count=0 &&
> + dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" if=/dev/null &&
> generate_zero_bytes $(($orig_size - $zero_pos))
> >>"$objdir/info/commit-graph" &&
> test_must_fail git commit-graph verify 2>test_err &&
> grep -v "^+" test_err >err &&
--
Todd