From christoph.mallon@gmx.de  Sat Feb  9 13:50:30 2013
Return-Path: <christoph.mallon@gmx.de>
Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115])
	by hub.freebsd.org (Postfix) with ESMTP id CDF38469
	for <freebsd-gnats-submit@freebsd.org>; Sat,  9 Feb 2013 13:50:30 +0000 (UTC)
	(envelope-from christoph.mallon@gmx.de)
Received: from mout.gmx.net (mout.gmx.net [212.227.17.21])
	by mx1.freebsd.org (Postfix) with ESMTP id 644FEAE2
	for <freebsd-gnats-submit@freebsd.org>; Sat,  9 Feb 2013 13:50:30 +0000 (UTC)
Received: from mailout-de.gmx.net ([10.1.76.24]) by mrigmx.server.lan
 (mrigmx002) with ESMTP (Nemesis) id 0MP3Jh-1TyNfO1ixb-006PVG for
 <FreeBSD-gnats-submit@freebsd.org>; Sat, 09 Feb 2013 14:50:29 +0100
Received: (qmail invoked by alias); 09 Feb 2013 13:50:29 -0000
Received: from p5B132F8B.dip.t-dialin.net (EHLO rotluchs.lokal) [91.19.47.139]
  by mail.gmx.net (mp024) with SMTP; 09 Feb 2013 14:50:29 +0100
Received: from tron by rotluchs.lokal with local (Exim 4.80.1 (FreeBSD))
	(envelope-from <christoph.mallon@gmx.de>)
	id 1U4Ap1-0005mJ-Ea; Sat, 09 Feb 2013 14:50:27 +0100
Message-Id: <E1U4Ap1-0005mJ-Ea@rotluchs.lokal>
Date: Sat, 09 Feb 2013 14:50:27 +0100
From: Christoph Mallon <christoph.mallon@gmx.de>
Reply-To: Christoph Mallon <christoph.mallon@gmx.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Eitan Adler <eadler@FreeBSD.org>
Subject: [PATCH] Improve send-pr
X-Send-Pr-Version: 3.114
X-GNATS-Notify: Eitan Adler <eadler@FreeBSD.org>

