Split brain is going to need the maintainer tag on the dgit server.
Allow clients to push the _both_ the DEP-14 and new dgit archive/ tag.
In this case dgit-repos-server can largely ignore the DEP-14 tag.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
exec qw(git show-ref);
die $!;
}
exec qw(git show-ref);
die $!;
}
- my %got = qw(tag 0 head 0);
+ my %got = qw(newtag 0 omtag 0 head 0);
while (<SR>) {
chomp or die;
printdebug " show-refs| $_\n";
s/^\S*[1-9a-f]\S* (\S+)$/$1/ or die;
next if m{^refs/heads/master$};
my $wh =
while (<SR>) {
chomp or die;
printdebug " show-refs| $_\n";
s/^\S*[1-9a-f]\S* (\S+)$/$1/ or die;
next if m{^refs/heads/master$};
my $wh =
- m{^refs/tags/} ? 'tag' :
+ m{^refs/tags/archive/} ? 'newtag' :
+ m{^refs/tags/} ? 'omtag' :
m{^refs/dgit/} ? 'head' :
die;
m{^refs/dgit/} ? 'head' :
die;
die if $got{$wh}++;
}
$!=0; $?=0; close SR or $?==256 or die "$? $!";
printdebug "installprospective ?\n";
die Dumper(\%got)." -- missing refs in new repo"
die if $got{$wh}++;
}
$!=0; $?=0; close SR or $?==256 or die "$? $!";
printdebug "installprospective ?\n";
die Dumper(\%got)." -- missing refs in new repo"
- if grep { !$_ } values %got;
+ unless $got{head} && grep { m/tag$/ && $got{$_} } keys %got;
our ($tagname, $tagval, $suite, $oldcommit, $commit);
our ($version, %tagh);
our ($tagname, $tagval, $suite, $oldcommit, $commit);
our ($version, %tagh);
+our ($maint_tagname, $maint_tagval);
our ($tagexists_error);
sub readupdates () {
printdebug " updates ...\n";
our ($tagexists_error);
sub readupdates () {
printdebug " updates ...\n";
while (<STDIN>) {
chomp or die;
printdebug " upd.| $_\n";
m/^(\S+) (\S+) (\S+)$/ or die "$_ ?";
my ($old, $sha1, $refname) = ($1, $2, $3);
if ($refname =~ m{^refs/tags/(?=(?:archive/)?$distro/)}) {
while (<STDIN>) {
chomp or die;
printdebug " upd.| $_\n";
m/^(\S+) (\S+) (\S+)$/ or die "$_ ?";
my ($old, $sha1, $refname) = ($1, $2, $3);
if ($refname =~ m{^refs/tags/(?=(?:archive/)?$distro/)}) {
- reject "pushing multiple tags!" if defined $tagname;
- $tagname = $'; #';
- $tagval = $sha1;
- $tagexists_error= "tag $tagname already exists -".
+ my $tn = $'; #';
+ $tags{$tn} = $sha1;
+ $tagexists_error= "tag $tn already exists -".
" not replacing previously-pushed version"
if $old =~ m/[^0]/;
} elsif ($refname =~ m{^refs/dgit/}) {
" not replacing previously-pushed version"
if $old =~ m/[^0]/;
} elsif ($refname =~ m{^refs/dgit/}) {
}
STDIN->error and die $!;
}
STDIN->error and die $!;
- reject "push is missing tag ref update" unless defined $tagname;
+ reject "push is missing tag ref update" unless %tags;
+ my @newtags = grep { m#^archive/# } keys %tags;
+ my @omtags = grep { !m#^archive/# } keys %tags;
+ reject "pushing too many similar tags" if @newtags>1 || @omtags>1;
+ if (@newtags) {
+ ($tagname) = @newtags;
+ ($maint_tagname) = @omtags;
+ } else {
+ ($tagname) = @omtags or die;
+ }
+ $tagval = $tags{$tagname};
+ $maint_tagval = $tags{$maint_tagname // ''};
+
reject "push is missing head ref update" unless defined $suite;
printdebug " updates ok.\n";
}
reject "push is missing head ref update" unless defined $suite;
printdebug " updates ok.\n";
}
my @cmd = @cmdbase;
push @cmd, "$commit:refs/dgit/$suite",
"$tagval:refs/tags/$tagname";
my @cmd = @cmdbase;
push @cmd, "$commit:refs/dgit/$suite",
"$tagval:refs/tags/$tagname";
+ push @cmd, "$maint_tagval:refs/tags/$maint_tagname"
+ if defined $maint_tagname;
debugcmd '+',@cmd;
$!=0;
my $r = system @cmd;
debugcmd '+',@cmd;
$!=0;
my $r = system @cmd;
mustfail 'push is missing head ref update' +$push_spec2
mustfail 'pushing unexpected ref' $push_spec HEAD:refs/wombat
mustfail 'pushing multiple heads' $push_spec HEAD:refs/dgit/wombat
mustfail 'push is missing head ref update' +$push_spec2
mustfail 'pushing unexpected ref' $push_spec HEAD:refs/wombat
mustfail 'pushing multiple heads' $push_spec HEAD:refs/dgit/wombat
-mustfail 'pushing multiple tags' $push_spec HEAD:refs/tags/$tagpfx/wombat
+mustfail E:'pushing multiple tags|pushing too many similar tags' \
+ $push_spec HEAD:refs/tags/$tagpfx/wombat