]> Sergey Matveev's repositories - public-inbox.git/commitdiff
v2writable: don't verify tip if reindexing
authorEric Wong <e@80x24.org>
Fri, 25 Dec 2020 10:21:14 +0000 (10:21 +0000)
committerEric Wong <e@80x24.org>
Sat, 26 Dec 2020 06:22:56 +0000 (06:22 +0000)
We only rely on git-rev-parse to resolve symbolic names ("HEAD")
to a SHA-* git commit ID.  We'll assume any git commit IDs we
get from SQLite DBs are valid and let "git-log" fail if it
isn't.

lib/PublicInbox/V2Writable.pm

index ca52874b6abdc87dc1031dffa9c4e823d42506ec..f20b5c7f0a75d5f22a0814929f5fc0cd0c3c6734 100644 (file)
@@ -1104,12 +1104,14 @@ sub sync_prepare ($$) {
                -d $git_dir or next; # missing epochs are fine
                my $git = PublicInbox::Git->new($git_dir);
                my $unit = { git => $git, epoch => $i };
+               my $tip;
                if ($reindex_heads) {
-                       $head = $reindex_heads->[$i] or next;
+                       $tip = $head = $reindex_heads->[$i] or next;
+               } else {
+                       $tip = $git->qx(qw(rev-parse -q --verify), $head);
+                       next if $?; # new repo
+                       chomp $tip;
                }
-               chomp(my $tip = $git->qx(qw(rev-parse -q --verify), $head));
-               next if $?; # new repo
-
                my $range = log_range($sync, $unit, $tip) or next;
                # can't use 'rev-list --count' if we use --diff-filter
                $pr->("$pfx $i.git counting $range ... ") if $pr;