#!/bin/sh

# This version of gendiff has been modified for Ksplice.
# gendiff was originally written by Marc Ewing <marc@redhat.com>,
# and it is available under the GNU General Public License.

[ -z "$1" -o -z "$2" ] && {
# usage
  echo "usage: $0 <directory> <diff-extension>" 1>&2
  exit 1
}

find $1 \( -name "*$2" -o -name ".*$2" -o -regex ".*ksplice/post/.*" -prune \) -print |
while read f; do
    U=-u
    [ "`basename $f`" = "ChangeLog$2" ] && U=-U0
    if [ -r "${f%$2}" ]; then
	diff ${U} "${f%$2}" "${f}"
    else
	diff ${U} /dev/null "${f}"
    fi
done

exit 0
