|
1 | 1 | #!/bin/sh |
2 | | -# Copyright (c) 2017 The Bitcoin Core developers |
| 2 | +# Copyright (c) 2017-2020 The Bitcoin Core developers |
3 | 3 | # Distributed under the MIT software license, see the accompanying |
4 | 4 | # file COPYING or http://www.opensource.org/licenses/mit-license.php. |
5 | 5 |
|
|
11 | 11 | # The resulting script should exactly transform the previous commit into the current |
12 | 12 | # one. Any remaining diff signals an error. |
13 | 13 |
|
14 | | -if test "x$1" = "x"; then |
| 14 | +export LC_ALL=C |
| 15 | +if test -z $1; then |
15 | 16 | echo "Usage: $0 <commit>..." |
16 | 17 | exit 1 |
17 | 18 | fi |
18 | 19 |
|
19 | 20 | RET=0 |
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" |
| 21 | +PREV_BRANCH=$(git name-rev --name-only HEAD) |
| 22 | +PREV_HEAD=$(git rev-parse HEAD) |
| 23 | +for commit in $(git rev-list --reverse $1); do |
| 24 | + if git rev-list -n 1 --pretty="%s" $commit | grep -q "^scripted-diff:"; then |
| 25 | + git checkout --quiet $commit^ || exit |
| 26 | + SCRIPT="$(git rev-list --format=%b -n1 $commit | sed '/^-BEGIN VERIFY SCRIPT-$/,/^-END VERIFY SCRIPT-$/{//!b};d')" |
| 27 | + if test -z "$SCRIPT"; then |
| 28 | + echo "Error: missing script for: $commit" |
28 | 29 | echo "Failed" |
29 | 30 | RET=1 |
30 | 31 | else |
31 | | - echo "Running script for: $i" |
| 32 | + echo "Running script for: $commit" |
32 | 33 | echo "$SCRIPT" |
33 | | - eval "$SCRIPT" |
34 | | - git --no-pager diff --exit-code $i && echo "OK" || (echo "Failed"; false) || RET=1 |
| 34 | + (eval "$SCRIPT") |
| 35 | + git --no-pager diff --exit-code $commit && echo "OK" || (echo "Failed"; false) || RET=1 |
35 | 36 | fi |
36 | 37 | git reset --quiet --hard HEAD |
37 | 38 | else |
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" |
| 39 | + if git rev-list "--format=%b" -n1 $commit | grep -q '^-\(BEGIN\|END\)[ a-zA-Z]*-$'; then |
| 40 | + echo "Error: script block marker but no scripted-diff in title of commit $commit" |
40 | 41 | echo "Failed" |
41 | 42 | RET=1 |
42 | 43 | fi |
|
0 commit comments