summaryrefslogtreecommitdiff
path: root/gitweb
diff options
context:
space:
mode:
authorLibravatar Jakub Narebski <jnareb@gmail.com>2006-08-24 19:41:23 +0200
committerLibravatar Junio C Hamano <junkio@cox.net>2006-08-25 19:40:05 -0700
commit56a322f16113119bcc3770ef9565297ab59c29d2 (patch)
treee8ddd83b7c73ee89d2c9f15e999ddf3f6539be5c /gitweb
parentgitweb: Faster return from git_get_preceding_references if possible (diff)
downloadtgif-56a322f16113119bcc3770ef9565297ab59c29d2.tar.xz
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 <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'gitweb')
-rwxr-xr-xgitweb/gitweb.perl16
1 files changed, 16 insertions, 0 deletions
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 01452d2c74..7aa6838836 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