-
-my $len_hex = xread 4;
-fail "non-hex packet length" unless $len_hex =~ m{^[0-9a-fA-F]{4}$};
-my $line = xread hex $len_hex;
-if ($line =~ m{^(git-[a-z-]+) ([!-~]+)\0host=([!-~]+)\0$}) {
- package cf;
- our ($service,$path,$host) = ($1,$2,$3);
- $path =~ s|^/*||;
- our $uri = $_ = "git://$host/$path";
-} else {
- $line =~ s|[^ -~]+| |g;
- fail "could not parse \"$line\""
+xread 4;
+fail "Bad hex in packet length" unless m|^[0-9a-fA-F]{4}$|;
+xread hex;
+unless (($service,$path,$host) =
+ m|^(git-[a-z-]+) /*([!-~]+)\0host=([!-~]+)\0$|) {
+ s|[^ -~]+| |g;
+ fail "Could not parse \"$_\""