Skip to content

Commit b3ec305

Browse files
committed
Fix bashisms in verify-commits and always check top commit's tree
1 parent f20e664 commit b3ec305

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b00ba6251f71fa1edaabdf809514e1bc3c67862e
1+
f7ec7cfd38b543ba81ac7bed5b77f9a19739460b

contrib/verify-commits/verify-commits.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ IS_SIGNED () {
4747
return 1;
4848
fi
4949

50-
if [ "$VERIFY_TREE" = 1 ]; then
50+
# We set $4 to 1 on the first call, always verifying the top of the tree
51+
if [ "$VERIFY_TREE" = 1 -o "$4" = "1" ]; then
5152
IFS_CACHE="$IFS"
5253
IFS='
5354
'
@@ -63,9 +64,10 @@ IS_SIGNED () {
6364
IFS="$IFS_CACHE"
6465

6566
FILE_HASHES=""
66-
for FILE in $(git ls-tree --full-tree -r --name-only $1 | LANG=C sort); do
67+
for FILE in $(git ls-tree --full-tree -r --name-only $1 | LC_ALL=C sort); do
6768
HASH=$(git cat-file blob $1:"$FILE" | sha512sum | { read FIRST OTHER; echo $FIRST; } )
68-
[ "$FILE_HASHES" != "" ] && FILE_HASHES="$FILE_HASHES"$'\n'
69+
[ "$FILE_HASHES" != "" ] && FILE_HASHES="$FILE_HASHES"'
70+
'
6971
FILE_HASHES="$FILE_HASHES$HASH $FILE"
7072
done
7173
HASH_MATCHES=0
@@ -86,7 +88,7 @@ IS_SIGNED () {
8688
local PARENTS
8789
PARENTS=$(git show -s --format=format:%P $1)
8890
for PARENT in $PARENTS; do
89-
if IS_SIGNED $PARENT $VERIFY_TREE $NO_SHA1; then
91+
if IS_SIGNED $PARENT $VERIFY_TREE $NO_SHA1 0; then
9092
return 0;
9193
fi
9294
break
@@ -111,10 +113,9 @@ fi
111113
DO_CHECKOUT_TEST=0
112114
if [ x"$2" = "x--tree-checks" ]; then
113115
DO_CHECKOUT_TEST=1
114-
115116
fi
116117

117-
IS_SIGNED "$TEST_COMMIT" "$DO_CHECKOUT_TEST" 1
118+
IS_SIGNED "$TEST_COMMIT" "$DO_CHECKOUT_TEST" 1 1
118119
RES=$?
119120
if [ "$RES" = 1 ]; then
120121
if ! "$HAVE_FAILED"; then

0 commit comments

Comments
 (0)