From: Eric Wong Date: Wed, 26 Mar 2025 20:13:03 +0000 (+0000) Subject: content_digest_dbg: more compact display w/ git_quote X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d1a92af7f1b281fee5311393090fc7219b89fdad;p=thirdparty%2Fpublic-inbox.git content_digest_dbg: more compact display w/ git_quote Make WWW /$MSGID/d/ endpoints and `lei mail-diff' output less verbose by getting rid of Data::Dumper in favor of a lightly-modified git_quote output. The extra [] pairs from Data::Dumper were unnecessary noise and the quoting used by git_quote should be more familiar to git users. Unfortunately, git's escaping of NUL bytes to `\000' is a bit noisy, so we'll undo that by substituting to `\0'. --- diff --git a/lib/PublicInbox/ContentDigestDbg.pm b/lib/PublicInbox/ContentDigestDbg.pm index 853624f13..a3ab09c07 100644 --- a/lib/PublicInbox/ContentDigestDbg.pm +++ b/lib/PublicInbox/ContentDigestDbg.pm @@ -2,19 +2,24 @@ # License: AGPL-3.0+ package PublicInbox::ContentDigestDbg; # cf. PublicInbox::ContentDigest use v5.12; -use Data::Dumper; +use PublicInbox::Git qw(git_quote); use PublicInbox::SHA; -$Data::Dumper::Useqq = $Data::Dumper::Terse = 1; sub new { bless [ PublicInbox::SHA->new(256), $_[1] ], __PACKAGE__ } sub add { - $_[0]->[0]->add($_[1]); - my @dbg = split(/^/sm, $_[1]); - if (@dbg && $dbg[0] =~ /\A(To|Cc)\0/) { # fold excessively long lines + my ($dig, $out) = @{$_[0]}; + $dig->add($_[1]); + my @dbg = split /^/sm, $_[1]; + # fold excessively long lines + @dbg && $dbg[0] =~ /\A(?:To|Cc)\0.*?\,/ and @dbg = map { split(/,/s, $_) } @dbg; + for (@dbg) { + $_ = git_quote($_); + s/\\000/\\0/g; # less ugly + # n.b. caller must (autodie) `close' to error check `say' + say $out ' ', $_; } - print { $_[0]->[1] } Dumper(\@dbg) or die "print $!"; } sub hexdigest { $_[0]->[0]->hexdigest }