chiark / gitweb /
list: support -c
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 23 Jan 2012 01:41:38 +0000 (01:41 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 23 Jan 2012 01:41:38 +0000 (01:41 +0000)
tb-list.pl

index e88b17d..1e95270 100755 (executable)
@@ -15,13 +15,21 @@ Getopt::Long::Configure(qw(bundling));
 our $deleted=0;
 our $deleted_only=0;
 our $current=0;
-our $relatedto=0;
+our $relatedto;
 our $leaves=0;
 our $sort='';
 
 GetOptions("d|deleted!" => \$deleted,         # including deleted patches
           "deleted-only!" => \$deleted_only, # only deleted patches
-          "r|related=s" => \$relatedto,     # only patches related to this one
+          "r|related=s" => sub {             # only patches related to that
+              $relatedto = parse_patch_spec($_[1]);
+          },
+          "c|related-current" => sub {      # only patches related to current
+              my $current_branch = current_branch();
+              die "-c only permitted when on a topbloke branch\n"
+                  unless $current_branch->{Kind} =~ m/^(?:tip|base)$/;
+              $relatedto = $current_branch;
+          },
           "l|last|leaf|leaves" => \$leaves, # only leaf patches
           "sort=s" => \$sort,
     ) or die "bad options\n";
@@ -45,8 +53,6 @@ foreach $sort (@sort) {
     $toposort=1 if $sort eq $toposort;
 }
 
-$relatedto = $relatedto ? parse_patch_spec($relatedto) : undef;
-
 #----- list patches -----
 
 our %patches;