+ next unless $l =~ m/\S/;
+ if ($l =~ m{^(?:\?\?| M) (.pc|debian/patches)}) {
+ $adds{$1}++;
+ } else {
+ print STDERR "git status: $l\n";
+ $bad++;
+ }
+ }
+ fail "unexpected output from git status (is tree clean?)" if $bad;
+ if (!%adds) {
+ progress "nothing quilty to commit, ok.";
+ return;
+ }
+ runcmd_ordryrun @git, qw(add), sort keys %adds;
+ my $m = "Commit Debian 3.0 (quilt) metadata";
+ progress "$m";
+ runcmd_ordryrun @git, qw(commit -m), $m;
+}
+
+sub madformat ($) {
+ my ($format) = @_;
+ return 0 unless $format eq '3.0 (quilt)';
+ progress "Format \`$format', urgh";
+ if ($noquilt) {
+ progress "Not doing any fixup of \`$format' due to --no-quilt-fixup";
+ return 0;
+ }
+ return 1;
+}
+
+sub push_parse_changelog ($) {
+ my ($clogpfn) = @_;
+
+ my $clogp = Dpkg::Control::Hash->new();
+ $clogp->load($clogpfn);
+
+ responder_send_file('parsed-changelog', $clogpfn);
+
+ $package = getfield $clogp, 'Source';
+ my $cversion = getfield $clogp, 'Version';
+ my $tag = debiantag($cversion);
+ runcmd @git, qw(check-ref-format), $tag;
+
+ my $dscfn = dscfn($cversion);
+
+ return ($clogp, $cversion, $tag, $dscfn);
+}
+
+sub push_parse_dsc ($$) {
+ my ($dscfn,$dscfnwhat, $cversion) = @_;
+ $dsc = parsecontrol($dscfn,$dscfnwhat);
+ my $dversion = getfield $dsc, 'Version';
+ my $dscpackage = getfield $dsc, 'Source';
+ ($dscpackage eq $package && $dversion eq $cversion) or
+ fail "$dsc is for $dscpackage $dversion".
+ " but debian/changelog is for $package $cversion";
+}
+
+sub push_mktag ($$$$$$$$) {
+ my ($head,$clogp,$tag,
+ $dsc,$dscfn,
+ $changesfile,$changesfilewhat,
+ $tfn) = @_;
+
+ $dsc->{$ourdscfield[0]} = $head;
+ $dsc->save("$dscfn.tmp") or die $!;
+
+ my $changes = parsecontrol($changesfile,$changesfilewhat);
+ foreach my $field (qw(Source Distribution Version)) {
+ $changes->{$field} eq $clogp->{$field} or
+ fail "changes field $field \`$changes->{$field}'".
+ " does not match changelog \`$clogp->{$field}'";