2 # Copyright (c) 2015 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
8 if [ -z "$COMMIT" ]; then
12 # Taken from git-subtree (Copyright (C) 2009 Avery Pennarun <apenwarr@gmail.com>)
19 git log
--grep="^git-subtree-dir: $dir/*\$" \
20 --pretty=format
:'START %H%n%s%n%n%b%nEND%n' "$COMMIT" |
24 git-subtree-mainline
:) main
="$b" ;;
25 git-subtree-split
:) sub
="$b" ;;
27 if [ -n "$sub" ]; then
28 if [ -n "$main" ]; then
30 # Pretend its sub was a squash.
44 # find latest subtree update
45 latest_squash
="$(find_latest_squash "$DIR")"
46 if [ -z "$latest_squash" ]; then
47 echo "ERROR: $DIR is not a subtree" >&2
54 # get the tree in the current commit
55 tree_actual
=$
(git ls-tree
-d "$COMMIT" "$DIR" |
head -n 1)
56 if [ -z "$tree_actual" ]; then
57 echo "FAIL: subtree directory $DIR not found in $COMMIT" >&2
63 echo "$DIR in $COMMIT currently refers to $tree_actual_type $tree_actual_tree"
64 if [ "d$tree_actual_type" != "dtree" ]; then
65 echo "FAIL: subtree directory $DIR is not a tree in $COMMIT" >&2
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)"
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
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
85 tree_subtree
=$
(git show
-s --format="%T" $rev)
86 echo "$DIR in $COMMIT was last updated to upstream commit $rev (tree $tree_subtree)"
88 # ... and compare the actual tree with it
89 if [ "$tree_actual_tree" != "$tree_subtree" ]; then
90 echo "FAIL: subtree update commit differs from upstream tree!" >&2