summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdgit40
1 files changed, 22 insertions, 18 deletions
diff --git a/dgit b/dgit
index 594281d..d287cfe 100755
--- a/dgit
+++ b/dgit
@@ -113,6 +113,9 @@ sub dscfn ($) {
sub changesopts () { return @changesopts[1..$#changesopts]; }
our $us = 'dgit';
+our $debugprefix = ' ';
+
+sub printdebug { print DEBUG $debugprefix, @_ or die $!; }
sub fail { die "$us: @_\n"; }
@@ -231,7 +234,7 @@ sub responder_send_command ($) {
my ($command) = @_;
return unless $we_are_responder;
# called even without $we_are_responder
- print DEBUG "<< $command\n";
+ printdebug "<< $command\n";
print $command, "\n" or die $!;
}
@@ -324,7 +327,7 @@ sub failedcmd {
}
sub runcmd {
- printcmd(\*DEBUG,"+",@_) if $debug>0;
+ printcmd(\*DEBUG,$debugprefix."+",@_) if $debug>0;
$!=0; $?=0;
failedcmd @_ if system @_;
}
@@ -339,16 +342,16 @@ sub printdone {
sub cmdoutput_errok {
die Dumper(\@_)." ?" if grep { !defined } @_;
- printcmd(\*DEBUG,"|",@_) if $debug>0;
+ printcmd(\*DEBUG,$debugprefix."|",@_) if $debug>0;
open P, "-|", @_ or die $!;
my $d;
$!=0; $?=0;
{ local $/ = undef; $d = <P>; }
die $! if P->error;
- if (!close P) { print DEBUG "=>!$?\n" if $debug>0; return undef; }
+ if (!close P) { printdebug "=>!$?\n" if $debug>0; return undef; }
chomp $d;
$d =~ m/^.*/;
- print DEBUG "=> \`$&'",(length $' ? '...' : ''),"\n" if $debug>0; #';
+ printdebug "=> \`$&'",(length $' ? '...' : ''),"\n" if $debug>0; #';
return $d;
}
@@ -359,7 +362,7 @@ sub cmdoutput {
}
sub dryrun_report {
- printcmd(\*STDERR,"#",@_);
+ printcmd(\*STDERR,$debugprefix."#",@_);
}
sub runcmd_ordryrun {
@@ -640,9 +643,9 @@ sub get_archive_dsc () {
next;
}
my $dscfh = new IO::File \$dscdata, '<' or die $!;
- print DEBUG Dumper($dscdata) if $debug>1;
+ printdebug Dumper($dscdata) if $debug>1;
$dsc = parsecontrolfh($dscfh,$dscurl, allow_pgp=>1);
- print DEBUG Dumper($dsc) if $debug>1;
+ printdebug Dumper($dsc) if $debug>1;
my $fmt = getfield $dsc, 'Format';
fail "unsupported source format $fmt, sorry" unless $format_ok{$fmt};
return;
@@ -914,7 +917,7 @@ sub fetch_from_archive () {
} else {
die "$lrref_fn $!";
}
- print DEBUG "previous reference hash=$lastpush_hash\n";
+ printdebug "previous reference hash=$lastpush_hash\n";
my $hash;
if (defined $dsc_hash) {
fail "missing git history even though dsc has hash -".
@@ -948,7 +951,7 @@ Package not found in the archive, but has allegedly been pushed using dgit.
$later_warning_msg
END
} else {
- print DEBUG "nothing found!\n";
+ printdebug "nothing found!\n";
if (defined $skew_warning_vsn) {
print STDERR <<END or die $!;
@@ -960,7 +963,7 @@ END
}
return 0;
}
- print DEBUG "current hash=$hash\n";
+ printdebug "current hash=$hash\n";
if ($lastpush_hash) {
fail "not fast forward on last upload branch!".
" (archive's version left in DGIT_ARCHIVE)"
@@ -968,13 +971,13 @@ END
}
if (defined $skew_warning_vsn) {
mkpath '.git/dgit';
- print DEBUG "SKEW CHECK WANT $skew_warning_vsn\n";
+ printdebug "SKEW CHECK WANT $skew_warning_vsn\n";
my $clogf = ".git/dgit/changelog.tmp";
runcmd shell_cmd "exec >$clogf",
@git, qw(cat-file blob), "$hash:debian/changelog";
my $gotclogp = parsechangelog("-l$clogf");
my $got_vsn = getfield $gotclogp, 'Version';
- print DEBUG "SKEW CHECK GOT $got_vsn\n";
+ printdebug "SKEW CHECK GOT $got_vsn\n";
if (version_compare_string($got_vsn, $skew_warning_vsn) < 0) {
print STDERR <<END or die $!;
@@ -1038,7 +1041,7 @@ sub pull () {
sub check_not_dirty () {
return if $ignoredirty;
my @cmd = (@git, qw(diff --quiet HEAD));
- printcmd(\*DEBUG,"+",@cmd) if $debug>0;
+ printcmd(\*DEBUG,$debugprefix."+",@cmd) if $debug>0;
$!=0; $?=0; system @cmd;
return if !$! && !$?;
if (!$! && $?==256) {
@@ -1173,7 +1176,7 @@ sub sign_changes ($) {
}
sub dopush () {
- print DEBUG "actually entering push\n";
+ printdebug "actually entering push\n";
prep_ud();
my $clogpfn = ".git/dgit/changelog.822.tmp";
@@ -1193,7 +1196,7 @@ sub dopush () {
push_parse_dsc("../$dscfn", $dscfn, $cversion);
my $format = getfield $dsc, 'Format';
- print DEBUG "format $format\n";
+ printdebug "format $format\n";
if (madformat($format)) {
commit_quilty_patch();
}
@@ -1203,8 +1206,8 @@ sub dopush () {
runcmd qw(dpkg-source -x --), "../../../../$dscfn";
my ($tree,$dir) = mktree_in_ud_from_only_subdir();
chdir '../../../..' or die $!;
- printcmd \*DEBUG,"+",@_;
my @diffcmd = (@git, qw(diff --exit-code), $tree);
+ printcmd \*DEBUG,$debugprefix."+",@diffcmd;
$!=0; $?=0;
if (system @diffcmd) {
if ($! && $?==256) {
@@ -1397,6 +1400,7 @@ sub cmd_remote_push_responder {
my ($dir) = @rargs;
chdir $dir or die "$dir: $!";
$we_are_responder = 1;
+ $debugprefix = ' ';
$|=1;
responder_send_command("dgit-remote-push-ready");
&cmd_push;
@@ -1434,7 +1438,7 @@ sub cmd_rpush {
push @rdgit, qw(remote-push-responder), (scalar @rargs), @rargs;
push @rdgit, @ARGV;
my @cmd = (@ssh, $host, shellquote @rdgit);
- printcmd \*DEBUG,"+",@cmd;
+ printcmd \*DEBUG,$debugprefix."+",@cmd;
eval {
$i_tmp = tempdir();
my $pid = open2(\*RO, \*RI, @cmd);