]> Sergey Matveev's repositories - public-inbox.git/commitdiff
Import.pm: When purging replace a purged file with a zero length file
authorEric W. Biederman <ebiederm@xmission.com>
Fri, 10 Aug 2018 00:08:22 +0000 (19:08 -0500)
committerEric Wong <e@80x24.org>
Fri, 10 Aug 2018 08:13:38 +0000 (08:13 +0000)
This ensures that the number of added files remains the same and thus
the article numbers derived from a repository will remain the same.

I think this is the last place in public-inbox that has to be tweaked to
guarantee the generated article number will remain the same in an public
inbox archive.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
lib/PublicInbox/Import.pm

index bfa7a8053297a50c44c5e1f4fe173fbd7f882bbf..3df7d98f298bd64a0ba84dbb8228ca27ae1617d3 100644 (file)
@@ -519,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+)/) {