]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Import.pm
Import.pm: When purging replace a purged file with a zero length file
[public-inbox.git] / lib / PublicInbox / Import.pm
index 4e3b4c55179766797b41960ea7c55bc266f210f4..3df7d98f298bd64a0ba84dbb8228ca27ae1617d3 100644 (file)
@@ -451,6 +451,7 @@ sub done {
 sub atfork_child {
        my ($self) = @_;
        foreach my $f (qw(in out)) {
+               next unless defined($self->{$f});
                close $self->{$f} or die "failed to close import[$f]: $!\n";
        }
 }
@@ -518,11 +519,12 @@ sub purge_oids {
                        push @buf, $buf;
                } elsif (/^M 100644 ([a-f0-9]+) (\w+)/) {
                        my ($oid, $path) = ($1, $2);
+                       $tree->{$path} = 1;
                        if ($purge->{$oid}) {
                                push @oids, $oid;
-                               delete $tree->{$path};
+                               my $cmd = "M 100644 inline $path\ndata 0\n\n";
+                               push @buf, $cmd;
                        } else {
-                               $tree->{$path} = 1;
                                push @buf, $_;
                        }
                } elsif (/^D (\w+)/) {