sub badproto ($$) {
my ($fh, $m) = @_;
fail "connection lost: $!" if $fh->error;
- fail "connection terminated" if $fh->eof;
fail "protocol violation; $m not expected";
}
die "$ourfn: $!" unless defined $got;
last if !$got;
print $fh "data-block ".length($d)."\n" or die $!;
- print $d or die $!;
+ print $fh $d or die $!;
}
- PF->eof or die "$ourfn $!";
PF->error and die "$ourfn $!";
print $fh "data-end\n" or die $!;
close PF;
return unless $we_are_responder;
# called even without $we_are_responder
printdebug "<< $command\n";
- print $command, "\n" or die $!;
+ print PO $command, "\n" or die $!;
}
sub responder_send_file ($$) {
return unless $we_are_responder;
printdebug "[[ $keyword $ourfn\n";
responder_send_command "file $keyword";
- protocol_send_file \*STDOUT, $ourfn;
+ protocol_send_file \*PO, $ourfn;
}
sub responder_receive_files ($@) {
printdebug "]] $keyword @ourfns\n";
responder_send_command "want $keyword";
foreach my $fn (@ourfns) {
- protocol_receive_file \*STDIN, $fn;
+ protocol_receive_file \*PI, $fn;
}
- protocol_expect { m/^files-end$/ } \*STDIN;
+ protocol_expect { m/^files-end$/ } \*PI;
}
#---------- remote protocol support, initiator ----------
if ($we_are_responder) {
my $m = join '', @_;
responder_send_command "progress ".length($m) or die $!;
- print $m or die $!;
+ print PO $m or die $!;
} else {
print @_, "\n";
}
}
responder_send_file('changes',$changesfile);
+ responder_send_command("param head $head");
my $tfn = sub { ".git/dgit/tag$_[0]"; };
my ($tagobjfn) =
die unless @rargs;
my ($dir) = @rargs;
$debugprefix = ' ';
- changedir $dir;
$we_are_responder = 1;
+
+ open PI, "<&STDIN" or die $!;
+ open STDIN, "/dev/null" or die $!;
+ open PO, ">&STDOUT" or die $!;
+ autoflush PO 1;
+ open STDOUT, ">&STDERR" or die $!;
autoflush STDOUT 1;
+
responder_send_command("dgit-remote-push-ready");
+
+ changedir $dir;
&cmd_push;
}
our %i_param;
-sub i_param ($) {
- $_[0] =~ m/^(\S+) (.*)$/;
+sub i_resp_param ($) {
+ $_[0] =~ m/^(\S+) (.*)$/ or badproto \*RO, "bad param spec";
$i_param{$1} = $2;
}
}
sub i_want_signed_tag {
+ printdebug Dumper(\%i_param, $i_dscfn);
defined $i_param{'head'} && defined $i_dscfn
or badproto \*RO, "sequencing error";
my $head = $i_param{'head'};