gitweb: Add git_get_rev_name_tags function
authorJakub Narebski <jnareb@gmail.com>
Thu, 24 Aug 2006 17:41:23 +0000 (19:41 +0200)
committerJunio C Hamano <junkio@cox.net>
Sat, 26 Aug 2006 02:40:05 +0000 (19:40 -0700)
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 <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
gitweb/gitweb.perl
index 01452d2c747bb29540d512ece6887c91b2ef040e..7aa6838836c61a7c965cff42630f98d8407fceac 100755 (executable)
@@ -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