Skip to content

Commit 9519fc3

Browse files
committed
Backport latest commit-script-check.sh from upstream
1 parent 3b25450 commit 9519fc3

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

test/lint/commit-script-check.sh

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
2-
# Copyright (c) 2017 The Bitcoin Core developers
2+
# Copyright (c) 2017-2020 The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

@@ -11,32 +11,33 @@
1111
# The resulting script should exactly transform the previous commit into the current
1212
# one. Any remaining diff signals an error.
1313

14-
if test "x$1" = "x"; then
14+
export LC_ALL=C
15+
if test -z $1; then
1516
echo "Usage: $0 <commit>..."
1617
exit 1
1718
fi
1819

1920
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"
2829
echo "Failed"
2930
RET=1
3031
else
31-
echo "Running script for: $i"
32+
echo "Running script for: $commit"
3233
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
3536
fi
3637
git reset --quiet --hard HEAD
3738
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"
4041
echo "Failed"
4142
RET=1
4243
fi

0 commit comments

Comments
 (0)