Skip to content

Commit 1858e6f

Browse files
committed
Merge #14864: test: Run scripted-diff in subshell
43f9099 scripted-diff: Run scripted-diff in subshell (Carl Dong) Pull request description: scripted-diffs should be run in subshells so that their execution does not affect the shell variables of commit-script-check. Shell variables are not unset before evaluating the scripted-diff, so that they might be used in the subshell. To this end, the variable previously named i is now more descriptively named commit, this also allows scripted-diffs to use the commonly used variable i without fear of losing a reference to the commit. Tree-SHA512: 0d86c069c2a978ca07d71bcd2b1b273e9bfabfe7e31a50c7b1b860e04f178b81c65814c3a38fb01e50b41a5065b646f0dab5b05d9be71138e72d4baba607e37b
2 parents e2c473f + 43f9099 commit 1858e6f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

test/lint/commit-script-check.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ fi
2020
RET=0
2121
PREV_BRANCH=`git name-rev --name-only HEAD`
2222
PREV_HEAD=`git rev-parse HEAD`
23-
for i in `git rev-list --reverse $1`; do
24-
if git rev-list -n 1 --pretty="%s" $i | grep -q "^scripted-diff:"; then
25-
git checkout --quiet $i^ || exit
26-
SCRIPT="`git rev-list --format=%b -n1 $i | sed '/^-BEGIN VERIFY SCRIPT-$/,/^-END VERIFY SCRIPT-$/{//!b};d'`"
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'`"
2727
if test "x$SCRIPT" = "x"; then
28-
echo "Error: missing script for: $i"
28+
echo "Error: missing script for: $commit"
2929
echo "Failed"
3030
RET=1
3131
else
32-
echo "Running script for: $i"
32+
echo "Running script for: $commit"
3333
echo "$SCRIPT"
34-
eval "$SCRIPT"
35-
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
3636
fi
3737
git reset --quiet --hard HEAD
3838
else
39-
if git rev-list "--format=%b" -n1 $i | grep -q '^-\(BEGIN\|END\)[ a-zA-Z]*-$'; then
39+
if git rev-list "--format=%b" -n1 $commit | grep -q '^-\(BEGIN\|END\)[ a-zA-Z]*-$'; then
4040
echo "Error: script block marker but no scripted-diff in title"
4141
echo "Failed"
4242
RET=1

0 commit comments

Comments
 (0)