>Number:         175985
>Category:       gnu
>Synopsis:       [PATCH] Improve send-pr(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Sat Feb 09 14:00:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Sat Feb 16 07:10:00 UTC 2013
>Originator:     Christoph Mallon
>Release:        
>Organization:
>Environment:


	
>Description:
- Do not delete lines starting with Subject:.
  They are most probably part of a attached git patch.
- Recognize an empty file as a not filled out PR, too.
- Allow attaching files via -- followed by file names.
	
>How-To-Repeat:
	
>Fix:
Please apply the patches.

	

--- 0001-send-pr-Do-not-delete-lines-starting-with-Subject.patch begins here ---
From 5184b240a473c99e960e3bf91137c6cbe9b87916 Mon Sep 17 00:00:00 2001
From: Christoph Mallon <christoph.mallon@gmx.de>
Date: Thu, 7 Feb 2013 15:27:37 +0100
Subject: [PATCH 1/3] send-pr: Do not delete lines starting with Subject:.

They are most probably part of a attached git patch.
---
 gnu/usr.bin/send-pr/send-pr.sh | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/gnu/usr.bin/send-pr/send-pr.sh b/gnu/usr.bin/send-pr/send-pr.sh
index dee0f48..cafab61 100644
--- a/gnu/usr.bin/send-pr/send-pr.sh
+++ b/gnu/usr.bin/send-pr/send-pr.sh
@@ -528,19 +528,6 @@ while true; do
 done
 
 #
-# Remove the subject field if one is already there.  There's no reason
-# for it to be any different than the synopsis.
-#
-if grep '^Subject:' $TEMP > /dev/null
-then
-  ed -s $TEMP << __EOF__
-/^Subject:/d
-w
-q
-__EOF__
-fi
-
-#
 # Add the subject field with the value of $SYNOPSIS.  We use the To:
 # field as an anchor, which had better be there.
 #
-- 
1.8.1.3
--- 0001-send-pr-Do-not-delete-lines-starting-with-Subject.patch ends here ---

--- 0002-send-pr-Recognize-an-empty-file-as-a-not-filled-out-.patch begins here ---
From 1aef69d088167180c2c9e7c7abc55d256afc59db Mon Sep 17 00:00:00 2001
From: Christoph Mallon <christoph.mallon@gmx.de>
Date: Thu, 7 Feb 2013 15:31:48 +0100
Subject: [PATCH 2/3] send-pr: Recognize an empty file as a not filled out PR,
 too.

---
 gnu/usr.bin/send-pr/send-pr.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gnu/usr.bin/send-pr/send-pr.sh b/gnu/usr.bin/send-pr/send-pr.sh
index cafab61..c009a18 100644
--- a/gnu/usr.bin/send-pr/send-pr.sh
+++ b/gnu/usr.bin/send-pr/send-pr.sh
@@ -393,7 +393,7 @@ __EOF__
   chmod u+w $TEMP
   eval $EDIT $TEMP
 
-  if cmp -s $REF $TEMP ; then
+  if [ ! -s "$TEMP" ] || cmp -s $REF $TEMP ; then
     echo "$COMMAND: problem report not filled out, therefore not sent"
     xs=1; exit
   fi
-- 
1.8.1.3
--- 0002-send-pr-Recognize-an-empty-file-as-a-not-filled-out-.patch ends here ---

--- 0003-send-pr-Allow-attaching-files-via-followed-by-file-n.patch begins here ---
From fe33d1d033e98bf627d49a111a711ee3c2334872 Mon Sep 17 00:00:00 2001
From: Christoph Mallon <christoph.mallon@gmx.de>
Date: Wed, 6 Feb 2013 15:16:23 +0100
Subject: [PATCH 3/3] send-pr: Allow attaching files via -- followed by file
 names.

---
 gnu/usr.bin/send-pr/send-pr.1  |  6 ++++++
 gnu/usr.bin/send-pr/send-pr.sh | 42 +++++++++++++++++++++++++++---------------
 2 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/gnu/usr.bin/send-pr/send-pr.1 b/gnu/usr.bin/send-pr/send-pr.1
index 49fd42b..4953a50 100644
--- a/gnu/usr.bin/send-pr/send-pr.1
+++ b/gnu/usr.bin/send-pr/send-pr.1
@@ -67,6 +67,12 @@ send-pr \- send problem report (PR) to a central support site
 .B \-a
 .I file
 ]
+[
+--
+[
+.I file...
+]
+]
 .SH DESCRIPTION
 .B send-pr
 is a tool used to submit 
diff --git a/gnu/usr.bin/send-pr/send-pr.sh b/gnu/usr.bin/send-pr/send-pr.sh
index c009a18..07950a7 100644
--- a/gnu/usr.bin/send-pr/send-pr.sh
+++ b/gnu/usr.bin/send-pr/send-pr.sh
@@ -144,6 +144,24 @@ BATCH=
 CC=
 SEVERITY_C=
 
