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

Re: [PATCH v2 1/2] t5332-multi-pack-reuse.sh: extract pack-objects helper functions

From
Patrick Steinhardt <ps@pks.im>
Date
Feb 6, 2024, 07:25 UTC
Message-ID
<ZcHe67-6VLssXYDL@tanuki>
In-Reply-To
<db3d67bfa38bf3141214619e766d39dc7f709812.1707173415.git.me@ttaylorr.com>
On Mon, Feb 05, 2024 at 05:50:19PM -0500, Taylor Blau wrote:
Show 68 quoted lines
> Most of the tests in t5332 perform some setup before repeating a common
> refrain that looks like:
> 
>     : >trace2.txt &&
>     GIT_TRACE2_EVENT="$PWD/trace2.txt" \
>       git pack-objects --stdout --revs --all >/dev/null &&
> 
>     test_pack_reused $objects_nr <trace2.txt &&
>     test_packs_reused $packs_nr <trace2.txt
> 
> The next commit will add more tests which repeat the above refrain.
> Avoid duplicating this invocation even further and prepare for the
> following commit by wrapping the above in a helper function called
> `test_pack_objects_reused_all()`.
> 
> Introduce another similar function `test_pack_objects_reused`, which
> expects to read a list of revisions over stdin for tests which need more
> fine-grained control of the contents of the pack they generate.
> 
> Signed-off-by: Taylor Blau <me@ttaylorr.com>
> ---
>  t/t5332-multi-pack-reuse.sh | 71 +++++++++++++++----------------------
>  1 file changed, 29 insertions(+), 42 deletions(-)
> 
> diff --git a/t/t5332-multi-pack-reuse.sh b/t/t5332-multi-pack-reuse.sh
> index 2ba788b042..d516062f84 100755
> --- a/t/t5332-multi-pack-reuse.sh
> +++ b/t/t5332-multi-pack-reuse.sh
> @@ -23,6 +23,27 @@ pack_position () {
>  	grep "$1" objects | cut -d" " -f1
>  }
>  
> +# test_pack_objects_reused_all <pack-reused> <packs-reused>
> +test_pack_objects_reused_all () {
> +	: >trace2.txt &&
> +	GIT_TRACE2_EVENT="$PWD/trace2.txt" \
> +		git pack-objects --stdout --revs --all --delta-base-offset \
> +		>/dev/null &&
> +
> +	test_pack_reused "$1" <trace2.txt &&
> +	test_packs_reused "$2" <trace2.txt
> +}
> +
> +# test_pack_objects_reused <pack-reused> <packs-reused>
> +test_pack_objects_reused () {
> +	: >trace2.txt &&
> +	GIT_TRACE2_EVENT="$PWD/trace2.txt" \
> +		git pack-objects --stdout --revs >/dev/null &&
> +
> +	test_pack_reused "$1" <trace2.txt &&
> +	test_packs_reused "$2" <trace2.txt
> +}
> +
>  test_expect_success 'preferred pack is reused for single-pack reuse' '
>  	test_config pack.allowPackReuse single &&
>  
> @@ -34,14 +55,10 @@ test_expect_success 'preferred pack is reused for single-pack reuse' '
>  
>  	git multi-pack-index write --bitmap &&
>  
> -	: >trace2.txt &&
> -	GIT_TRACE2_EVENT="$PWD/trace2.txt" \
> -		git pack-objects --stdout --revs --all >/dev/null &&
> -
> -	test_pack_reused 3 <trace2.txt &&
> -	test_packs_reused 1 <trace2.txt
> +	test_pack_objects_reused_all 3 1
>  '

Sorry for being nitpicky, but now we have the reverse problem where this function adds `--delta-base-offset`. How about we adapt the helper function so that it accepts trailing arguments like this:

```
test_pack_objects_reused () {
	local pack_reused="$1"
	local packs_reused="$2"
	shift 2
	: >trace2.txt &&
	GIT_TRACE2_EVENT="$PWD/trace2.txt" \
		git pack-objects --stdout --revs "$@" >/dev/null &&
	test_pack_reused "$pack_reused" <trace2.txt &&
	test_packs_reused "$packs_reused" <trace2.txt
}
```

This merges the two helpers into a single one where callers can decide by themselves which arguments to pass to git-pack-objects(1).

Patrick
Previous: Taylor BlauNext: Taylor Blau
Message 10 of 11 in “pack-objects: enable multi-pack reuse via feature.experimental”
  1. 0/2 pack-objects: enable multi-pack reuse via feature.experimentalTaylor Blau, Jan 16, 2024
  2. 1/2 t5332-multi-pack-reuse.sh: extract pack-objects helper functionsTaylor Blau, Jan 16, 2024
  3. Patrick SteinhardtJan 17, 2024
  4. Taylor BlauFeb 5, 2024
  5. 2/2 pack-objects: enable multi-pack reuse via `feature.experimental`Taylor Blau, Jan 16, 2024
  6. Patrick SteinhardtJan 17, 2024
  7. Taylor BlauFeb 5, 2024
  8. 0/2 pack-objects: enable multi-pack reuse via feature.experimentalTaylor Blau, Feb 5, 2024
  9. 1/2 t5332-multi-pack-reuse.sh: extract pack-objects helper functionsTaylor Blau, Feb 5, 2024
  10. Patrick SteinhardtFeb 6, 2024
  11. 2/2 pack-objects: enable multi-pack reuse via `feature.experimental`Taylor Blau, Feb 5, 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.