]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
cindex: fix prune to not wipe out the entire index
authorEric Wong <e@80x24.org>
Fri, 21 Apr 2023 11:52:03 +0000 (11:52 +0000)
committerEric Wong <e@80x24.org>
Fri, 21 Apr 2023 12:14:30 +0000 (12:14 +0000)
Oops :x  I noticed this while I was working on a major optimization
for prune...

lib/PublicInbox/CodeSearchIdx.pm
t/cindex.t

index 9712313344ccd0e462d4b58bc298574bb5695608..fa761ed0f3ac21f555f5b11810aa271710e56d96 100644 (file)
@@ -803,7 +803,7 @@ EOM
                my $f = "$git_dir/objects/info/alternates";
                open $ALT_FH{$fmt}, '>', $f or die "open($f): $!";
        }
-       say { $ALT_FH{$fmt} } $out or die "say: $!";
+       say { $ALT_FH{$fmt} } $objdir or die "say: $!";
 }
 
 sub prep_alternate_start {
index d40f73ff6ac251c834dac7e6394686076cc8ed72..8b89ebffbee6b456de77b497040641b82ba4fa17 100644 (file)
@@ -165,6 +165,8 @@ if ('--prune') {
        $csrch->reopen;
        is(scalar($csrch->mset('s:hi')->items), 0,
                'hit stays pruned since GIT_DIR was previously pruned');
+       isnt(scalar($csrch->mset('s:NUL')->items), 0,
+               'prune did not clobber entire index');
 }
 
 File::Path::remove_tree("$tmp/ext");