Skip to content

Commit efc06c2

Browse files
committed
If GNU sha512sum is missing, try perl shasum in verify-commits
1 parent 8ed849f commit efc06c2

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

contrib/verify-commits/verify-commits.sh

+15-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ REVSIG_ALLOWED=$(cat "${DIR}/allow-revsig-commits")
1414

1515
HAVE_FAILED=false
1616

17+
HAVE_GNU_SHA512=1
18+
[ ! -x "$(which sha512sum)" ] && HAVE_GNU_SHA512=0
19+
1720
if [ x"$1" = "x" ]; then
1821
CURRENT_COMMIT="HEAD"
1922
else
@@ -91,16 +94,26 @@ while true; do
9194

9295
FILE_HASHES=""
9396
for FILE in $(git ls-tree --full-tree -r --name-only "$CURRENT_COMMIT" | LC_ALL=C sort); do
94-
HASH=$(git cat-file blob "$CURRENT_COMMIT":"$FILE" | sha512sum | { read FIRST OTHER; echo $FIRST; } )
97+
if [ "$HAVE_GNU_SHA512" = 1 ]; then
98+
HASH=$(git cat-file blob "$CURRENT_COMMIT":"$FILE" | sha512sum | { read FIRST OTHER; echo $FIRST; } )
99+
else
100+
HASH=$(git cat-file blob "$CURRENT_COMMIT":"$FILE" | shasum -a 512 | { read FIRST OTHER; echo $FIRST; } )
101+
fi
95102
[ "$FILE_HASHES" != "" ] && FILE_HASHES="$FILE_HASHES"'
96103
'
97104
FILE_HASHES="$FILE_HASHES$HASH $FILE"
98105
done
106+
107+
if [ "$HAVE_GNU_SHA512" = 1 ]; then
108+
TREE_HASH="$(echo "$FILE_HASHES" | sha512sum)"
109+
else
110+
TREE_HASH="$(echo "$FILE_HASHES" | shasum -a 512)"
111+
fi
99112
HASH_MATCHES=0
100113
MSG="$(git show -s --format=format:%B "$CURRENT_COMMIT" | tail -n1)"
101114

102115
case "$MSG -" in
103-
"Tree-SHA512: $(echo "$FILE_HASHES" | sha512sum)")
116+
"Tree-SHA512: $TREE_HASH")
104117
HASH_MATCHES=1;;
105118
esac
106119

0 commit comments

Comments
 (0)