Description: add --select option to mail command
 .
 When you want to only send out part of a series, this is not
 trivial with quilt. This patch adds a --select option to the
 mail command to allow editing a copy of the series file before
 sending mail so that only those patches you keep in that file
 are sent.
Origin: vendor
Author: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Martin Quinson <mquinson@debian.org>
Last-Update: 2013-08-05
Bug-Debian: http://bugs.debian.org/481331

---
 quilt/mail.in |   29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

Index: b/quilt/mail.in
===================================================================
--- a/quilt/mail.in
+++ b/quilt/mail.in
@@ -19,7 +19,7 @@
 
 usage()
 {
-	printf $"Usage: quilt mail {--mbox file|--send} [-m text] [-M file] [--prefix prefix] [--sender ...] [--from ...] [--to ...] [--cc ...] [--bcc ...] [--subject ...] [--reply-to message] [first_patch [last_patch]]\n"
+	printf $"Usage: quilt mail {--mbox file|--send} [--select] [-m text] [-M file] [--prefix prefix] [--sender ...] [--from ...] [--to ...] [--cc ...] [--bcc ...] [--subject ...] [--reply-to message] [first_patch [last_patch]]\n"
 	if [ x$1 = x-h ]
 	then
 		printf $"
@@ -66,6 +66,9 @@
 
 --reply-to message
 	Add the appropriate headers to reply to the specified message.
+
+--select
+	Edit a copy of the series file to select patches to send.
 " "@DOCSUBDIR@/README.MAIL"
 		exit 0
 	else
@@ -163,7 +166,7 @@
 options=`getopt -o m:M:h \
 		--long from:,to:,cc:,bcc:,subject: \
 		--long send,mbox:,charset:,sender: \
-		--long prefix:,reply-to:,signature: -- "$@"`
+		--long select,prefix:,reply-to:,signature: -- "$@"`
 
 if [ $? -ne 0 ]
 then
@@ -221,6 +224,9 @@
 	--send)
 		opt_send=1
 		shift ;;
+	--select)
+		opt_select=1
+		shift ;;
 	--mbox)
 		opt_mbox=$2
 		shift 2 ;;
@@ -260,6 +266,10 @@
 
 if [ $# -ge 1 ]
 then
+	if [ -n "$opt_select" ] ; then
+		echo $"Cannot use --select when specifying the first and last patch to work with."
+		exit 1
+	fi
 	if [ "$1" = - ]
 	then
 		first_patch="$(find_first_patch)" || exit 1
@@ -414,6 +424,9 @@
 	}
 fi
 
+tmpdir=$(gen_tempfile -d)
+add_exit_handler "rm -rf $tmpdir"
+
 if [ -n "$first_patch" ]
 then
 	if [ -n "$last_patch" ]
@@ -435,14 +448,18 @@
 	else
 		patches=( "$first_patch" $(patches_after "$first_patch") )
 	fi
-else
+elif [ -n "$opt_select" ] ; then
+	nser="$tmpdir/series"
+	cp "$SERIES" "$nser"
+	if ! $EDITOR "$nser" ; then
+		exit 1
+	fi
+	SERIES="$nser"
+else	
 	patches=( $(cat_series) )
 fi
 total=${#patches[@]}
 
-tmpdir=$(gen_tempfile -d)
-add_exit_handler "rm -rf $tmpdir"
-
 for patch in "${patches[@]}"
 do
 	mkdir -p "$tmpdir/$(dirname "$patch")"
