From: Ian Jackson Date: Sat, 28 Nov 2015 15:56:10 +0000 (+0000) Subject: Dgit.pm: Provide hashfile() X-Git-Tag: archive/debian/2.0~340 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=commitdiff_plain;h=f1d9b2980bf85457cb37fba193fbd930ffe4ebac;ds=inline Dgit.pm: Provide hashfile() Call site(s) will come later. --- diff --git a/Debian/Dgit.pm b/Debian/Dgit.pm index fa853741..2555812c 100644 --- a/Debian/Dgit.pm +++ b/Debian/Dgit.pm @@ -8,6 +8,7 @@ use warnings; use POSIX; use IO::Handle; use Config; +use Digest::SHA; BEGIN { use Exporter (); @@ -18,6 +19,7 @@ BEGIN { @EXPORT = qw(setup_sigwarn debiantag server_branch server_ref stat_exists link_ltarget + hashfile fail ensuredir executable_on_path waitstatusmsg failedcmd cmdoutput cmdoutput_errok @@ -229,6 +231,13 @@ sub link_ltarget ($$) { link $old, $new or die "link $old $new: $!"; } +sub hashfile ($) { + my ($fn) = @_; + my $h = Digest::SHA->new(256); + $h->addfile($fn); + return $h->hexdigest(); +} + sub git_rev_parse ($) { return cmdoutput qw(git rev-parse), "$_[0]~0"; }