#!/bin/sh

set -e

PRG=$(basename "$0")

function showhelp() {
	cat <<EOF
Usage:   $PRG [git-buildpackage opts] [-- debuild opts]

Example: $PRG --git-sign-tags
EOF
}

if [ $# -eq 0 ]; then
	showhelp
	exit 1
fi

gitopts=''
while [ $# -gt 0 ]; do
	case $1 in
		-h|--help)
			showhelp
			exit 0
			;;
		--)
			shift
			break
			;;
		--git-*)
			gitopts="$gitopts $1"
			shift
			;;
		*)
			echo "ERROR: Unknown argument \"$1\"!" &>2
			showhelp
			exit 1
			;;
	esac
done

git-buildpackage \
	--git-builder="localdebuild -i\.git/ -I.git $@" \
	--git-cleaner="fakeroot debian/rules clean" \
	$gitopts