diff options
author | Jakub Jirutka <jakub@jirutka.cz> | 2017-12-29 00:53:29 +0100 |
---|---|---|
committer | Jakub Jirutka <jakub@jirutka.cz> | 2017-12-29 00:54:50 +0100 |
commit | 328ee5e65cd273648e296912760ebbe69381deba (patch) | |
tree | ab28ca5957d952ecb6819a82bcad042deade15e8 /.githooks/pre-commit | |
parent | 65010e4ea4b5ff37f6cc677674423e1ffa55e814 (diff) | |
download | aports-328ee5e65cd273648e296912760ebbe69381deba.tar.bz2 aports-328ee5e65cd273648e296912760ebbe69381deba.tar.xz |
githooks: fix checksum comparison in pre-commit hook
The previous method didn't work for larger files.
Diffstat (limited to '.githooks/pre-commit')
-rwxr-xr-x | .githooks/pre-commit | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 1960d863ba..b286691a3d 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -57,22 +57,23 @@ check_local_sources() { local apkbuild="$1" local startdir="${apkbuild%/*}" local status=0 - local checksum content filename line sources + local checksum_act checksum_exp content filename line sources sources=$(abuild_local_sources "$apkbuild") for line in $sources; do filename=${line%%:*} - checksum=${line#*:} + checksum_exp=${line#*:} - content=$(git show ":$startdir/$filename" 2>/dev/null) || { + if ! git cat-file -e ":$startdir/$filename" 2>/dev/null; then error "$startdir: missing file \"$filename\"" status=1 continue - } - [ "$(printf '%s\n' "$content" | sha512sum)" = "$checksum -" ] || { + fi + checksum_act=$(git show ":$startdir/$filename" | sha512sum) + if [ "$checksum_act" != "$checksum_exp -" ]; then error "$startdir: bad checksum for file \"$filename\" (hint: run abuild checksum)" status=1 - } + fi done return $status |