]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei_mirror: fix glob semantics to match end-of-path
authorEric Wong <e@80x24.org>
Mon, 28 Nov 2022 05:31:29 +0000 (05:31 +0000)
committerEric Wong <e@80x24.org>
Mon, 28 Nov 2022 23:38:55 +0000 (23:38 +0000)
Globs such as `*/foo' should not match `*/foobar',
this allows cloning only `git' and not
`gitolite-transparency-log` off lore

lib/PublicInbox/LeiMirror.pm

index a7ddfcd2834a11146f762af48d6da7cab7add198..40164b676ddb7591536789161ef3a7d14ab1ef35 100644 (file)
@@ -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;