t0021/rot13-filter: improve 'if .. elsif .. else' style

Before further refactoring the "t0021/rot13-filter.pl" script, let's modernize the style of its 'if .. elsif .. else' clauses to improve its readability by making it more similar to our other perl scripts. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Nov 5, 2017 at 22:38 UTC ed17d26245b27df1694a4efaf386e6924aefaee5
1 file changed +13 -26
t/t0021/rot13-filter.pl
+13 -26
@@ -75,23 +75,20 @@ sub packet_bin_read {
75 if ( $bytes_read == 0 ) {
76 # EOF - Git stopped talking to us!
77 return ( -1, "" );
78 - }
79 - elsif ( $bytes_read != 4 ) {
78 + } elsif ( $bytes_read != 4 ) {
79 die "invalid packet: '$buffer'";
80 }
81 my $pkt_size = hex($buffer);
82 if ( $pkt_size == 0 ) {
83 return ( 1, "" );
85 - }
86 - elsif ( $pkt_size > 4 ) {
84 + } elsif ( $pkt_size > 4 ) {
85 my $content_size = $pkt_size - 4;
86 $bytes_read = read STDIN, $buffer, $content_size;
87 if ( $bytes_read != $content_size ) {
88 die "invalid packet ($content_size bytes expected; $bytes_read bytes read)";
89 }
90 return ( 0, $buffer );
93 - }
94 - else {
91 + } else {
92 die "invalid packet size: $pkt_size";
93 }
94 }
@@ -195,8 +192,7 @@ while (1) {
192 $debug->flush();
193 packet_txt_write("status=success");
194 packet_flush();
198 - }
199 - else {
195 + } else {
196 my ( $res, $pathname ) = packet_required_key_val_read("pathname");
197 if ( $res == -1 ) {
198 die "unexpected EOF while expecting pathname";
@@ -240,17 +236,13 @@ while (1) {
236 my $output;
237 if ( exists $DELAY{$pathname} and exists $DELAY{$pathname}{"output"} ) {
238 $output = $DELAY{$pathname}{"output"}
243 - }
244 - elsif ( $pathname eq "error.r" or $pathname eq "abort.r" ) {
239 + } elsif ( $pathname eq "error.r" or $pathname eq "abort.r" ) {
240 $output = "";
246 - }
247 - elsif ( $command eq "clean" and grep( /^clean$/, @capabilities ) ) {
241 + } elsif ( $command eq "clean" and grep( /^clean$/, @capabilities ) ) {
242 $output = rot13($input);
249 - }
250 - elsif ( $command eq "smudge" and grep( /^smudge$/, @capabilities ) ) {
243 + } elsif ( $command eq "smudge" and grep( /^smudge$/, @capabilities ) ) {
244 $output = rot13($input);
252 - }
253 - else {
245 + } else {
246 die "bad command '$command'";
247 }
248
@@ -259,25 +251,21 @@ while (1) {
251 $debug->flush();
252 packet_txt_write("status=error");
253 packet_flush();
262 - }
263 - elsif ( $pathname eq "abort.r" ) {
254 + } elsif ( $pathname eq "abort.r" ) {
255 print $debug "[ABORT]\n";
256 $debug->flush();
257 packet_txt_write("status=abort");
258 packet_flush();
268 - }
269 - elsif ( $command eq "smudge" and
259 + } elsif ( $command eq "smudge" and
260 exists $DELAY{$pathname} and
271 - $DELAY{$pathname}{"requested"} == 1
272 - ) {
261 + $DELAY{$pathname}{"requested"} == 1 ) {
262 print $debug "[DELAYED]\n";
263 $debug->flush();
264 packet_txt_write("status=delayed");
265 packet_flush();
266 $DELAY{$pathname}{"requested"} = 2;
267 $DELAY{$pathname}{"output"} = $output;
279 - }
280 - else {
268 + } else {
269 packet_txt_write("status=success");
270 packet_flush();
271
@@ -297,8 +285,7 @@ while (1) {
285 print $debug ".";
286 if ( length($output) > $MAX_PACKET_CONTENT_SIZE ) {
287 $output = substr( $output, $MAX_PACKET_CONTENT_SIZE );
300 - }
301 - else {
288 + } else {
289 $output = "";
290 }
291 }