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" |
21 while read a b junk
; do
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 latest_squash
="$(find_latest_squash "$DIR")"
45 if [ -z "$latest_squash" ]; then
46 echo "ERROR: $DIR is not a subtree" >&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
57 tree_subtree
=$
(git show
-s --format="%T" $rev)
58 echo "$DIR in $COMMIT was last updated to upstream commit $rev (tree $tree_subtree)"
59 tree_actual
=$
(git ls-tree
-d "$COMMIT" "$DIR" |
head -n 1)
60 if [ -z "$tree_actual" ]; then
61 echo "FAIL: subtree directory $DIR not found in $COMMIT" >&2
67 echo "$DIR in $COMMIT currently refers to $tree_actual_type $tree_actual_tree"
68 if [ "d$tree_actual_type" != "dtree" ]; then
69 echo "FAIL: subtree directory $DIR is not a tree in $COMMIT" >&2
72 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