Skip to content

Commit 6e4e98e

Browse files
author
MarcoFalke
committed
Merge #11394: Perform a weaker subtree check in Travis
487aff4 Check subtree consistency in Travis (Pieter Wuille) e1d0cc2 Improve git-subtree-check.sh (Pieter Wuille) Pull request description: Apparently many of our subtrees get modified by PRs in this repository, without getting noticed. To improve upon this: * Make git-subtree-check.sh capable of doing a weaker consistency check (that doesn't need access to external repositories), but which should be sufficient to detect unintended changes. It can be fooled by a fake subtree merge commit, but that would hopefully be obvious to reviewers. * Make Travis invoke this subtree check for each of our subtrees. Note that Travis is currently expected to fail on this PR, as 2 out of 4 subtrees (`src/secp156k1` and `src/univalue` have been modified directly in master). Tree-SHA512: 465b680392d3daf38a8c1dda77d6f74b1d1c23324c378774777fb95aa673e119a8f7e3ccc124e41d97b5ac8975f3d79f3015797d2d309666582394364917ec4e
2 parents c838283 + 487aff4 commit 6e4e98e

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ install:
4646
- if [ -n "$PACKAGES" ]; then travis_retry sudo apt-get install --no-install-recommends --no-upgrade -qq $PACKAGES; fi
4747
before_script:
4848
- if [ "$CHECK_DOC" = 1 -a "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then contrib/devtools/commit-script-check.sh $TRAVIS_COMMIT_RANGE; fi
49+
- if [ "$CHECK_DOC" = 1 ]; then contrib/devtools/git-subtree-check.sh src/crypto/ctaes; fi
50+
- if [ "$CHECK_DOC" = 1 ]; then contrib/devtools/git-subtree-check.sh src/secp256k1; fi
51+
- if [ "$CHECK_DOC" = 1 ]; then contrib/devtools/git-subtree-check.sh src/univalue; fi
52+
- if [ "$CHECK_DOC" = 1 ]; then contrib/devtools/git-subtree-check.sh src/leveldb; fi
4953
- if [ "$CHECK_DOC" = 1 ]; then contrib/devtools/check-doc.py; fi
5054
- if [ "$CHECK_DOC" = 1 ]; then contrib/devtools/check-rpc-mappings.py .; fi
5155
- if [ "$CHECK_DOC" = 1 ]; then contrib/devtools/lint-all.sh; fi

contrib/devtools/git-subtree-check.sh

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,17 @@ find_latest_squash()
4141
done
4242
}
4343

44+
# find latest subtree update
4445
latest_squash="$(find_latest_squash "$DIR")"
4546
if [ -z "$latest_squash" ]; then
4647
echo "ERROR: $DIR is not a subtree" >&2
4748
exit 2
4849
fi
49-
5050
set $latest_squash
5151
old=$1
5252
rev=$2
53-
if [ "d$(git cat-file -t $rev 2>/dev/null)" != dcommit ]; then
54-
echo "ERROR: subtree commit $rev unavailable. Fetch/update the subtree repository" >&2
55-
exit 2
56-
fi
57-
tree_subtree=$(git show -s --format="%T" $rev)
58-
echo "$DIR in $COMMIT was last updated to upstream commit $rev (tree $tree_subtree)"
53+
54+
# get the tree in the current commit
5955
tree_actual=$(git ls-tree -d "$COMMIT" "$DIR" | head -n 1)
6056
if [ -z "$tree_actual" ]; then
6157
echo "FAIL: subtree directory $DIR not found in $COMMIT" >&2
@@ -69,9 +65,30 @@ if [ "d$tree_actual_type" != "dtree" ]; then
6965
echo "FAIL: subtree directory $DIR is not a tree in $COMMIT" >&2
7066
exit 1
7167
fi
68+
69+
# get the tree at the time of the last subtree update
70+
tree_commit=$(git show -s --format="%T" $old)
71+
echo "$DIR in $COMMIT was last updated in commit $old (tree $tree_commit)"
72+
73+
# ... and compare the actual tree with it
74+
if [ "$tree_actual_tree" != "$tree_commit" ]; then
75+
git diff $tree_commit $tree_actual_tree >&2
76+
echo "FAIL: subtree directory was touched without subtree merge" >&2
77+
exit 1
78+
fi
79+
80+
# get the tree in the subtree commit referred to
81+
if [ "d$(git cat-file -t $rev 2>/dev/null)" != dcommit ]; then
82+
echo "subtree commit $rev unavailable: cannot compare" >&2
83+
exit
84+
fi
85+
tree_subtree=$(git show -s --format="%T" $rev)
86+
echo "$DIR in $COMMIT was last updated to upstream commit $rev (tree $tree_subtree)"
87+
88+
# ... and compare the actual tree with it
7289
if [ "$tree_actual_tree" != "$tree_subtree" ]; then
73-
git diff-tree $tree_actual_tree $tree_subtree >&2
74-
echo "FAIL: subtree directory tree doesn't match subtree commit tree" >&2
90+
echo "FAIL: subtree update commit differs from upstream tree!" >&2
7591
exit 1
7692
fi
93+
7794
echo "GOOD"

0 commit comments

Comments
 (0)