diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2015-05-27 21:28:39 +0100 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2015-05-31 12:17:08 +0100 |
commit | 0c838feda384f115a115ddd609eca9b8c6ece162 (patch) | |
tree | 8cb1c0e7bd98def61fd28851c6c461ecb02b5ce9 /Debian | |
parent | c31626414fabe6a00ff9db901f69016d26400cb4 (diff) |
git_get_ref: Move to Dgit.pm and reimplement
Use
git for-each-ref --format=%(objectname) [r]efs/whatever
This pattern won't match literally as a prefix because a ref name
cannot contain [, so it must match according to fnmatch. whatever
cannot contain fnmatch metacharacters because they're not valid in ref
names.
This is a better idiom because it might directly look up the ref in
question (although currently it probably doesn't).
Diffstat (limited to 'Debian')
-rw-r--r-- | Debian/Dgit.pm | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Debian/Dgit.pm b/Debian/Dgit.pm index a270cd8..32c2bc5 100644 --- a/Debian/Dgit.pm +++ b/Debian/Dgit.pm @@ -18,7 +18,7 @@ BEGIN { @EXPORT = qw(debiantag server_branch server_ref stat_exists fail ensuredir waitstatusmsg failedcmd cmdoutput cmdoutput_errok - git_rev_parse git_for_each_ref + git_rev_parse git_get_ref git_for_each_ref git_for_each_tag_referring is_fast_fwd $package_re $component_re $deliberately_re $branchprefix @@ -205,6 +205,14 @@ sub git_for_each_ref ($$) { $!=0; $?=0; close GFER or die "$pattern $? $!"; } +sub git_get_ref ($) { + # => '' if no such ref + my ($refname) = @_; + my $_ = $refname; + s{^refs/}{[r]efs/} or die "$refname $_ ?"; + return cmdoutput qw(git for-each-ref --format=%(objectname)), $_; +} + sub git_for_each_tag_referring ($$) { my ($objreferring, $func) = @_; # calls $func->($tagobjid,$refobjid,$fullrefname,$tagname); |