Index: quilt-sendmail/configure.ac
===================================================================
--- quilt-sendmail.orig/configure.ac
+++ quilt-sendmail/configure.ac
@@ -142,38 +142,24 @@ else
 	AC_MSG_RESULT(yes)
 fi
 
-AC_ARG_WITH(diffstat, AC_HELP_STRING(
-    [--with-diffstat], [name of the diffstat executable to use]),
-    [
-       DIFFSTAT="$withval"
-       AC_SUBST(DIFFSTAT)
-       AC_MSG_NOTICE([Using diffstat executable $DIFFSTAT])
-    ],[
-       AC_PATH_PROG(DIFFSTAT, diffstat)
-    ])
-if test -z "$DIFFSTAT"; then
-    AC_MSG_WARN([
-diffstat utility not found; the --diffstat option of the refresh command
-will not work correctly until diffstat is installed. If you have diffstat
-in a directory that is not in the search path you can specify its location
-using the '--with-diffstat' option.
-])
-    DIFFSTAT="diffstat"
-elif test "$DIFFSTAT" != no; then
+QUILT_COMPAT_PROG_PATH(DIFFSTAT, [diffstat])
+
+if test -z "$INTERNAL_DIFFSTAT"; then
     # We need diffstat version 1.32 or better, else quilt refresh --diffstat
     # will show progress data we don't want to see.  This is only a warning
     # and we continue even if version is older, as this is only a minor
     # annoyance.
     AC_MSG_CHECKING([for diffstat version])
-    diffstat_major_version=`$DIFFSTAT -V 2>/dev/null | \
-	sed 's/^[[^0-9]]*\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
-    diffstat_minor_version=`$DIFFSTAT -V 2>/dev/null | \
-	sed 's/^[[^0-9]]*\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
+    diffstat_version=`$DIFFSTAT -V 2>/dev/null | \
+        sed 's/^[[^0-9]]*\([[0-9]]*\)\.\([[0-9]]*\).*/\1 \2/'`
+    eval set -- "$diffstat_version"
+    diffstat_major_version="$1"
+    diffstat_minor_version="$2"
     if test -z "$diffstat_major_version" -o -z "$diffstat_minor_version"; then
 	AC_MSG_RESULT(unknown)
 	AC_MSG_WARN([
 diffstat utility version couldn't be checked; chances are good that the
---diffstat option of the refresh and diff commands will not work properly.
+--diffstat option of the refresh commands will not work properly.
 ])
     else
 	AC_MSG_RESULT($diffstat_major_version.$diffstat_minor_version)
Index: quilt-sendmail/quilt/refresh.in
===================================================================
--- quilt-sendmail.orig/quilt/refresh.in
+++ quilt-sendmail/quilt/refresh.in
@@ -49,10 +49,6 @@ patch.
 --no-index
 	Do not output Index: lines.
 
---diffstat
-	Add a diffstat section to the patch header, or replace the
-	existing diffstat section.
-
 -f	Enforce refreshing of a patch that is not on top.
 
 --backup
@@ -63,6 +59,14 @@ patch.
 --strip-trailing-whitespace
 	Strip trailing whitespace at the end of lines.
 "
+		if [ ! -f @QUILT@/compat/diffstat ]
+		then
+			printf "
+--diffstat
+	Add a diffstat section to the patch header, or replace the
+	existing diffstat section.
+"
+		fi
 		exit 0
 	else
 		exit 1
Index: quilt-sendmail/compat/diffstat.in
===================================================================
--- /dev/null
+++ quilt-sendmail/compat/diffstat.in
@@ -0,0 +1,4 @@
+#! @BASH@
+
+echo "diffstat support has not been built into \`quilt'" >&2
+exit 1
