From 0b68365860e19e82dd76d97d67ec4f7b0d825a95 Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Sat, 6 Aug 2011 08:43:24 +0530 Subject: [PATCH] fix accumulation of 'config' (git config) lines If a repo matches multiple patterns, 'config' lines were being picked up only from one of the 'repo' paras, instead of from all applicable ones. --- src/gitolite.pm | 9 ++++-- src/gl-compile-conf | 5 ++++ t/t55-repo-configs-wild-without-CREATOR | 37 ++++++++++++++++++++++++- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/gitolite.pm b/src/gitolite.pm index bfced77..191cbfa 100644 --- a/src/gitolite.pm +++ b/src/gitolite.pm @@ -644,13 +644,18 @@ sub parse_acl # the old "convenience copy" thing. Now on steroids :) # note that when copying the @all entry, we retain the destination name as - # @all; we dont change it to $repo or $gl_user + # @all; we dont change it to $repo or $gl_user. We need to maintain this + # distinction to be able to print the @/#/& prefixes in the report output + # (see doc/report-output.mkd) for my $r ('@all', @repo_plus) { my $dr = $repo; $dr = '@all' if $r eq '@all'; $repos{$dr}{DELETE_IS_D} = 1 if $repos{$r}{DELETE_IS_D}; $repos{$dr}{CREATE_IS_C} = 1 if $repos{$r}{CREATE_IS_C}; $repos{$dr}{NAME_LIMITS} = 1 if $repos{$r}{NAME_LIMITS}; - $git_configs{$dr} = $git_configs{$r} if $git_configs{$r}; + # this needs to copy the key-value pairs from RHS to LHS, not just + # assign RHS to LHS! However, we want to roll in '@all' configs also + # into the actual $repo; there's no need to preserve the distinction + map { $git_configs{$repo}{$_} = $git_configs{$r}{$_} } keys %{$git_configs{$r}} if $git_configs{$r}; for my $u ('@all', "$gl_user - wild", @user_plus, keys %perm_cats) { my $du = $gl_user; $du = '@all' if $u eq '@all' or ($perm_cats{$u} || '') eq '@all'; diff --git a/src/gl-compile-conf b/src/gl-compile-conf index 5d59358..56d023c 100755 --- a/src/gl-compile-conf +++ b/src/gl-compile-conf @@ -245,6 +245,11 @@ sub parse_conf_line for my $repo (@{ $repos_p }) # each repo in the current stanza { $git_configs{$repo}{$key} = $value; + + # force entry in %repos. Without this, a repo para with just a + # config line and no ACLs gets ignored in the output + $repos{$repo}{HAS_CONFIG} = 1; + # no problem if it's a plain repo (non-pattern, non-groupname) # OR wild configs are allowed unless ( ($repo =~ $REPONAME_PATT and $repo !~ /^@/) or $GL_GITCONFIG_WILD) { diff --git a/t/t55-repo-configs-wild-without-CREATOR b/t/t55-repo-configs-wild-without-CREATOR index af0bd0e..e3abb13 100644 --- a/t/t55-repo-configs-wild-without-CREATOR +++ b/t/t55-repo-configs-wild-without-CREATOR @@ -30,7 +30,7 @@ do name "update rc file to allow foo.*" catrc cp ~/1 ~/junk - perl -pi -e 's/GL_GITCONFIG_KEYS = ""/GL_GITCONFIG_KEYS = "foo\\\\..*"/' ~/junk + perl -pi -e 's/GL_GITCONFIG_KEYS = ""/GL_GITCONFIG_KEYS = "gl\\\\..* foo\\\\..*"/' ~/junk cat ~/junk | runremote dd of=.gitolite.rc catrc expect "GL_GITCONFIG_KEYS.*foo" @@ -130,6 +130,41 @@ do expect '^.foo' expect 'frob = nitz' + name "check cumulative configs" + echo " + repo @all + config gl.mirror.master = \"git@gc.com git@gh.net\" + + @leads = u1 u2 + @devs = u1 u2 u3 u4 + + @gbar = bar/..* + repo @gbar + C = @leads + RW+ = CREATOR + RW = @leads + config foo.frob = nitz + + repo b../tr.* + config foo.nitz = ham + " | ugc -r + expect_push_ok "master -> master" + + name "check try1 has foo.frob" + runremote cat $TEST_BASE/bar/try1.git/config + expect '^.foo' + expect 'frob = nitz' + + name "check try1 has foo.nitz" + runremote cat $TEST_BASE/bar/try2.git/config + expect '^.foo' + expect 'nitz = ham' + + name "check @all config works..." + runremote cat $TEST_BASE/bar/try2.git/config + expect gl.\"mirror\" + expect master = .git.gc.com git.gh.net + name INTERNAL done done