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

Re: What's cooking in git.git (Jan 2024, #01; Tue, 2)

From
René Scharfe <l.s.r@web.de>
Date
Jan 3, 2024, 17:14 UTC
Message-ID
<a81ecbb1-9ebf-4026-99c3-667ad28e2c80@web.de>
In-Reply-To
<20240103090152.GB1866508@coredump.intra.peff.net>
Am 03.01.24 um 10:01 schrieb Jeff King:
Show 45 quoted lines
> On Tue, Jan 02, 2024 at 05:02:35PM -0800, Junio C Hamano wrote:
>
>> * jk/t1006-cat-file-objectsize-disk (2023-12-21) 1 commit
>>   (merged to 'next' on 2023-12-28 at d82812e636)
>>  + t1006: add tests for %(objectsize:disk)
>>
>>  Test update.
>>
>>  Will merge to 'master'.
>>  source: <20231221094722.GA570888@coredump.intra.peff.net>
>
> It looks like this is the original version. I posted a v2 that took
> René's suggestion to swap out the awk for shell, but it got overlooked.
> I'm happy enough either way, but if we want to salvage that effort,
> here's a patch which could go on top:
>
> -- >8 --
> From: René Scharfe <l.s.r@web.de>
> Subject: [PATCH] t1006: prefer shell loop to awk for packed object sizes
>
> To compute the expected on-disk size of packed objects, we sort the
> output of show-index by pack offset and then compute the difference
> between adjacent entries using awk. This works but has a few readability
> problems:
>
>   1. Reading the index in pack order means don't find out the size of an
>      oid's entry until we see the _next_ entry. So we have to save it to
>      print later.
>
>      We can instead iterate in reverse order, so we compute each oid's
>      size as we see it.
>
>   2. Since the awk invocation is inside a text_expect block, we can't
>      easily use single-quotes to hold the script. So we use
>      double-quotes, but then have to escape the dollar signs in the awk
>      script.
>
>      We can swap this out for a shell loop instead (which is made much
>      easier by the first change).
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> I gave René authorship since this was his cleverness, but obviously I
> wrote the commit message. Giving an explicit signoff would be nice,
> though.
Alright, thank you!
Signed-off-by: René Scharfe <l.s.r@web.de>
Show 31 quoted lines
>
>  t/t1006-cat-file.sh | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
> index 0c2eafae65..5ea3326128 100755
> --- a/t/t1006-cat-file.sh
> +++ b/t/t1006-cat-file.sh
> @@ -1117,14 +1117,16 @@ test_expect_success 'cat-file %(objectsize:disk) with --batch-all-objects' '
>  		while read idx
>  		do
>  			git show-index <"$idx" >idx.raw &&
> -			sort -n <idx.raw >idx.sorted &&
> +			sort -nr <idx.raw >idx.sorted &&
>  			packsz=$(test_file_size "${idx%.idx}.pack") &&
>  			end=$((packsz - rawsz)) &&
> -			awk -v end="$end" "
> -			  NR > 1 { print oid, \$1 - start }
> -			  { start = \$1; oid = \$2 }
> -			  END { print oid, end - start }
> -			" idx.sorted ||
> +			while read start oid rest
> +			do
> +				size=$((end - start)) &&
> +				end=$start &&
> +				echo "$oid $size" ||
> +				return 1
> +			done <idx.sorted ||
>  			return 1
>  		done
>  	} >expect.raw &&
Previous: Junio C HamanoNext: Taylor Blau
Message 7 of 20 in “What's cooking in git.git (Jan 2024, #01; Tue, 2)”
  1. Junio C HamanoJan 3, 2024
  2. Patrick SteinhardtJan 3, 2024
  3. Jeff KingJan 3, 2024
  4. Junio C HamanoJan 3, 2024
  5. Jeff KingJan 5, 2024
  6. Junio C HamanoJan 5, 2024
  7. René ScharfeJan 3, 2024
  8. Taylor BlauJan 3, 2024
  9. Junio C HamanoJan 3, 2024
  10. SZEDER GáborJan 13, 2024
  11. Taylor BlauJan 13, 2024
  12. SZEDER GáborJan 13, 2024
  13. Taylor BlauJan 16, 2024
  14. SZEDER GáborFeb 25, 2024
  15. Taylor BlauFeb 26, 2024
  16. SZEDER GáborJan 13, 2024
  17. Taylor BlauJan 16, 2024
  18. Junio C HamanoJan 16, 2024
  19. Taylor BlauJan 16, 2024
  20. Junio C HamanoJan 16, 2024

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.