mirror of
https://github.com/wahyd4/gitolite.git
synced 2026-08-08 20:45:57 +10:00
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:
+18
-6
@@ -426,12 +426,24 @@ sub setup_git_configs
|
||||
{
|
||||
my ($repo, $git_configs_p) = @_;
|
||||
|
||||
while ( my ($key, $value) = each(%{ $git_configs_p->{$repo} }) ) {
|
||||
if ($value ne "") {
|
||||
$value =~ s/^"(.*)"$/$1/;
|
||||
system("git", "config", $key, $value);
|
||||
} else {
|
||||
system("git", "config", "--unset-all", $key);
|
||||
# new_wild calls us without checking!
|
||||
return unless $git_configs_p->{$repo};
|
||||
|
||||
# git_configs_p is a ref to a hash whose elements look like
|
||||
# {"reponame"}{sequence_number}{"key"} = "value";
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ use Exporter 'import';
|
||||
# real constants
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
$current_data_version = '1.7';
|
||||
$current_data_version = '2.0';
|
||||
|
||||
$ABRT = "\n\t\t***** ABORTING *****\n ";
|
||||
$WARN = "\n\t\t***** WARNING *****\n ";
|
||||
|
||||
+3
-2
@@ -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
|
||||
# copy above desc to lite.pm -- my %split_conf = ();
|
||||
|
||||
# rule sequence number
|
||||
# rule and config sequence numbers
|
||||
my $rule_seq = 0;
|
||||
my $config_seq = 0;
|
||||
|
||||
# <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
|
||||
@@ -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);
|
||||
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
|
||||
# config line and no ACLs gets ignored in the output
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$data_version = '1.7';
|
||||
$data_version = '2.0';
|
||||
%repos = (
|
||||
'aa' => {
|
||||
'R' => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$data_version = '1.7';
|
||||
$data_version = '2.0';
|
||||
%repos = (
|
||||
'aa' => {
|
||||
'R' => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$data_version = '1.7';
|
||||
$data_version = '2.0';
|
||||
%repos = ();
|
||||
%split_conf = (
|
||||
'aa' => 1,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$data_version = '1.7';
|
||||
$data_version = '2.0';
|
||||
%repos = (
|
||||
'@g1' => {
|
||||
'@g1' => [
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$data_version = '1.7';
|
||||
$data_version = '2.0';
|
||||
%repos = (
|
||||
'aa' => {
|
||||
'R' => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$data_version = '1.7';
|
||||
$data_version = '2.0';
|
||||
%repos = (
|
||||
'aa' => {
|
||||
'R' => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$data_version = '1.7';
|
||||
$data_version = '2.0';
|
||||
%repos = ();
|
||||
%split_conf = (
|
||||
'aa' => 1,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$data_version = '1.7';
|
||||
$data_version = '2.0';
|
||||
%repos = (
|
||||
'aa' => {
|
||||
'@g1' => [
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$data_version = '1.7';
|
||||
$data_version = '2.0';
|
||||
%repos = ();
|
||||
%groups = (
|
||||
'@g1' => {
|
||||
|
||||
Reference in New Issue
Block a user