git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Taylor Blau <me@ttaylorr.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 1/2] t5332-multi-pack-reuse.sh: extract pack-objects helper functions
Date: Wed, 17 Jan 2024 08:32:09 +0100	[thread overview]
Message-ID: <ZaeCeY-9AIR-zt7u@tanuki> (raw)
In-Reply-To: <94dd41e1afdd6d926a106ab387295cf5fce624cf.1705431816.git.me@ttaylorr.com>

[-- Attachment #1: Type: text/plain, Size: 2738 bytes --]

On Tue, Jan 16, 2024 at 02:03:44PM -0500, Taylor Blau wrote:
> 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 | 70 +++++++++++++++----------------------
>  1 file changed, 28 insertions(+), 42 deletions(-)
> 
> diff --git a/t/t5332-multi-pack-reuse.sh b/t/t5332-multi-pack-reuse.sh
> index 2ba788b042..b53e821bc0 100755
> --- a/t/t5332-multi-pack-reuse.sh
> +++ b/t/t5332-multi-pack-reuse.sh
> @@ -23,6 +23,26 @@ 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 >/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 &&
>  
[snip]
> @@ -104,12 +110,7 @@ test_expect_success 'reuse objects from first pack with middle gap' '
>  	^$(git rev-parse D)
>  	EOF
>  
> -	: >trace2.txt &&
> -	GIT_TRACE2_EVENT="$PWD/trace2.txt" \
> -		git pack-objects --stdout --delta-base-offset --revs <in >/dev/null &&
> -
> -	test_pack_reused 3 <trace2.txt &&
> -	test_packs_reused 1 <trace2.txt
> +	test_pack_objects_reused 3 1 <in

This conversion causes us to drop the `--delta-base-offset` flag. It
would be great to have an explanation in the commit message why it is
fine to drop it.

Other than that this looks like a nice simplification to me.

Patrick

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2024-01-17  7:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-16 19:03 [PATCH 0/2] pack-objects: enable multi-pack reuse via feature.experimental Taylor Blau
2024-01-16 19:03 ` [PATCH 1/2] t5332-multi-pack-reuse.sh: extract pack-objects helper functions Taylor Blau
2024-01-17  7:32   ` Patrick Steinhardt [this message]
2024-02-05 22:44     ` Taylor Blau
2024-01-16 19:03 ` [PATCH 2/2] pack-objects: enable multi-pack reuse via `feature.experimental` Taylor Blau
2024-01-17  7:32   ` Patrick Steinhardt
2024-02-05 22:48     ` Taylor Blau
2024-02-05 22:50 ` [PATCH v2 0/2] pack-objects: enable multi-pack reuse via feature.experimental Taylor Blau
2024-02-05 22:50   ` [PATCH v2 1/2] t5332-multi-pack-reuse.sh: extract pack-objects helper functions Taylor Blau
2024-02-06  7:25     ` Patrick Steinhardt
2024-02-05 22:50   ` [PATCH v2 2/2] pack-objects: enable multi-pack reuse via `feature.experimental` Taylor Blau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZaeCeY-9AIR-zt7u@tanuki \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=me@ttaylorr.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).