+attach()
+{
+  if [ -e "$1" -a ! -d "$1" ]; then
+    PRETTY_NAME=${1##*/}
+    if file -b "$1" | grep -q "text" 2>/dev/null ; then
+      ATTACHED_FILES="$ATTACHED_FILES
+--- $PRETTY_NAME begins here ---
+$(cat "$1")
+--- $PRETTY_NAME ends here ---
+"
+    else
+      ATTACHED_FILES="$ATTACHED_FILES
+$(uuencode "$PRETTY_NAME" < "$1")
+"
+    fi
+  fi
+}
+
 while [ $# -gt 0 ]; do
   case "$1" in
     -r) ;; 		# Ignore for backward compat.
@@ -173,22 +191,16 @@ while [ $# -gt 0 ]; do
     -a | --attach) if [ -z "$2" ]; then
 	  echo "$USAGE" ; exit 1; 
 	fi
-	if [ -e "$2" -a ! -d "$2" ]; then
-	  PRETTY_NAME=`basename $2`
-	  if file $2 | grep "text" >/dev/null 2>/dev/null ; then
-	    ATTACHED_FILES="$ATTACHED_FILES
---- $PRETTY_NAME begins here ---
-`cat \"$2\"`
---- $PRETTY_NAME ends here ---
-"
-	  else
-	    ATTACHED_FILES="$ATTACHED_FILES
-`uuencode \"$PRETTY_NAME\" < \"$2\"`
-"
-	  fi
-	  shift;
-	fi;
+	attach "$2"
+	shift
 	;;
+    --)
+	shift
+	while [ "$#" != 0 ]; do
+		attach "$1"
+		shift
+	done
+	break;;
     -*) echo "$USAGE" ; exit 1 ;;
     *) if [ -z "$USER_GNATS_SITE" ]; then
 	 if [ ! -r "$DATADIR/gnats/$1" ]; then
-- 
1.8.1.3
--- 0003-send-pr-Allow-attaching-files-via-followed-by-file-n.patch ends here ---


>Release-Note:
>Audit-Trail:

From: Eitan Adler <eadler@freebsd.org>
To: Christoph Mallon <christoph.mallon@gmx.de>
Cc: bug-followup <bug-followup@freebsd.org>
Subject: Re: gnu/175985: [PATCH] Improve send-pr
Date: Fri, 15 Feb 2013 13:25:30 -0500

 On 9 February 2013 08:50, Christoph Mallon <christoph.mallon@gmx.de> wrote:
 
 I have not yet looked at the code.
 
 >>Description:
 > - Do not delete lines starting with Subject:.
 >   They are most probably part of a attached git patch.
 
 This is probably fine, but I am curious why they were removed in the
 past.  How does GNATS actually treat the subject line?
 
 > - Recognize an empty file as a not filled out PR, too.
 
 This is fine with me.
 > - Allow attaching files via -- followed by file names.
 
 This is fine with me.
 
 -- 
 Eitan Adler
 Source, Ports, Doc committer
 Bugmeister, Ports Security teams

From: Christoph Mallon <christoph.mallon@gmx.de>
To: Eitan Adler <eadler@freebsd.org>
Cc: bug-followup <bug-followup@freebsd.org>
Subject: Re: gnu/175985: [PATCH] Improve send-pr
Date: Sat, 16 Feb 2013 08:04:16 +0100

 On 15.02.2013 19:25, Eitan Adler wrote:
 > On 9 February 2013 08:50, Christoph Mallon <christoph.mallon@gmx.de> wrote:
 > 
 > I have not yet looked at the code.
 > 
 >>> Description:
 >> - Do not delete lines starting with Subject:.
 >>   They are most probably part of a attached git patch.
 > 
 > This is probably fine, but I am curious why they were removed in the
 > past.  How does GNATS actually treat the subject line?
 
 There is no Subject line in the PR template presented to the user.
 After the user finishes filling out the PR template, send-pr adds a Subject line with a copy of the Synopsis.
 I guess, GNATS shows the Subject just like any other field.
 send-pr ensures, that Subject and Synopsis are the same (Have a look at some random PRs).
 
 >> - Recognize an empty file as a not filled out PR, too.
 > 
 > This is fine with me.
 >> - Allow attaching files via -- followed by file names.
 > 
 > This is fine with me.
 
 I also have another patch, which adds a dummy file after each file.
 GNATS does not recognize every other file.
 This works around the problem.
 The proper solution would be to correct the problem in GNATS.
 
 	Christoph
>Unformatted:
