blob: 72f27ed313fcd8b9f1cf35c0ac9be2abebe44db4 [file] [log] [blame]
#!/bin/bash
# Do a quick sanity test on a cherry picked commit. Currently performed
# by comparing the diffstat of the two and looking for differences.
#
# Also check that the patched functions match; in case things got applied
# to a similar looking block of code in a different function.
# For this, we filter out things that might trigger false positives, such
# as changes to the function args, or the function type, etc.
PATCH=$1
# If a patch appears "different", then look for this in the commit log
# to see if the gomer messing with it explained why.
GOMER=PG:
if [ -z "$1" ]; then
echo must supply patchname
exit 1
fi
if [ "$1" = "-q" ]; then
QUIET=1
shift
fi
if [ ! -f "$1" ]; then
echo patchname $1 does not exist
exit 1
fi
PARENT=`cat $1|grep ommit|grep 'pstream\|herry'|sed 's/.* \([0-9a-f]\+\).*/\1/'|head -n1`
LEN=`echo $PARENT|wc -c`
# Check for garbage strings that arent SHA.
if [ "$LEN" != "41" ]; then
PARENT=""
fi
if [ -z "$PARENT" ]; then
if [ -z "$QUIET" ]; then
echo $1
echo -e \\t' *** This has unknown parent commit. ***'
fi
exit 1
fi
git show $PARENT > /dev/null 2>&1
if [ $? != 0 ]; then
if [ -z "$QUIET" ]; then
echo $1
echo -e \\t' *** Indicated parent commit ('$PARENT') is bogus. ***'
fi
exit 1
fi
# Collect data on the parent
A=`mktemp`
git show --pretty=email $PARENT | diffstat -p0 > $A
echo -n 'Chunk count: ' >> $A
git show --pretty=email $PARENT|grep ^@@ | wc -l >> $A
# and the function list
git show --pretty=email $PARENT \
|grep ^@@ \
| sed 's/^@@.*@@//' \
| sed 's/static //' \
| sed 's/inline //' \
| sed 's/extern //' \
| sed 's/const //' \
| sed 's/char //' \
| sed 's/int //' \
| sed 's/unsigned //' \
| sed 's/struct //' \
| sed 's/void //' \
| sed 's/long //' \
| sed 's/__init //' \
| sed 's/__cpuinit //' \
| sed 's/(..*$//' \
>> $A
# Collect data on the cherry pick
B=`mktemp`
diffstat -p0 $1 > $B
echo -n 'Chunk count: ' >> $B
cat $1 |grep ^@@ | wc -l >> $B
# and the function list
cat $1 |grep ^@@ \
| sed 's/^@@.*@@//' \
| sed 's/static //' \
| sed 's/inline //' \
| sed 's/extern //' \
| sed 's/const //' \
| sed 's/char //' \
| sed 's/int //' \
| sed 's/unsigned //' \
| sed 's/struct //' \
| sed 's/void //' \
| sed 's/long //' \
| sed 's/__init //' \
| sed 's/__cpuinit //' \
| sed 's/(..*$//' \
>> $B
cmp -s $A $B
RETVAL=$?
if [ -z "$QUIET" ]; then
if [ $RETVAL != 0 ]; then
echo $1
diff -u $A $B |grep '^[+-] '
fi
fi
rm -f $A $B
cat $1 | grep -q '^C[cC]:.*stable@kernel.org'
if [ $? = 0 ]; then
if [ -z "$QUIET" ]; then
echo $1
echo patch has Lingering CC to stable
fi
RETVAL=1
fi
# Assume sign off on cherry pick should be N+1 of parent.
SOB_PCOUNT=`git show --pretty=email $PARENT |grep ^Signed-off-by: |wc -l`
SOB_CCOUNT=`cat $1 |grep ^Signed-off-by: |wc -l`
SOB_PCOUNT=$[$SOB_PCOUNT+1]
if [ $SOB_PCOUNT -ne $SOB_CCOUNT ];then
if [ -z "$QUIET" ]; then
echo $1
echo patch possibly missing the SOB line?
fi
RETVAL=1
fi
# Look for explanation from mangler as to why it might fail sanity check.
if [ $RETVAL != 0 ]; then
if [ -z "$QUIET" ]; then
grep -A1 $GOMER $1
fi
fi
exit $RETVAL