git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] t1006: add tests for %(objectsize:disk)

From
René Scharfe <l.s.r@web.de>
Date
Dec 24, 2023, 09:30 UTC
Message-ID
<62dc66ef-d669-4486-be61-8d50bf469627@web.de>
In-Reply-To
<20231223100905.GB2016274@coredump.intra.peff.net>
Am 23.12.23 um 11:09 schrieb Jeff King:
Show 52 quoted lines
>
> ---
>  t/t1006-cat-file.sh | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
>
> diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
> index 271c5e4fd3..e0c6482797 100755
> --- a/t/t1006-cat-file.sh
> +++ b/t/t1006-cat-file.sh
> @@ -1100,6 +1100,42 @@ test_expect_success 'cat-file --batch="batman" with --batch-all-objects will wor
>  	cmp expect actual
>  '
>
> +test_expect_success 'cat-file %(objectsize:disk) with --batch-all-objects' '
> +	# our state has both loose and packed objects,
> +	# so find both for our expected output
> +	{
> +		find .git/objects/?? -type f |
> +		awk -F/ "{ print \$0, \$3\$4 }" |
> +		while read path oid
> +		do
> +			size=$(test_file_size "$path") &&
> +			echo "$oid $size" ||
> +			return 1
> +		done &&
> +		rawsz=$(test_oid rawsz) &&
> +		find .git/objects/pack -name "*.idx" |
> +		while read idx
> +		do
> +			git show-index <"$idx" >idx.raw &&
> +			sort -nr <idx.raw >idx.sorted &&
> +			packsz=$(test_file_size "${idx%.idx}.pack") &&
> +			end=$((packsz - rawsz)) &&
> +			while read start oid rest
> +			do
> +				size=$((end - start)) &&
> +				end=$start &&
> +				echo "$oid $size" ||
> +				return 1
> +			done <idx.sorted ||
> +			return 1
> +		done
> +	} >expect.raw &&
> +	sort <expect.raw >expect &&
> +	git cat-file --batch-all-objects \
> +		--batch-check="%(objectname) %(objectsize:disk)" >actual &&
> +	test_cmp expect actual
> +'
> +
>  test_expect_success 'set up replacement object' '
>  	orig=$(git rev-parse HEAD) &&
>  	git cat-file commit $orig >orig &&
Looks good to me.
René
Previous: Jeff KingNext: Jeff King
Message 13 of 17 in “Test breakage with zlib-ng”
  1. Ondrej PohorelskyDec 12, 2023
  2. René ScharfeDec 12, 2023
  3. Jeff KingDec 12, 2023
  4. René ScharfeDec 12, 2023
  5. 2/1 test-lib-functions: add object size functionsRené Scharfe, Dec 13, 2023
  6. Jeff KingDec 14, 2023
  7. René ScharfeDec 19, 2023
  8. t1006: add tests for %(objectsize:disk)Jeff King, Dec 21, 2023
  9. René ScharfeDec 21, 2023
  10. Jeff KingDec 21, 2023
  11. René ScharfeDec 21, 2023
  12. t1006: add tests for %(objectsize:disk)Jeff King, Dec 23, 2023
  13. René ScharfeDec 24, 2023
  14. Jeff KingDec 23, 2023
  15. René ScharfeDec 24, 2023
  16. brian m. carlsonDec 12, 2023
  17. Junio C HamanoDec 12, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.