From: Eric Wong Date: Fri, 21 Apr 2023 11:52:03 +0000 (+0000) Subject: cindex: fix prune to not wipe out the entire index X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c23413abbe1db6e96af4a028f69613d1340e880c;p=thirdparty%2Fpublic-inbox.git cindex: fix prune to not wipe out the entire index Oops :x I noticed this while I was working on a major optimization for prune... --- diff --git a/lib/PublicInbox/CodeSearchIdx.pm b/lib/PublicInbox/CodeSearchIdx.pm index 971231334..fa761ed0f 100644 --- a/lib/PublicInbox/CodeSearchIdx.pm +++ b/lib/PublicInbox/CodeSearchIdx.pm @@ -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 { diff --git a/t/cindex.t b/t/cindex.t index d40f73ff6..8b89ebffb 100644 --- a/t/cindex.t +++ b/t/cindex.t @@ -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");