diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2013-10-09 07:19:56 +0100 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2013-10-09 07:19:56 +0100 |
commit | 874b84944d26794d2d8031c44bc28c22ed9ca3f3 (patch) | |
tree | d4b8b60b6b220c636c774ffada18b1108803ec08 /dgit | |
parent | 76708972d08328b32cef22ec1cf86d0aec1541fa (diff) |
wip changes for remote push - provide i_tmp
Diffstat (limited to 'dgit')
-rwxr-xr-x | dgit | 28 |
1 files changed, 22 insertions, 6 deletions
@@ -28,6 +28,7 @@ use File::Basename; use Dpkg::Version; use POSIX; use IPC::Open2; +use File::Temp; our $our_version = 'UNRELEASED'; ###substituted### @@ -1360,6 +1361,15 @@ sub cmd_remote_push_responder { &cmd_push; } +our $i_tmp; + +sub i_cleanup { + local ($@); + return unless defined $i_tmp; + chdir "/" or die $!; + eval { rmtree $i_tmp; }; +} + sub cmd_rpush { my $host = nextarg; my $dir; @@ -1378,12 +1388,18 @@ sub cmd_rpush { push @rdgit, @ARGV; my @cmd = (@ssh, $host, shellquote @rdgit); my $pid = open2(\*RO, \*RI, @cmd); - initiator_expect { m/^dgit-remote-push-ready/ }; - for (;;) { - initiator_expect { m/^(\S+)\s+(.*)$/ }; - my ($icmd,$iargs) = ($1, $2); - $icmd =~ s/\-/_/g; - { no strict qw(refs); &{"i_resp_$icmd"}($iargs); } + eval { + $i_tmp = tempdir(); + chdir $i_tmp or die "$i_tmp $!"; + initiator_expect { m/^dgit-remote-push-ready/ }; + for (;;) { + initiator_expect { m/^(\S+)(?: (.*))?$/ }; + my ($icmd,$iargs) = ($1, $2); + i_method "i_resp_", $icmd, $iargs; + } + }; + i_cleanup(); + die $@; } } |