1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
#!/bin/sh
if test $# -ne 2; then
cat >> /dev/stderr <<EOF
Usage:
$0 <repodir> <gitrev>
Where <repodir> defaults to the current directory. XXX: The parameter
order needs to be reversed.
Examine <gitrev> in <repodir> and determine if it is sufficiently
"interesting" to be worth testing.
The output is one of:
tag: <tagname>
a commit containing a tag
merge: <parents>
a merge point
branch: <children>
a branch point
true
a commit that changes build and/or source files
false
the commit is not interesting
EOF
exit 1
fi
set -eu
bindir=$(realpath $(dirname $0))
rutdir=$1 ; shift
gitrev=$1 ; shift
# All tags are interesting.
#
# If there is no tag then this command fails with an error so suppress
# that.
tag=$(git -C ${rutdir} describe --exact-match ${gitrev} 2>/dev/null || :)
if test -n "${tag}" ; then
echo tag: ${tag}
exit 0
fi
# All merges (commits with more than one parent) are "interesting".
parents=$(git -C ${rutdir} show --no-patch --format=%P ${gitrev})
if test $(echo ${parents} | wc -w) -gt 1 ; then
echo merge: ${parents}
exit 0
fi
# All branches (commits with more than one child) are "interesting".
#
# Determining children is messy for some reason: generate a <<parent
# child ...> list of all revisions more recent than GITREV
# (REV.. seems to be interpreted as that) and use that to find
# immediate parents (a child matches $GITREV).
children=$(git -C ${rutdir} rev-list --parents ${gitrev}.. | awk "/ ${gitrev}/ { print \$1}")
if test $(echo ${children} | wc -w) -gt 1 ; then
echo branch: ${children}
exit 0
fi
# grep . exits non-zero when there is no input (i.e., the diff is
# empty); and this will cause the command to fail.
if git -C ${rutdir} show "${gitrev}^{commit}" \
CHANGES \
Makefile \
mk \
lib \
programs \
include \
testing/pluto \
| grep . > /dev/null ; then
echo "true"
exit 0
fi
echo "false"
exit 1
|