2 # Copyright (c) 2017 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.
6 # This simple script checks for commits beginning with: scripted-diff:
7 # If found, looks for a script between the lines -BEGIN VERIFY SCRIPT- and
8 # -END VERIFY SCRIPT-. If no ending is found, it reads until the end of the
11 # The resulting script should exactly transform the previous commit into the current
12 # one. Any remaining diff signals an error.
14 if test "x$1" = "x"; then
15 echo "Usage: $0 <commit>..."
20 PREV_BRANCH
=`git name-rev --name-only HEAD`
21 PREV_HEAD
=`git rev-parse HEAD`
22 for i
in `git rev-list --reverse $1`; do
23 if git rev-list
-n 1 --pretty="%s" $i |
grep -q "^scripted-diff:"; then
24 git checkout
--quiet $i^ ||
exit
25 SCRIPT
="`git rev-list --format=%b -n1 $i | sed '/^-BEGIN VERIFY SCRIPT-$/,/^-END VERIFY SCRIPT-$/{//!b};d'`"
26 if test "x$SCRIPT" = "x"; then
27 echo "Error: missing script for: $i"
31 echo "Running script for: $i"
34 git
--no-pager diff --exit-code $i && echo "OK" ||
(echo "Failed"; false
) || RET
=1
36 git
reset --quiet --hard HEAD
38 if git rev-list
"--format=%b" -n1 $i |
grep -q '^-\(BEGIN\|END\)[ a-zA-Z]*-$'; then
39 echo "Error: script block marker but no scripted-diff in title"
45 git checkout
--quiet $PREV_BRANCH 2>/dev
/null || git checkout
--quiet $PREV_HEAD