chiark / gitweb /
Introduce git_for_each_tag_referring
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 22 Mar 2015 14:56:32 +0000 (14:56 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 22 Mar 2015 15:19:51 +0000 (15:19 +0000)
Debian/Dgit.pm

index 4d9b81a..e2f8edd 100644 (file)
@@ -64,4 +64,15 @@ sub git_for_each_ref ($$) {
     $!=0; $?=0; close $fh or die "$pattern $? $!";
 }
 
+sub git_for_each_tag_referring ($$) {
+    my ($objreferring, $func) = @_;
+    # calls $func->($objid,$fullrefname,$tagname);
+    git_for_each_ref('refs/tags', sub {
+       my ($objid,$objtype,$fullrefname,$tagname) = @_;
+       next unless $objtype eq 'tag';
+       next if defined $objreferring and $objid ne $objreferring;
+       $func->($objid,$fullrefname,$tagname);
+    });
+}
+
 1;