fix sequencing for repo config statements

Without this, complex mirroring scenarios will be unpredictable.  For
example (abbreviating "gitolite.mirror." to "gimo.") something as simple
as this will not give "foo" his different mirror setup

    repo @all
        config gimo.master = "frodo"
        config gimo.slaves = "sam"

    repo foo
        config gimo.master = "sam"
        config gimo.slaves = "frodo gollum"

    repo foo bar
        RW  =   u1

Even worse things happen when you have wild cards.

Now, however, they all come in the right sequence and the most recent
one takes effect (unlike ACL rules, where the first match wins, because
there you're trying to just find a match and get out, while here you're
just mindlessly applying config lines in the right order).
This commit is contained in:
Sitaram Chamarty 2011-08-17 19:46:07 +05:30
parent 442d7ca29c
commit 056459aeda
12 changed files with 31 additions and 18 deletions

View file

@ -426,12 +426,24 @@ sub setup_git_configs
{ {
my ($repo, $git_configs_p) = @_; my ($repo, $git_configs_p) = @_;
while ( my ($key, $value) = each(%{ $git_configs_p->{$repo} }) ) { # new_wild calls us without checking!
if ($value ne "") { return unless $git_configs_p->{$repo};
$value =~ s/^"(.*)"$/$1/;
system("git", "config", $key, $value); # git_configs_p is a ref to a hash whose elements look like
} else { # {"reponame"}{sequence_number}{"key"} = "value";
system("git", "config", "--unset-all", $key);
my %rch = %{ $git_configs_p->{$repo} };
# %rch has elements that look like {sequence_number}{"key"} = "value"
for my $seq (sort { $a <=> $b } keys %rch) {
# and the final step is the repo config: {"key"} = "value"
my $rc = $rch{$seq};
while ( my ($key, $value) = each(%{ $rc }) ) {
if ($value ne "") {
$value =~ s/^"(.*)"$/$1/;
system("git", "config", $key, $value);
} else {
system("git", "config", "--unset-all", $key);
}
} }
} }
} }

View file

@ -32,7 +32,7 @@ use Exporter 'import';
# real constants # real constants
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
$current_data_version = '1.7'; $current_data_version = '2.0';
$ABRT = "\n\t\t***** ABORTING *****\n "; $ABRT = "\n\t\t***** ABORTING *****\n ";
$WARN = "\n\t\t***** WARNING *****\n "; $WARN = "\n\t\t***** WARNING *****\n ";

View file

@ -49,8 +49,9 @@ open STDOUT, ">", "/dev/null" if (@ARGV and shift eq '-q');
# names of repos whose ACLs don't make it into the main compiled config file # names of repos whose ACLs don't make it into the main compiled config file
# copy above desc to lite.pm -- my %split_conf = (); # copy above desc to lite.pm -- my %split_conf = ();
# rule sequence number # rule and config sequence numbers
my $rule_seq = 0; my $rule_seq = 0;
my $config_seq = 0;
# <sigh>... having been forced to use a list as described above, we lose some # <sigh>... having been forced to use a list as described above, we lose some
# efficiency due to the possibility of the same {ref, perms} pair showing up # efficiency due to the possibility of the same {ref, perms} pair showing up
@ -244,7 +245,7 @@ sub parse_conf_line
die "$ABRT git config $key not allowed\ncheck GL_GITCONFIG_KEYS in the rc file for how to allow it\n" if (@matched < 1); die "$ABRT git config $key not allowed\ncheck GL_GITCONFIG_KEYS in the rc file for how to allow it\n" if (@matched < 1);
for my $repo (@{ $repos_p }) # each repo in the current stanza for my $repo (@{ $repos_p }) # each repo in the current stanza
{ {
$git_configs{$repo}{$key} = $value; $git_configs{$repo}{$config_seq++}{$key} = $value;
# force entry in %repos. Without this, a repo para with just a # force entry in %repos. Without this, a repo para with just a
# config line and no ACLs gets ignored in the output # config line and no ACLs gets ignored in the output

View file

@ -1,4 +1,4 @@
$data_version = '1.7'; $data_version = '2.0';
%repos = ( %repos = (
'aa' => { 'aa' => {
'R' => { 'R' => {

View file

@ -1,4 +1,4 @@
$data_version = '1.7'; $data_version = '2.0';
%repos = ( %repos = (
'aa' => { 'aa' => {
'R' => { 'R' => {

View file

@ -1,4 +1,4 @@
$data_version = '1.7'; $data_version = '2.0';
%repos = (); %repos = ();
%split_conf = ( %split_conf = (
'aa' => 1, 'aa' => 1,

View file

@ -1,4 +1,4 @@
$data_version = '1.7'; $data_version = '2.0';
%repos = ( %repos = (
'@g1' => { '@g1' => {
'@g1' => [ '@g1' => [

View file

@ -1,4 +1,4 @@
$data_version = '1.7'; $data_version = '2.0';
%repos = ( %repos = (
'aa' => { 'aa' => {
'R' => { 'R' => {

View file

@ -1,4 +1,4 @@
$data_version = '1.7'; $data_version = '2.0';
%repos = ( %repos = (
'aa' => { 'aa' => {
'R' => { 'R' => {

View file

@ -1,4 +1,4 @@
$data_version = '1.7'; $data_version = '2.0';
%repos = (); %repos = ();
%split_conf = ( %split_conf = (
'aa' => 1, 'aa' => 1,

View file

@ -1,4 +1,4 @@
$data_version = '1.7'; $data_version = '2.0';
%repos = ( %repos = (
'aa' => { 'aa' => {
'@g1' => [ '@g1' => [

View file

@ -1,4 +1,4 @@
$data_version = '1.7'; $data_version = '2.0';
%repos = (); %repos = ();
%groups = ( %groups = (
'@g1' => { '@g1' => {