scalar @{ $opts_opt_map{$_} }
} keys %opts_opt_map;
-sub finalise_opts_opts();
sub parseopts_late_defaults();
our $keyid;
sub access_nomdistro () {
my $base = access_basedistro();
- return cfg("dgit-distro.$base.nominal-distro",'RETURN-UNDEF') // $base;
+ my $r = cfg("dgit-distro.$base.nominal-distro",'RETURN-UNDEF') // $base;
+ $r =~ m/^$distro_re$/ or badcfg
+ "bad syntax for (nominal) distro \`$r' (does not match /^$distro_re$/)";
+ return $r;
}
sub access_quirk () {
Push failed, before we got started.
You can retry the push, after fixing the problem, if you like.
END
- finalise_opts_opts();
+ parseopts_late_defaults();
}
sub notpushing () {
- finalise_opts_opts();
+ parseopts_late_defaults();
}
sub supplementary_message ($) {
}
our ($dsc_hash,$lastpush_mergeinput);
+our ($dsc_distro, $dsc_hint_tag, $dsc_hint_url);
our $ud = '.git/dgit/unpack';
}
}
+sub parse_dsc_field ($$) {
+ my ($dsc, $what) = @_;
+ my $f;
+ foreach my $field (@ourdscfield) {
+ $f = $dsc->{$field};
+ last if defined $f;
+ }
+ if (!defined $f) {
+ progress "$what: NO git hash";
+ } elsif (($dsc_hash, $dsc_distro, $dsc_hint_tag, $dsc_hint_url)
+ = $f =~ m/^(\w+) ($distro_re) ($versiontag_re) (\S+)(?:\s|$)/) {
+ progress "$what: specified git info ($dsc_distro)";
+ $dsc_hint_tag = [ $dsc_hint_tag ];
+ } elsif ($f =~ m/^\w+\s*$/) {
+ $dsc_hash = $&;
+ $dsc_distro //= 'debian';
+ $dsc_hint_tag = [ debiantags +(getfield $dsc, 'Version'),
+ $dsc_distro ];
+ progress "$what: specified git hash";
+ } else {
+ fail "$what: invalid Dgit info";
+ }
+}
+
+sub resolve_dsc_field_commit ($$) {
+ my ($already_distro, $already_mapref) = @_;
+
+ return unless defined $dsc_hash;
+
+ my $rewritemapdata = git_cat_file $already_mapref.':map';
+ if (defined $rewritemapdata
+ && $rewritemapdata =~ m/^$dsc_hash(?:[ \t](\w+))/m) {
+ progress "server's git history rewrite map contains a relevant entry!";
+
+ $dsc_hash = $1;
+ if (defined $dsc_hash) {
+ progress "using rewritten git hash in place of .dsc value";
+ } else {
+ progress "server data says .dsc hash is to be disregarded";
+ }
+ }
+}
+
sub fetch_from_archive () {
ensure_setup_existing_tree();
get_archive_dsc();
if ($dsc) {
- foreach my $field (@ourdscfield) {
- $dsc_hash = $dsc->{$field};
- last if defined $dsc_hash;
- }
- if (defined $dsc_hash) {
- $dsc_hash =~ m/\w+/ or fail "invalid hash in .dsc \`$dsc_hash'";
- $dsc_hash = $&;
- progress "last upload to archive specified git hash";
- } else {
- progress "last upload to archive has NO git hash";
- }
+ parse_dsc_field($dsc, 'last upload to archive');
+ resolve_dsc_field_commit access_basedistro,
+ lrfetchrefs."/".$rewritemap
} else {
progress "no version available from the archive";
}
- my $rewritemapdata = git_cat_file lrfetchrefs."/".$rewritemap.':map';
- if (defined $rewritemapdata
- && $rewritemapdata =~ m/^$dsc_hash(?:[ \t](\w+))/m) {
- progress "server's git history rewrite map contains a relevant entry!";
- $dsc_hash = $1;
- if (defined $dsc_hash) {
- progress "using rewritten git hash in place of .dsc value";
- } else {
- progress "server data says .dsc hash is to be disregarded";
- }
- }
-
# If the archive's .dsc has a Dgit field, there are three
# relevant git commitids we need to choose between and/or merge
# together:
die unless $tagwants->[0]{View} eq 'dgit';
- $dsc->{$ourdscfield[0]} = $tagwants->[0]{Objid};
+ my $declaredistro = access_nomdistro();
+ my $reader_giturl = do { local $access_forpush=0; access_giturl(); };
+ $dsc->{$ourdscfield[0]} = join " ",
+ $tagwants->[0]{Objid}, $declaredistro, $tagwants->[0]{Tag},
+ $reader_giturl;
$dsc->save("$dscfn.tmp") or die $!;
my $changes = parsecontrol($changesfile,$changesfilewhat);
# to control the "tagger" (b) we can do remote signing
my $authline = clogp_authline $clogp;
my $delibs = join(" ", "",@deliberatelies);
- my $declaredistro = access_nomdistro();
my $mktag = sub {
my ($tw) = @_;
}
sub fetchpullargs () {
- notpushing();
if (!defined $package) {
my $sourcep = parsecontrol('debian/control','debian/control');
$package = getfield $sourcep, 'Source';
} else {
badusage "incorrect arguments to dgit fetch or dgit pull";
}
+ notpushing();
}
sub cmd_fetch {
parse_dscdata();
- my $dgit_commit = $dsc->{$ourdscfield[0]};
- if (defined $dgit_commit
+ parse_dsc_field($dsc, "Dgit metadata in .dsc");
+
+ if (defined $dsc_hash
&& !forceing [qw(import-dsc-with-dgit-field)]) {
- $dgit_commit =~ m/\w+/ or fail "invalid hash in .dsc";
- $dgit_commit = $&;
progress "dgit: import-dsc of .dsc with Dgit field, using git hash";
my @cmd = (qw(sh -ec),
- "echo $dgit_commit | git cat-file --batch-check");
+ "echo $dsc_hash | git cat-file --batch-check");
my $objgot = cmdoutput @cmd;
if ($objgot =~ m#^\w+ missing\b#) {
fail <<END
-.dsc contains Dgit field referring to object $dgit_commit
+.dsc contains Dgit field referring to object $dsc_hash
Your git tree does not have that object. Try `git fetch' from a
plausible server (browse.dgit.d.o? alioth?), and try the import-dsc again.
END
}
- if ($oldhash && !is_fast_fwd $oldhash, $dgit_commit) {
+ if ($oldhash && !is_fast_fwd $oldhash, $dsc_hash) {
if ($force > 0) {
progress "Not fast forward, forced update.";
} else {
- fail "Not fast forward to $dgit_commit";
+ fail "Not fast forward to $dsc_hash";
}
}
@cmd = (@git, qw(update-ref -m), "dgit import-dsc (Dgit): $info",
- $dstbranch, $dgit_commit);
+ $dstbranch, $dsc_hash);
runcmd @cmd;
progress "dgit: import-dsc updated git ref $dstbranch";
return 0;
}
-sub finalise_opts_opts () {
+sub parseopts_late_defaults () {
foreach my $k (keys %opts_opt_map) {
my $om = $opts_opt_map{$k};
}
}
- parseopts_late_defaults();
-}
-
-sub parseopts_late_defaults () {
if (!defined $rmchanges) {
local $access_forpush;
$rmchanges = access_cfg_bool(0, 'rm-old-changes');