chiark / gitweb /
cmd_push: Factor out all prep code
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 28795fec9f5a130bf530da26bb323863281391e6..c17b42a967645446189383765216bce9a61ddb46 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -47,6 +47,8 @@ our $absurdity = undef; ###substituted###
 our @rpushprotovsn_support = qw(4 3 2); # 4 is new tag format
 our $protovsn;
 
+our $cmd;
+our $subcommand;
 our $isuite;
 our $idistro;
 our $package;
@@ -4490,9 +4492,9 @@ END
     pull();
 }
 
-sub cmd_push {
+sub prep_push () {
     parseopts();
-    badusage "-p is not allowed with dgit push" if defined $package;
+    badusage "-p is not allowed with dgit $subcommand" if defined $package;
     check_not_dirty();
     my $clogp = parsechangelog();
     $package = getfield $clogp, 'Source';
@@ -4501,7 +4503,7 @@ sub cmd_push {
     } elsif (@ARGV==1) {
        ($specsuite) = (@ARGV);
     } else {
-       badusage "incorrect arguments to dgit push";
+       badusage "incorrect arguments to dgit $subcommand";
     }
     $isuite = getfield $clogp, 'Distribution';
     pushing();
@@ -4514,9 +4516,13 @@ sub cmd_push {
     if (defined $specsuite &&
        $specsuite ne $isuite &&
        $specsuite ne $csuite) {
-           fail "dgit push: changelog specifies $isuite ($csuite)".
+           fail "dgit $subcommand: changelog specifies $isuite ($csuite)".
                " but command line specifies $specsuite";
     }
+}
+
+sub cmd_push {
+    prep_push();
     dopush();
 }
 
@@ -6795,7 +6801,7 @@ if (!@ARGV) {
     print STDERR $helpmsg or die $!;
     exit 8;
 }
-my $cmd = shift @ARGV;
+$cmd = $subcommand = shift @ARGV;
 $cmd =~ y/-/_/;
 
 my $pre_fn = ${*::}{"pre_$cmd"};