summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2015-07-26 18:04:45 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2015-07-26 19:55:31 +0100
commit596f5bac104b0f6a1e87b509f945fd6e6ad7001a (patch)
tree0fb5b5645cfa5b9b1c34862c13bdf424144bed93
parentca067bcb7c0f986a103a7730d452a8c4b39a158f (diff)
Option parsing: Defer addition of cmdline opts so that we can put config ones in between
No functional change yet.
-rwxr-xr-xdgit21
1 files changed, 19 insertions, 2 deletions
diff --git a/dgit b/dgit
index 13b47fd..de14f92 100755
--- a/dgit
+++ b/dgit
@@ -98,6 +98,8 @@ our %opts_opt_map = ('dget' => \@dget, # accept for compatibility
'mergechanges' => \@mergechanges);
our %opts_opt_cmdonly = ('gpg' => 1);
+our %opts_opt_cmdline_opts;
+sub finalise_opts_opts();
our $keyid;
@@ -603,6 +605,11 @@ sub pushing () {
Push failed, before we got started.
You can retry the push, after fixing the problem, if you like.
END
+ finalise_opts_opts();
+}
+
+sub notpushing () {
+ finalise_opts_opts();
}
sub supplementary_message ($) {
@@ -2004,6 +2011,7 @@ END
sub cmd_clone {
parseopts();
+ notpushing();
my $dstdir;
badusage "-p is not allowed with clone; specify as argument instead"
if defined $package;
@@ -2051,6 +2059,7 @@ sub branchsuite () {
}
sub fetchpullargs () {
+ notpushing();
if (!defined $package) {
my $sourcep = parsecontrol('debian/control','debian/control');
$package = getfield $sourcep, 'Source';
@@ -2084,8 +2093,8 @@ sub cmd_pull {
}
sub cmd_push {
- pushing();
parseopts();
+ pushing();
badusage "-p is not allowed with dgit push" if defined $package;
check_not_dirty();
my $clogp = parsechangelog();
@@ -2823,10 +2832,12 @@ sub clean_tree () {
sub cmd_clean () {
badusage "clean takes no additional arguments" if @ARGV;
+ notpushing();
clean_tree();
}
sub build_prep () {
+ notpushing();
badusage "-p is not allowed when building" if defined $package;
check_not_dirty();
clean_tree();
@@ -3039,7 +3050,7 @@ sub parseopts () {
!$opts_opt_cmdonly{$1} &&
($om = $opts_opt_map{$1})) {
push @ropts, $_;
- push @$om, $2;
+ push @{ $opts_opt_cmdline_opts{$1} }, $2;
} elsif (m/^--existing-package=(.*)/s) {
push @ropts, $_;
$existing_package = $1;
@@ -3146,6 +3157,12 @@ sub parseopts () {
}
}
+sub finalise_opts_opts () {
+ foreach my $k (keys %opts_opt_cmdline_opts) {
+ push @{ $opts_opt_map{$k} }, @{ $opts_opt_cmdline_opts{$k} };
+ }
+}
+
if ($ENV{$fakeeditorenv}) {
quilt_fixup_editor();
}