And here are the patches.

Tomasz
From 471b2435d394b7628576401c0f6beb3d5a2dfa2d Mon Sep 17 00:00:00 2001
From: Tomasz Buchert <[email protected]>
Date: Sun, 23 Aug 2015 12:23:31 +0200
Subject: [PATCH 1/2] show all valid identities

---
 gpglist/gpglist | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/gpglist/gpglist b/gpglist/gpglist
index f4e2e66..591c2e1 100755
--- a/gpglist/gpglist
+++ b/gpglist/gpglist
@@ -49,8 +49,8 @@ gpglist -- show who signed which of your UIDs
 B<gpglist> takes a keyid and creates a listing showing who signed your user IDs.
 
 	$ gpglist 6D8ABE71
-	+-----  1 Christoph Berg <[email protected]>
-	|  +--  2 Christoph Berg <[email protected]>
+	+----- x 1 Christoph Berg <[email protected]>
+	|  +-- x 2 Christoph Berg <[email protected]>
 	1  2  
 	x     7929AB90F7AC3AF0 Martin Helas <[email protected]>
 	x  x  29BE5D2268FD549F Martin Michlmayr <[email protected]>
@@ -134,14 +134,28 @@ while (<SIGS>) {
 }
 close SIGS;
 
+sub status {
+	my $id = shift;
+	my $uid = shift;
+	my $rev_t = (defined $revs{$id}->{$uid} ? $revs{$id}->{$uid} : -2);
+	my $sig_t = (defined $sigs{$id}->{$uid} ? $sigs{$id}->{$uid} : -2);
+	if ($sig_t == -2) {  # no signature
+		return " ";
+	}
+	else {
+		return ($rev_t > $sig_t ? "R" : "x");
+	}
+}
+
 # XXX: Add an option for this
-@uids = grep { !defined $revs{$longkey}->{$_} } @uids;
+@uids = grep { status($longkey, $_) eq "x" } @uids;
 
 for ( my $a=0; $a <= $#uids; $a++ ) {
 	printf "|  " x $a
 	     . "+--"
 	     . "---" x ($#uids-$a)
-	     . (defined $revs{$longkey}->{$uids[$a]} ? "R" : " ") # revuid
+	     . " "
+	     . status($longkey, $uids[$a])
 	     . "%2i $uids{$uids[$a]}\n", $a+1;
 }
 
@@ -152,14 +166,7 @@ print "\n";
 
 for my $id (sort {$ids{$a} cmp $ids{$b}} keys %ids) {
 	foreach my $uid (@uids) {
-		if (defined $revs{$id}->{$uid} and defined $sigs{$id}->{$uid} and
-				$sigs{$id}->{$uid} > 0 and # < 0 means non-revocable
-				$revs{$id}->{$uid} > $sigs{$id}->{$uid}) {
-			print 'R';
-		} else {
-			print (defined $sigs{$id}->{$uid} ? 'x' : ' ');
-		}
-		print '  ';
+		print status($id, $uid) . '  ';
 	}
 	print "$id $ids{$id}\n";
 }
-- 
2.5.0

From 580624afc3e7b074ee743c3b43198915ad696231 Mon Sep 17 00:00:00 2001
From: Tomasz Buchert <[email protected]>
Date: Sun, 23 Aug 2015 12:40:08 +0200
Subject: [PATCH 2/2] add option to list revoked uids

---
 gpglist/gpglist | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/gpglist/gpglist b/gpglist/gpglist
index 591c2e1..7134fd5 100755
--- a/gpglist/gpglist
+++ b/gpglist/gpglist
@@ -40,7 +40,7 @@ gpglist -- show who signed which of your UIDs
 
 =over
 
-=item B<gpglist> I<keyid>
+=item B<gpglist> I<keyid> [I<--show-revoked>]
 
 =back
 
@@ -56,6 +56,9 @@ B<gpglist> takes a keyid and creates a listing showing who signed your user IDs.
 	x  x  29BE5D2268FD549F Martin Michlmayr <[email protected]>
 	   x  7DDB2B8DB4B462C5 Martin Wanke <[email protected]>
 
+By default only non-revoked identities are listed, but you can override it with
+I<--show-revoked>.
+
 =head1 AUTHORS
 
 =over
@@ -79,11 +82,17 @@ gpgsigs(1), gpg(1), caff(1).
 use strict;
 use warnings;
 use English '-no_match_vars';
+use Getopt::Long;
 
 my $now = time;
-my $key=shift @ARGV;
+my $show_revoked;
+
+GetOptions("show-revoked" => \$show_revoked)
+or die("Error in command line arguments");
+
+my $key = shift @ARGV;
 unless (defined $key) {
-	die "Usage: $PROGRAM_NAME <keyid>\n";
+	die "Usage: $PROGRAM_NAME <keyid> [--show-revoked]\n";
 }
 
 open SIGS, '-|', $ENV{GNUPGBIN} // 'gpg', qw/--no-auto-check-trustdb --list-options show-sig-subpackets --fixed-list-mode --with-colons --list-sigs/, $key
@@ -147,8 +156,8 @@ sub status {
 	}
 }
 
-# XXX: Add an option for this
-@uids = grep { status($longkey, $_) eq "x" } @uids;
+my $allowed = ($show_revoked ? "xR" : "x");
+@uids = grep { index($allowed, status($longkey, $_)) != -1 } @uids;
 
 for ( my $a=0; $a <= $#uids; $a++ ) {
 	printf "|  " x $a
-- 
2.5.0

Reply via email to