chiark / gitweb /
some ---- comments
[topbloke.git] / tb-list.pl
index 6a4466b5fdb4102f71bd82f31472ddb41535d2ba..620f7599650aec3b2baff315263728ab8ea12f87 100755 (executable)
@@ -8,6 +8,8 @@ use strict;
 use Getopt::Long;
 use Topbloke;
 
+#----- option parsing -----
+
 Getopt::Long::Configure(qw(bundling));
 
 our $deleted=0;
@@ -43,6 +45,10 @@ foreach $sort (@sort) {
     $toposort=1 if $sort eq $toposort;
 }
 
+$relatedto = $relatedto ? parse_patch_spec($relatedto) : undef;
+
+#----- list patches -----
+
 our %patches;
 
 foreach_patch($relatedto || $leaves || !$spec ? { } : $spec, 
@@ -54,6 +60,8 @@ foreach_patch($relatedto || $leaves || !$spec ? { } : $spec,
                  $patches{$patch}{ParsedName} = $parsedname;
              });
 
+#----- selection -----
+
 if ($leaves) {
     foreach my $p (keys %patches) {
        my $v = $patches{$p};
@@ -82,6 +90,8 @@ if ($relatedto) {
                next unless exists $patches{$dep};
                $patches{$dep}{Related} = 1;
            }
+           # oh, and mark ourselves as Related=1 too!
+           $v->{Related} = 1;
        }
     }
 }
@@ -94,9 +104,12 @@ foreach my $p (keys %patches) {
     next if $deleted_only && !$v->{Info}[0]{Deleted};
     next if $leaves && $v->{NotLeaf};
     next if $relatedto && !$v->{Related};
+    next if $spec && !patch_matches_spec($v->{ParsedName}, $spec);
     push @output, $p;
 }
 
+#----- sorting -----
+
 sub sortsub () {
     my $txt = "sub sort_cmp {\n    my \$r;\n";
     debug("@sort");
@@ -143,9 +156,26 @@ eval sortsub()." 1;" or die "$@ ?";
 
 @output = sort sort_cmp @output;
 
-use Data::Dumper;
+#----- printing -----
+
+my $current_branch = current_branch();
+my $current_patch = $current_branch->{Kind} eq 'tip'
+    ? $current_branch->{Fullname} : '';
 
 foreach my $p (@output) {
     my $v = $patches{$p};
-    print Dumper($p, $v);
+    my $pa = $v->{ParsedName};
+    my ($msgkind, $msg) = git_get_object("$pa->{Ref}:.topbloke/msg");
+    die "$p $msgkind ?" unless $msgkind eq 'blob';
+    my $subject =
+       $msg =~ m/^Subject:\s*(?:\[[^][]*\]\s*)?(.*\S)\s*$/mi
+       ? $1 : "[no subject]";  
+    printf("%1s%1s %s\@%s/%s/%-20s %s\n",
+          $p eq $current_patch ? '>' : '',
+          $v->{Info}[0]{Deleted} ? 'D' : '',
+          $pa->{Email}, $pa->{Domain}, $pa->{Date}, $pa->{Nick},
+          $subject)
+       or die $!;
 }
+
+closeout();