Skip to content

Commit 25cbfe3

Browse files
chriscoolgitster
authored andcommitted
t0021/rot13-filter: add packet_initialize()
Let's refactor the code to initialize communication into its own packet_initialize() function, so that we can reuse this functionality in following patches. Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 00df039 commit 25cbfe3

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

t/t0021/rot13-filter.pl

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,25 @@ sub packet_flush {
127127
STDOUT->flush();
128128
}
129129

130+
sub packet_initialize {
131+
my ($name, $version) = @_;
132+
133+
packet_compare_lists([0, $name . "-client"], packet_txt_read()) ||
134+
die "bad initialize";
135+
packet_compare_lists([0, "version=" . $version], packet_txt_read()) ||
136+
die "bad version";
137+
packet_compare_lists([1, ""], packet_bin_read()) ||
138+
die "bad version end";
139+
140+
packet_txt_write( $name . "-server" );
141+
packet_txt_write( "version=" . $version );
142+
packet_flush();
143+
}
144+
130145
print $debug "START\n";
131146
$debug->flush();
132147

133-
packet_compare_lists([0, "git-filter-client"], packet_txt_read()) ||
134-
die "bad initialize";
135-
packet_compare_lists([0, "version=2"], packet_txt_read()) ||
136-
die "bad version";
137-
packet_compare_lists([1, ""], packet_bin_read()) ||
138-
die "bad version end";
139-
140-
packet_txt_write("git-filter-server");
141-
packet_txt_write("version=2");
142-
packet_flush();
148+
packet_initialize("git-filter", 2);
143149

144150
packet_compare_lists([0, "capability=clean"], packet_txt_read()) ||
145151
die "bad capability";

0 commit comments

Comments
 (0)