From 7b7d4bd01b564969eb0c1904a5bd9ee4f3dbba72 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 23 Oct 2021 20:19:37 +0000 Subject: git: simplify local_nick, avoid "foo.git.git" We need to use a non-greedy regexp to avoid capturing the ".git" suffix in the pathname before blindly appending our own. --- lib/PublicInbox/Git.pm | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index e634ca55..374a3b4d 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -442,13 +442,8 @@ sub packed_bytes { sub DESTROY { cleanup(@_) } sub local_nick ($) { - my ($self) = @_; - my $ret = '???'; # don't show full FS path, basename should be OK: - if ($self->{git_dir} =~ m!/([^/]+)(?:/*\.git/*)?\z!) { - $ret = "$1.git"; - } - wantarray ? ($ret) : $ret; + $_[0]->{git_dir} =~ m!/([^/]+?)(?:/*\.git/*)?\z! ? "$1.git" : '???'; } sub host_prefix_url ($$) { @@ -465,7 +460,7 @@ sub pub_urls { if (my $urls = $self->{cgit_url}) { return map { host_prefix_url($env, $_) } @$urls; } - local_nick($self); + (local_nick($self)); } sub cat_async_begin { -- cgit v1.2.3-24-ge0c7