From 8b6f007f99396b096abee9a1ed5826d80d69121f Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sun, 20 Sep 2015 16:57:51 -0700 Subject: [PATCH] taskd.pl: support --abbrev option Signed-off-by: Kyle J. McKay --- taskd/taskd.pl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/taskd/taskd.pl b/taskd/taskd.pl index 4e20a0f..6eca442 100755 --- a/taskd/taskd.pl +++ b/taskd/taskd.pl @@ -52,6 +52,7 @@ my $syslog; my $stderr; my $inetd; my $idle_timeout; +my $abbrev = 8; $| = 1; @@ -121,7 +122,7 @@ sub ref_change { $user or die "failed to load user $username"; } - statmsg "ref-change $username $name ($ref: @{[substr($oldrev,0,8)]} -> @{[substr($newrev,0,8)]})"; + statmsg "ref-change $username $name ($ref: @{[substr($oldrev,0,$abbrev)]} -> @{[substr($newrev,0,$abbrev)]})"; open STDIN, '<', '/dev/null'; Girocco::Notify::ref_change($proj, $user, $ref, $oldrev, $newrev); return 0; @@ -252,8 +253,10 @@ my $parse_res = GetOptions( 'syslog|s' => \$syslog, 'no-syslog' => sub {$syslog = 0}, 'stderr' => \$stderr, + 'abbrev=i' => \$abbrev, ) || pod2usage(2); $progress = 1 unless $quiet; +$abbrev = 128 unless $abbrev > 0; if (defined($idle_timeout)) { die "--idle-timeout must be a whole number" unless $idle_timeout =~ /^\d+$/; die "--idle-timeout may not be used without --inetd" unless $inetd; @@ -379,6 +382,7 @@ taskd.pl [options] enabled by --inetd --no-syslog do not send message to syslog --stderr always send messages to stderr too + --abbrev=n abbreviate hashes to n (default is 8) =head1 OPTIONS @@ -448,6 +452,11 @@ Always send error message output to STDERR. If --syslog is in effect then a copy will also be sent to syslog. In --inetd mode this applies to non-error messages as well. +=item B<--abbrev=n> + +Abbreviate displayed hash values to only the first n hexadecimal characters. +The default is 8 characters. Set to 0 for no abbreviation at all. + =back =head1 DESCRIPTION -- 2.11.4.GIT