chiark / gitweb /
Debugging output: Break out debugcmd into Dgit.pm and use it everywhere (nfc)
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 268f35673d54e17e7013c682473676d92c6e1046..44cfb15acfbb3e968b4b6aa6c3083842033ea003 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -386,7 +386,7 @@ sub failedcmd {
 }
 
 sub runcmd {
-    printcmd(\*DEBUG,$debugprefix."+",@_) if $debug>0;
+    debugcmd "+",@_;
     $!=0; $?=0;
     failedcmd @_ if system @_;
 }
@@ -404,7 +404,7 @@ sub printdone {
 
 sub cmdoutput_errok {
     die Dumper(\@_)." ?" if grep { !defined } @_;
-    printcmd(\*DEBUG,$debugprefix."|",@_) if $debug>0;
+    debugcmd "|",@_;
     open P, "-|", @_ or die $!;
     my $d;
     $!=0; $?=0;
@@ -911,7 +911,7 @@ sub sshpsql ($$$) {
               access_runeinfo("ssh-psql $runeinfo").
               " export LC_MESSAGES=C; export LC_CTYPE=C;".
               " ".shellquote qw(psql -A), $dbname, qw(-c), $sql);
-    printcmd(\*DEBUG,$debugprefix."|",@cmd) if $debug>0;
+    debugcmd "|",@cmd;
     open P, "-|", @cmd or die $!;
     while (<P>) {
        chomp or die;
@@ -1503,7 +1503,7 @@ sub pull () {
 sub check_not_dirty () {
     return if $ignoredirty;
     my @cmd = (@git, qw(diff --quiet HEAD));
-    printcmd(\*DEBUG,$debugprefix."+",@cmd) if $debug>0;
+    debugcmd "+",@cmd;
     $!=0; $?=0; system @cmd;
     return if !$! && !$?;
     if (!$! && $?==256) {
@@ -1695,7 +1695,7 @@ sub dopush () {
     changedir '../../../..';
     my $diffopt = $debug>0 ? '--exit-code' : '--quiet';
     my @diffcmd = (@git, qw(diff), $diffopt, $tree);
-    printcmd \*DEBUG,$debugprefix."+",@diffcmd;
+    debugcmd "+",@diffcmd;
     $!=0; $?=0;
     my $r = system @diffcmd;
     if ($r) {
@@ -1993,7 +1993,7 @@ sub cmd_rpush {
     push @rdgit, qw(remote-push-build-host), (scalar @rargs), @rargs;
     push @rdgit, @ARGV;
     my @cmd = (@ssh, $host, shellquote @rdgit);
-    printcmd \*DEBUG,$debugprefix."+",@cmd;
+    debugcmd "+",@cmd;
 
     if (defined $initiator_tempdir) {
        rmtree $initiator_tempdir;