chiark / gitweb /
dgit: Option parsing: Fix distro/suite reference bugs
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 5207e0b96780124fbb106843e51f0fd4b3fe1ba3..88bd431ab37e277bcd273079a2f6fc42078e3030 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -143,6 +143,7 @@ our %opts_cfg_insertpos = map {
 } keys %opts_opt_map;
 
 sub finalise_opts_opts();
+sub parseopts_late_defaults();
 
 our $keyid;
 
@@ -4076,7 +4077,6 @@ END
 
 sub cmd_clone {
     parseopts();
-    notpushing();
     my $dstdir;
     badusage "-p is not allowed with clone; specify as argument instead"
        if defined $package;
@@ -4091,8 +4091,9 @@ sub cmd_clone {
     } else {
        badusage "incorrect arguments to dgit clone";
     }
-    $dstdir ||= "$package";
+    notpushing();
 
+    $dstdir ||= "$package";
     if (stat_exists $dstdir) {
        fail "$dstdir already exists";
     }
@@ -5637,6 +5638,7 @@ sub postbuild_mergechanges_vanilla ($) {
 }
 
 sub cmd_build {
+    build_prep_early();
     my @dbp = (@dpkgbuildpackage, qw(-us -uc), changesopts_initial(), @ARGV);
     my $wantsrc = massage_dbp_args \@dbp;
     if ($wantsrc > 0) {
@@ -5790,6 +5792,7 @@ sub build_source {
 }
 
 sub cmd_build_source {
+    build_prep_early();
     badusage "build-source takes no additional arguments" if @ARGV;
     build_source();
     maybe_unapply_patches_again();
@@ -6289,6 +6292,8 @@ sub finalise_opts_opts () {
                     @$om[$insertpos..$#$om] );
        }
     }
+
+    parseopts_late_defaults();
 }
 
 if ($ENV{$fakeeditorenv}) {
@@ -6349,8 +6354,6 @@ sub parseopts_late_defaults () {
     }
 }
 
-parseopts_late_defaults();
-
 my $fn = ${*::}{"cmd_$cmd"};
 $fn or badusage "unknown operation $cmd";
 $fn->();