about summary refs log tree commit homepage
path: root/lib/PublicInbox/V2Writable.pm
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-04-01 23:15:04 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-04-01 23:25:04 +0000
commitc34a83286234ea1e876ebdf92a33744272bb6f4e (patch)
treea04f43151284e6893e23780438773f9ea07c9fba /lib/PublicInbox/V2Writable.pm
parent0321a1a9e7ae9c9d878d547ee67659ef8aa95689 (diff)
downloadpublic-inbox-c34a83286234ea1e876ebdf92a33744272bb6f4e.tar.gz
We need to ensure there is only one file in the top-level tree
at any commit so the "add; remove; add;" sequence on the same
message is detected properly.

Otherwise, git will not detect the second "add" unless
a second message is added to history.

Deletes are now stored in "d" (and not "D" or "_/D") at the
top-level, now.  There's no need to have a "_" to reduce churn
as "m" and "d" should never co-exist.  It's now lowercased to
make it easier-to-distinguish from "D" in git-log output.
Diffstat (limited to 'lib/PublicInbox/V2Writable.pm')
-rw-r--r--lib/PublicInbox/V2Writable.pm12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index c4368ccc..c8869bda 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -634,15 +634,19 @@ sub reindex {
                         -d $git->{git_dir} or next; # missing parts are fine
                         chomp($tip = $git->qx('rev-parse', $head)) unless $tip;
                         my $h = $cur == $max_git ? $tip : $head;
-                        my @count = ('rev-list', '--count', $h, '--', 'm');
-                        $regen_max += $git->qx(@count);
+
+                        # can't use 'rev-list --count' if we use --diff-filter
+                        my $fh = $git->popen(qw(log --pretty=tformat:%h
+                                        --no-notes --no-color --no-renames
+                                        --diff-filter=AM), $h, '--', 'm');
+                        ++$regen_max while <$fh>;
                 }
                 die "No messages found in $pfx/*.git, bug?\n" unless $regen_max;
                 $regen = \$regen_max;
         }
         my $D = {};
         my @cmd = qw(log --raw -r --pretty=tformat:%h
-                        --no-notes --no-color --no-abbrev);
+                        --no-notes --no-color --no-abbrev --no-renames);
 
         # if we are regenerating, we must not use a newer tip commit than what
         # the regeneration counter used:
@@ -663,7 +667,7 @@ sub reindex {
                         } elsif (/\A:\d{6} 100644 $x40 ($x40) [AM]\tm$/o) {
                                 $self->reindex_oid($mm_tmp, $D, $git, $1,
                                                 $regen);
-                        } elsif (m!\A:\d{6} 100644 $x40 ($x40) [AM]\t_/D$!o) {
+                        } elsif (/\A:\d{6} 100644 $x40 ($x40) [AM]\td$/o) {
                                 $self->mark_deleted($D, $git, $1);
                         }
                 }