From bc0a478e64dcbd7944ebbf894507665ba794ad17 Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Sat, 30 Jan 2010 04:48:51 +0530 Subject: [PATCH] auth: minor fix to reporting on wildcard repos Mpenz asked what would happen if the config looked like repo foo/abc R sitaram repo foo/.* RW sitaram If you asked for an expand of '.*', it would pick up permissions from the second set (i.e., "RW") and print them against "foo/abc". This is misleading, since those are not the permissions that will actually be *used*. Gitolite always uses the more specific form if it is given, which means your actual permissions are just "R". This patch is to prevent that misleading reporting in this corner case. --- src/gitolite.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gitolite.pm b/src/gitolite.pm index cccd310..ba72f93 100644 --- a/src/gitolite.pm +++ b/src/gitolite.pm @@ -230,6 +230,7 @@ sub expand_wild # get the list of repo patterns &parse_acl($GL_CONF_COMPILED, "", "NOBODY", "NOBODY", "NOBODY"); my @repopatts = grep { $_ !~ $REPONAME_PATT } sort keys %repos; + my %reponames = map { $_ => 1 } grep { $_ =~ $REPONAME_PATT } sort keys %repos; # display matching repos (from *all* the repos in the system) that $user # has at least "R" access to @@ -239,6 +240,11 @@ sub expand_wild chomp ($actual_repo); $actual_repo =~ s/^\.\///; $actual_repo =~ s/\.git$//; + # actual_repo should not be present "as is" in the config, because if + # it does, those permissions will override anything inherited from a + # wildcard that also happens to match, and it would be misleading to + # show that here + next if $reponames{$actual_repo}; # it has to match the pattern being expanded next unless $actual_repo =~ /^$repo$/; # it also has to match one of the repo patterns in %repos (which we