From: Jakub Narebski Date: Thu, 24 Aug 2006 17:41:23 +0000 (+0200) Subject: gitweb: Add git_get_rev_name_tags function X-Git-Tag: v1.4.3-rc1~168^2~20 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=56a322f16113119bcc3770ef9565297ab59c29d2;p=git.git gitweb: Add git_get_rev_name_tags function Add git_get_rev_name_tags function, for later use in git_commitdiff('plain') for X-Git-Tag: header. This function, contrary to the call to git_get_following_references($hash, "tags"); _does_ strip "tags/" and returns bare tag name. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 01452d2c7..7aa683883 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -800,6 +800,22 @@ sub git_get_preceding_references { return @reflist; } +sub git_get_rev_name_tags { + my $hash = shift || return undef; + + open my $fd, "-|", $GIT, "name-rev", "--tags", $hash + or return; + my $name_rev = <$fd>; + close $fd; + + if ($name_rev =~ m|^$hash tags/(.*)$|) { + return $1; + } else { + # catches also '$hash undefined' output + return undef; + } +} + ## ---------------------------------------------------------------------- ## parse to hash functions