summaryrefslogtreecommitdiff
path: root/Debian/Dgit.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Debian/Dgit.pm')
-rw-r--r--Debian/Dgit.pm15
1 files changed, 14 insertions, 1 deletions
diff --git a/Debian/Dgit.pm b/Debian/Dgit.pm
index 8b29ba2..4d9b81a 100644
--- a/Debian/Dgit.pm
+++ b/Debian/Dgit.pm
@@ -12,7 +12,7 @@ BEGIN {
$VERSION = 1.00;
@ISA = qw(Exporter);
@EXPORT = qw(debiantag server_branch server_ref
- stat_exists
+ stat_exists git_for_each_ref
$package_re $branchprefix);
%EXPORT_TAGS = ( policyflags => qw() );
@EXPORT_OK = qw();
@@ -51,4 +51,17 @@ sub stat_exists ($) {
die "stat $f: $!";
}
+sub git_for_each_ref ($$) {
+ my ($pattern,$func) = @_;
+ # calls $func->($objid,$objtype,$fullrefname,$reftail);
+ # $reftail is RHS of ref after refs/\w+/
+ # breaks if $pattern matches any ref `refs/blah' where blah has no `/'
+ my $fh = new IO::File, "-|", qw(git for-each-ref), $pattern or die $!;
+ while (<$fh>) {
+ m#^(\w+)\s+(\w+)\s+(refs/\w+/(\S+))\s# or die "$_ ?";
+ $func->($1,$2,$3,$4);
+ }
+ $!=0; $?=0; close $fh or die "$pattern $? $!";
+}
+
1;