From: Eric Wong <e@80x24.org>
Date: Mon, 28 Nov 2022 05:31:29 +0000 (+0000)
Subject: lei_mirror: fix glob semantics to match end-of-path
X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=ec46cae1685813ada8bf5ef5be13d9024ad9cc90;p=public-inbox.git

lei_mirror: fix glob semantics to match end-of-path

Globs such as `*/foo' should not match `*/foobar',
this allows cloning only `git' and not
`gitolite-transparency-log` off lore
---

diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm
index a7ddfcd2..40164b67 100644
--- a/lib/PublicInbox/LeiMirror.pm
+++ b/lib/PublicInbox/LeiMirror.pm
@@ -506,18 +506,18 @@ sub multi_inbox ($$$) {
 	my $n = scalar(keys %$v2) + scalar(@v1);
 	my @orig = defined($incl // $excl) ? (keys %$v2, @v1) : ();
 	if (defined $incl) {
-		my $re = '(?:'.join('|', map {
-				$self->{lei}->glob2re($_) // qr/\A\Q$_\E\z/
-			} @$incl).')';
+		my $re = '(?:'.join('\\z|', map {
+				$self->{lei}->glob2re($_) // qr/\A\Q$_\E/
+			} @$incl).'\\z)';
 		my @gone = delete @$v2{grep(!/$re/, keys %$v2)};
 		delete @$m{map { @$_ } @gone} and $self->{-culled_manifest} = 1;
 		delete @$m{grep(!/$re/, @v1)} and $self->{-culled_manifest} = 1;
 		@v1 = grep(/$re/, @v1);
 	}
 	if (defined $excl) {
-		my $re = '(?:'.join('|', map {
-				$self->{lei}->glob2re($_) // qr/\A\Q$_\E\z/
-			} @$excl).')';
+		my $re = '(?:'.join('\\z|', map {
+				$self->{lei}->glob2re($_) // qr/\A\Q$_\E/
+			} @$excl).'\\z)';
 		my @gone = delete @$v2{grep(/$re/, keys %$v2)};
 		delete @$m{map { @$_ } @gone} and $self->{-culled_manifest} = 1;
 		delete @$m{grep(/$re/, @v1)} and $self->{-culled_manifest} = 1;