From: Ian Jackson Date: Wed, 9 Oct 2013 06:19:56 +0000 (+0100) Subject: wip changes for remote push - provide i_tmp X-Git-Tag: debian/0.16_experimental2^2~16 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=commitdiff_plain;h=874b84944d26794d2d8031c44bc28c22ed9ca3f3 wip changes for remote push - provide i_tmp --- diff --git a/dgit b/dgit index 6bd95e99..bac0baf0 100755 --- a/dgit +++ b/dgit @@ -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 $@; } }