Re: [RFC/PATCH v4 07/49] Git/Packet.pm: add packet_initialize()
- From
Ben Peart <peartben@gmail.com>
- Date
- Jun 23, 2017, 18:55 UTC
- Message-ID
- <a2adc8ab-a1a2-082d-8588-fb683acaadaf@gmail.com>
- In-Reply-To
- <20170620075523.26961-8-chriscool@tuxfamily.org>
I like where this ends but it seems to me that patches 6, 7 and 8 should just get merged into patch 4 and 5.
On 6/20/2017 3:54 AM, Christian Couder wrote:
Show 57 quoted lines
> Add a function to initialize the communication. And use this
> function in 't/t0021/rot13-filter.pl'.
>
> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
> ---
> perl/Git/Packet.pm | 13 +++++++++++++
> t/t0021/rot13-filter.pl | 8 +-------
> 2 files changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/perl/Git/Packet.pm b/perl/Git/Packet.pm
> index 2ad6b00d6c..b0233caf37 100644
> --- a/perl/Git/Packet.pm
> +++ b/perl/Git/Packet.pm
> @@ -19,6 +19,7 @@ our @EXPORT = qw(
> packet_bin_write
> packet_txt_write
> packet_flush
> + packet_initialize
> );
> our @EXPORT_OK = @EXPORT;
>
> @@ -70,3 +71,15 @@ sub packet_flush {
> print STDOUT sprintf( "%04x", 0 );
> STDOUT->flush();
> }
> +
> +sub packet_initialize {
> + my ($name, $version) = @_;
> +
> + ( packet_txt_read() eq ( 0, $name . "-client" ) ) || die "bad initialize";
> + ( packet_txt_read() eq ( 0, "version=" . $version ) ) || die "bad version";
> + ( packet_bin_read() eq ( 1, "" ) ) || die "bad version end";
> +
> + packet_txt_write( $name . "-server" );
> + packet_txt_write( "version=" . $version );
> + packet_flush();
> +}
> diff --git a/t/t0021/rot13-filter.pl b/t/t0021/rot13-filter.pl
> index 36a9eb3608..5b05518640 100644
> --- a/t/t0021/rot13-filter.pl
> +++ b/t/t0021/rot13-filter.pl
> @@ -40,13 +40,7 @@ sub rot13 {
> print $debug "START\n";
> $debug->flush();
>
> -( packet_txt_read() eq ( 0, "git-filter-client" ) ) || die "bad initialize";
> -( packet_txt_read() eq ( 0, "version=2" ) ) || die "bad version";
> -( packet_bin_read() eq ( 1, "" ) ) || die "bad version end";
> -
> -packet_txt_write("git-filter-server");
> -packet_txt_write("version=2");
> -packet_flush();
> +packet_initialize("git-filter", 2);
>
> ( packet_txt_read() eq ( 0, "capability=clean" ) ) || die "bad capability";
> ( packet_txt_read() eq ( 0, "capability=smudge" ) ) || die "bad capability";
>