chiark / gitweb /
Remove // from inside conditionals
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 29 Jul 2018 03:51:02 +0000 (04:51 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 29 Jul 2018 04:02:21 +0000 (05:02 +0100)
This idiom is terse, but quite confusing.  Instead, handle the undef
case explicitly.

While we are editing these:
 * Change two internal errors from die to confess
 * Fix a die in git-debrebase which ought to be badusage

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
debian/changelog
dgit
git-debrebase

index 8e87d39f696e0887ecb08973f7208e9cba19ecd3..a01f5dfb7e423615e738ff5fab3ca65b4acdb4b1 100644 (file)
@@ -1,6 +1,6 @@
 dgit (6.2~) unstable; urgency=medium
 
-  * 
+  * dgit: Minor code cleanup.
 
  --
 
diff --git a/dgit b/dgit
index 6e8b757e8c825cf5f15dd6ae147100d49b3ac063..63126712f4490bfd78f4a47ca73be00e25d04dc9 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -824,7 +824,8 @@ sub access_forpush () {
 }
 
 sub pushing () {
-    die "$access_forpush ?" if ($access_forpush // 1) ne 1;
+    confess 'internal error '.Dumper($access_forpush)," ?" if
+       defined $access_forpush and !$access_forpush;
     badcfg "pushing but distro is configured readonly"
        if access_forpush_config() eq '0';
     $access_forpush = 1;
@@ -4439,7 +4440,8 @@ END
     responder_send_command("param isuite $isuite");
     responder_send_command("param tagformat $tagformat");
     if (defined $maintviewhead) {
-       die unless ($protovsn//4) >= 4;
+       confess "internal error (protovsn=$protovsn)"
+           if defined $protovsn and $protovsn < 4;
        responder_send_command("param maint-view $maintviewhead");
     }
 
@@ -7049,8 +7051,8 @@ sub check_env_sanity () {
        foreach my $name (qw(PIPE CHLD)) {
            my $signame = "SIG$name";
            my $signum = eval "POSIX::$signame" // die;
-           ($SIG{$name} // 'DEFAULT') eq 'DEFAULT' or
-               die "$signame is set to something other than SIG_DFL\n";
+           die "$signame is set to something other than SIG_DFL\n"
+               if defined $SIG{$name} and $SIG{$name} ne 'DEFAULT';
            $blocked->ismember($signum) and
                die "$signame is blocked\n";
        }
index f00222520e9cf2f6d230b6ebd955d5b2c7aac80b..07e5f478cac58281570da99ef27e57953c0a6a53 100755 (executable)
@@ -970,7 +970,8 @@ sub defaultcmd_rebase () {
 }
 
 sub cmd_analyse () {
-    die if ($ARGV[0]//'') =~ m/^-/;
+    badusage "analyse does not support any options"
+       if @ARGV and $ARGV[0] =~ m/^-/;
     badusage "too many arguments to analyse" if @ARGV>1;
     my ($old) = @ARGV;
     if (defined $old) {