diff --git a/scripts/check-kernel-commit b/scripts/check-kernel-commit new file mode 100755 index 0000000..533402c --- /dev/null +++ b/scripts/check-kernel-commit @@ -0,0 +1,137 @@ +#!/bin/bash + +usage() +{ + echo "Check whether a given list of commit is available in" + echo "a given list of branches." + echo + echo "Usage: ${0##*/} branches commit_hash..." + echo + echo "Parametes:" + echo " branches: file with the list of branches to be checked" + echo " commit_hash: hash of the commint to be found" +} + +if [ $# -lt 2 ] ; then + usage + exit 1 +fi + +branches=$1 +shift; +KBC_CHECK_HASHES="$*" + +if [ ! -f "$branches" ] ; then + "Error: Can't find the file with the list of branches: $branches" + exit 1 +fi + +check_branch() +{ + verbose=0 + if [ $1 == "-v" ] ; then + verbose=1 + shift + fi + + branch="$1" + found="" + missing="" + + for hash in $KBC_CHECK_HASHES ; do + git grep "$hash" "remotes/origin/$branch" >/dev/null 2>&1 + if [ $? -eq 0 ] ; then + found="$found $hash" + else + missing="$missing $hash" + fi + done + + # found + if [ -z "$missing" ] ; then + return 0 + fi + + # missing + if [ -z "$found" ] ; then + return 2 + fi + + # partly + if [ $verbose -ne 0 ] ; then + echo " missing hash:" + for hash in $missing ; do + echo " $hash" + done + echo + fi + return 1 +} + +check_parents() +{ + last_branch="" + for branch in "$@" ; do + check_branch $branch + case $? in + 0) + echo " (found in $branch)" + return + ;; + 1) + echo " (partly in $branch)" + return + ;; + *) + ;; + esac + last_branch="$branch" + done + + # not found anywhere + echo " (not even in $last_branch)" +} + +print_branch() +{ + branch="$1" + echo -n "$branch" + + len=`echo $branch| wc -c` + spaces=$((24 - $len)) + while [ $spaces -gt 0 ] ; do + echo -n " " + spaces=$(($spaces - 1)) + done +} + +while read line ; do + line=${line%%\#*} + branch=${line%% *} + parents=${line#$branch} + # always check also the _EMBARGO branch as a possible parent + parents="${branch}_EMBARGO $parents" + + # empty line or comment + if [ -z "$branch" ] ; then + continue + fi + + print_branch "$branch" + check_branch "$branch" + + case $? in + 0) + echo "" + ;; + 1) + echo -n " " + check_parents $parents + # print missing commits + check_branch -v "$branch" + ;; + *) + echo -n "" + check_parents "${branch}_EMBARGO" $parents + esac +done < "$branches"