aboutsummaryrefslogtreecommitdiff
path: root/contrib/verify-commits
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2018-04-07 18:47:17 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2018-04-07 18:48:27 +0200
commitb2e5fe8b559b2f6561ee8f220e9141e401929f5e (patch)
tree13a4261192d527911a77061cde3fe7ec6b63c971 /contrib/verify-commits
parentf8d6dc47cbe7b65f05eb9e77e9e8b19659c25831 (diff)
parent577f11141c5155345c68809aac8511b018cc4050 (diff)
Merge #12708: Make verify-commits.sh test that merges are clean
577f111 Make verify-commits.sh test that merges are clean (Pieter Wuille) Pull request description: Unsure if we want this. This modifies verify-commits.sh to redo all merges along the leftmost commit branch (which includes all PR merges), and verify whether they match the merge commit's trees. The benefit is that it will detect a case where one of the maintainers merges a PR, but makes an unrelated change inside the merge commit. This on itself is not very strong, as unrelated changes can also be included in the merged branch itself - but perhaps the merge commit is not something that people are otherwise likely to look at. Fixes #8089 Tree-SHA512: 2c020f5ac3f771ac775aa726832916bb8e03a311b2745d7a9825047239bd0660d838f086f3456f2bb05cea14c1529f74436b8cdd74cc94b70e40b4617309f62c
Diffstat (limited to 'contrib/verify-commits')
-rwxr-xr-xcontrib/verify-commits/verify-commits.sh32
1 files changed, 27 insertions, 5 deletions
diff --git a/contrib/verify-commits/verify-commits.sh b/contrib/verify-commits/verify-commits.sh
index 532b97a438..6415eea4d5 100755
--- a/contrib/verify-commits/verify-commits.sh
+++ b/contrib/verify-commits/verify-commits.sh
@@ -35,6 +35,8 @@ NO_SHA1=1
PREV_COMMIT=""
INITIAL_COMMIT="${CURRENT_COMMIT}"
+BRANCH="$(git rev-parse --abbrev-ref HEAD)"
+
while true; do
if [ "$CURRENT_COMMIT" = $VERIFIED_ROOT ]; then
echo "There is a valid path from \"$INITIAL_COMMIT\" to $VERIFIED_ROOT where all commits are signed!"
@@ -123,9 +125,29 @@ while true; do
fi
PARENTS=$(git show -s --format=format:%P "$CURRENT_COMMIT")
- for PARENT in $PARENTS; do
- PREV_COMMIT="$CURRENT_COMMIT"
- CURRENT_COMMIT="$PARENT"
- break
- done
+ PARENT1=${PARENTS%% *}
+ PARENT2=""
+ if [ "x$PARENT1" != "x$PARENTS" ]; then
+ PARENTX=${PARENTS#* }
+ PARENT2=${PARENTX%% *}
+ if [ "x$PARENT2" != "x$PARENTX" ]; then
+ echo "Commit $CURRENT_COMMIT is an octopus merge" > /dev/stderr
+ exit 1
+ fi
+ fi
+ if [ "x$PARENT2" != "x" ]; then
+ CURRENT_TREE="$(git show --format="%T" "$CURRENT_COMMIT")"
+ git checkout --force --quiet "$PARENT1"
+ git merge --no-ff --quiet "$PARENT2" >/dev/null
+ RECREATED_TREE="$(git show --format="%T" HEAD)"
+ if [ "$CURRENT_TREE" != "$RECREATED_TREE" ]; then
+ echo "Merge commit $CURRENT_COMMIT is not clean" > /dev/stderr
+ git diff "$CURRENT_COMMIT"
+ git checkout --force --quiet "$BRANCH"
+ exit 1
+ fi
+ git checkout --force --quiet "$BRANCH"
+ fi
+ PREV_COMMIT="$CURRENT_COMMIT"
+ CURRENT_COMMIT="$PARENT1"
done