X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=dgit;h=4aefa085a6b3835d16384b1a218ff5cf18f0cf73;hb=496685d614bba3670ba89fda0802750b8ac54a9d;hp=bf0d6398431340e1ff53feea1e478e472f75bb39;hpb=ee802f8a6760c88b641f05d4dee51439a9a42c96;p=dgit.git diff --git a/dgit b/dgit index bf0d6398..4aefa085 100755 --- a/dgit +++ b/dgit @@ -65,6 +65,7 @@ our $quilt_modes_re = 'linear|smash|auto|nofix|nocheck|gbp|unapplied'; our $we_are_responder; our $initiator_tempdir; our $patches_applied_dirtily = 00; +our $tagformat_want; our $tagformat; our $tagformatfn; @@ -245,6 +246,7 @@ sub quiltmode_splitbrain () { # # > param head HEAD # > param csuite SUITE +# > param tagformat old|new # # > previously REFNAME=OBJNAME # if --deliberately-not-fast-forward # # goes into tag, for replay prevention @@ -1241,24 +1243,25 @@ sub create_remote_git_repo () { sub select_tagformat () { # sets $tagformatfn - return if $tagformatfn && !$tagformat; - die 'bug' if $tagformatfn && $tagformat; - # ... $tagformat assigned after previous select_tagformat + return if $tagformatfn && !$tagformat_want; + die 'bug' if $tagformatfn && $tagformat_want; + # ... $tagformat_want assigned after previous select_tagformat my (@supported) = split /\,/, access_cfg('dgit-tag-format'); printdebug "select_tagformat supported @supported\n"; - $tagformat //= [ $supported[0], "distro access configuration", 0 ]; - printdebug "select_tagformat specified @$tagformat\n"; + $tagformat_want //= [ $supported[0], "distro access configuration", 0 ]; + printdebug "select_tagformat specified @$tagformat_want\n"; - my ($fmt,$why,$override) = @$tagformat; + my ($fmt,$why,$override) = @$tagformat_want; fail "target distro supports tag formats @supported". " but have to use $fmt ($why)" unless $override or grep { $_ eq $fmt } @supported; - $tagformat = undef; + $tagformat_want = undef; + $tagformat = $fmt; $tagformatfn = ${*::}{"debiantag_$fmt"}; fail "trying to use unknown tag format \`$fmt' ($why) !" @@ -1938,12 +1941,12 @@ sub push_parse_dsc ($$$) { } sub push_mktag ($$$$$$$) { - my ($head,$clogp,$tag, + my ($dgithead,$clogp,$dgittag, $dscfn, $changesfile,$changesfilewhat, - $tfn) = @_; + $tfnbase) = @_; - $dsc->{$ourdscfield[0]} = $head; + $dsc->{$ourdscfield[0]} = $dgithead; $dsc->save("$dscfn.tmp") or die $!; my $changes = parsecontrol($changesfile,$changesfilewhat); @@ -1961,8 +1964,12 @@ sub push_mktag ($$$$$$$) { my $authline = clogp_authline $clogp; my $delibs = join(" ", "",@deliberatelies); my $declaredistro = access_basedistro(); - open TO, '>', $tfn->('.tmp') or die $!; - print TO <', $tfn->('.tmp') or die $!; + print TO <('.tmp'); - if ($sign) { - if (!defined $keyid) { - $keyid = access_cfg('keyid','RETURN-UNDEF'); - } - if (!defined $keyid) { - $keyid = getfield $clogp, 'Maintainer'; - } - unlink $tfn->('.tmp.asc') or $!==&ENOENT or die $!; - my @sign_cmd = (@gpg, qw(--detach-sign --armor)); - push @sign_cmd, qw(-u),$keyid if defined $keyid; - push @sign_cmd, $tfn->('.tmp'); - runcmd_ordryrun @sign_cmd; - if (act_scary()) { - $tagobjfn = $tfn->('.signed.tmp'); - runcmd shell_cmd "exec >$tagobjfn", qw(cat --), - $tfn->('.tmp'), $tfn->('.tmp.asc'); + my $tagobjfn = $tfn->('.tmp'); + if ($sign) { + if (!defined $keyid) { + $keyid = access_cfg('keyid','RETURN-UNDEF'); + } + if (!defined $keyid) { + $keyid = getfield $clogp, 'Maintainer'; + } + unlink $tfn->('.tmp.asc') or $!==&ENOENT or die $!; + my @sign_cmd = (@gpg, qw(--detach-sign --armor)); + push @sign_cmd, qw(-u),$keyid if defined $keyid; + push @sign_cmd, $tfn->('.tmp'); + runcmd_ordryrun @sign_cmd; + if (act_scary()) { + $tagobjfn = $tfn->('.signed.tmp'); + runcmd shell_cmd "exec >$tagobjfn", qw(cat --), + $tfn->('.tmp'), $tfn->('.tmp.asc'); + } } - } + return $tagobjfn; + }; - return ($tagobjfn); + my @r; + push @r, $mktag->($tfnbase, $dgithead, $dgittag); + return @r; } sub sign_changes ($) { @@ -2107,6 +2118,7 @@ END responder_send_file('changes',$changesfile); responder_send_command("param head $head"); responder_send_command("param csuite $csuite"); + responder_send_command("param tagformat $tagformat"); if (deliberately_not_fast_forward) { git_for_each_ref(lrfetchrefs, sub { @@ -2129,7 +2141,7 @@ END $tagobjfn = $tfn->('.signed.tmp'); responder_receive_files('signed-tag', $tagobjfn); } else { - $tagobjfn = + ($tagobjfn) = push_mktag($head,$clogp,$tag, $dscpath, $changesfile,$changesfile, @@ -2382,9 +2394,9 @@ sub rpush_handle_protovsn_bothends () { if ($protovsn < 4) { fail "rpush negotiated protocol version $protovsn". " which supports old tag format only". - " but trying to use new format (".$tagformat->[1].")" - if $tagformat && $tagformat->[0] ne 'old'; - $tagformat = ['old', "rpush negotiated protocol $protovsn", 0]; + " but trying to use new format (".$tagformat_want->[1].")" + if $tagformat_want && $tagformat_want->[0] ne 'old'; + $tagformat_want = ['old', "rpush negotiated protocol $protovsn", 0]; } select_tagformat(); } @@ -2552,11 +2564,18 @@ sub i_want_signed_tag { my $head = $i_param{'head'}; die if $head =~ m/[^0-9a-f]/ || $head !~ m/^../; + select_tagformat(); + if ($protovsn >= 4) { + my $p = $i_param{'tagformat'} // ''; + $p eq $tagformat + or badproto \*RO, "tag format mismatch: $p vs. $tagformat"; + } + die unless $i_param{'csuite'} =~ m/^$suite_re$/; $csuite = $&; push_parse_dsc $i_dscfn, 'remote dsc', $i_version; - my $tagobjfn = + my ($tagobjfn) = push_mktag $head, $i_clogp, $i_tag, $i_dscfn, $i_changesfn, 'remote changes', @@ -3844,7 +3863,7 @@ sub parseopts () { } elsif (m/^--dgit-tag-format=(old|new)$/s) { # undocumented, for testing push @ropts, $_; - $tagformat = [ $1, 'command line', 1 ]; + $tagformat_want = [ $1, 'command line', 1 ]; # 1 menas overrides distro configuration } elsif (m/^--always-split-source-build$/s) { # undocumented, for testing