diff options
author | Eric Wong <e@80x24.org> | 2019-01-30 10:33:55 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-01-30 10:33:55 +0000 |
commit | 2d5e54cc2e4bae1c370c70cc50e40ef21e82b59c (patch) | |
tree | ac2edbe30c762c27dc4359dac5fe3275acc52128 /lib/PublicInbox/SolverGit.pm | |
parent | b018ba7021fc4acd8534d9c4eba69da00a593853 (diff) | |
download | public-inbox-2d5e54cc2e4bae1c370c70cc50e40ef21e82b59c.tar.gz |
Xapian will interpret ".." as ranges, even quoted phrases. So break up words on ".." since punctuation (AFAIK) is not searchable, anyways.
Diffstat (limited to 'lib/PublicInbox/SolverGit.pm')
-rw-r--r-- | lib/PublicInbox/SolverGit.pm | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm index 59d2c93c..c5025269 100644 --- a/lib/PublicInbox/SolverGit.pm +++ b/lib/PublicInbox/SolverGit.pm @@ -170,6 +170,13 @@ sub extract_diff ($$$$$) { sub path_searchable ($) { defined($_[0]) && $_[0] =~ m!\A[\w/\. \-]+\z! } +# ".." appears in path names, which confuses Xapian into treating +# it as a range query. So we split on ".." since Xapian breaks +# on punctuation anyways: +sub filename_query ($) { + join('', map { qq( dfn:"$_") } split(/\.\./, $_[0])); +} + sub find_extract_diff ($$$) { my ($self, $ibx, $want) = @_; my $srch = $ibx->search or return; @@ -187,11 +194,11 @@ sub find_extract_diff ($$$) { my $path_b = $want->{path_b}; if (path_searchable($path_b)) { - $q .= qq{ dfn:"$path_b"}; + $q .= filename_query($path_b); my $path_a = $want->{path_a}; if (path_searchable($path_a) && $path_a ne $path_b) { - $q .= qq{ dfn:"$path_a"}; + $q .= filename_query($path_a); } } |