From deda3da18271ab86e1d8be971159654d31a23885 Mon Sep 17 00:00:00 2001 From: Teemu Matilainen Date: Fri, 26 Feb 2010 16:55:28 +0200 Subject: [PATCH] auth: do not anchor the pattern given for expand Currently the pattern of expand command is line anchored. This is different than in e.g. grep, and causes extra work to add '.*' prefix and/or suffix in many use cases. The new semantics now mean you might get more matches than you would have gotten earlier. However, the expand command is still totally undocumented, so I think it is acceptable to change the functionality. ;) This patch removes the anchoring. So for earlier behavior the specified pattern needs be in form of '^$'. The default pattern is also changed from '.*' to '^', so there might be even a small speed improvement. =) Signed-off-by: Teemu Matilainen --- src/gitolite.pm | 2 +- src/gl-auth-command | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gitolite.pm b/src/gitolite.pm index 46d537c..c61a566 100644 --- a/src/gitolite.pm +++ b/src/gitolite.pm @@ -320,7 +320,7 @@ sub expand_wild $actual_repo =~ s/^\.\///; $actual_repo =~ s/\.git$//; # actual_repo has to match the pattern being expanded - next unless $actual_repo =~ /^$repo$/; + next unless $actual_repo =~ /$repo/; # if actual_repo is present "as is" in the config, those # permissions will override anything inherited from a # wildcard that also happens to match diff --git a/src/gl-auth-command b/src/gl-auth-command index 443bd8f..3d7eefc 100755 --- a/src/gl-auth-command +++ b/src/gl-auth-command @@ -115,7 +115,7 @@ if ($ENV{SSH_ORIGINAL_COMMAND} =~ $CUSTOM_COMMANDS) { my $cmd = $ENV{SSH_ORIGINAL_COMMAND}; my ($verb, $repo) = ($cmd =~ /^\s*(\S+)(?:\s+\/?(.*?)(?:.git)?)?$/); # deal with "no argument" cases - $verb eq 'expand' ? $repo = '.*' : die "$verb needs an argument\n" unless $repo; + $verb eq 'expand' ? $repo = '^' : die "$verb needs an argument\n" unless $repo; if ($repo =~ $REPONAME_PATT and $verb =~ /getperms|setperms/) { # with an actual reponame, you can "getperms" or "setperms" get_set_perms($repo_base_abs, $repo, $verb, $user);