#!/bin/sh
#
# Copyright (c) Josef "Jeff" Sipek, 2006-2013
#

USAGE="[--git] [--diffstat]"
COLOR=`git config --get color.ui`

if [ -z "$GUILT_VERSION" ]; then
	echo "Invoking `basename "$0"` directly is no longer supported." >&2
	exit 1
fi

_main() {

if [ "$COLOR" = "always" ]; then
	echo "git color.ui=always is unsupported because"
	echo "escape characters will be redirected"
	echo "please set it to color.ui=auto"
	exit 1
fi

while [ $# -gt 0 ]; do
	case "$1" in
		--git)
			gdiff=t ;;
		--diffstat)
			dstat=t ;;
		*)
			usage ;;
	esac
	shift
done

TOP=`get_top`

if [ -z "$TOP" ]; then
	die "No patches applied; try guilt push first"
fi

refresh_patch "$TOP" "$gdiff" "$dstat"
echo "Patch $TOP refreshed"

}
