Patchwork [1/1] send-pull-request: Fetch TO email address from git config if specified

login
register
mail settings
Submitter Khem Raj
Date March 12, 2011, 3:12 p.m.
Message ID <9d1bcc0f0467186a24ddd8acd4bd7fbc1ae5ebea.1299942641.git.raj.khem@gmail.com>
Download mbox | patch
Permalink /patch/1331/
State New, archived
Headers show

Comments

Khem Raj - March 12, 2011, 3:12 p.m.
Usually people using git send-email has git config sendmail.to
configured to the usual mailing list or person so we harness that
here.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 scripts/send-pull-request |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)
Darren Hart - March 14, 2011, 10:09 p.m.
Hi Khem,

On 03/12/2011 07:12 AM, Khem Raj wrote:
> Usually people using git send-email has git config sendmail.to
> configured to the usual mailing list or person so we harness that
> here.

OK, good idea, couple concerns below.

>
> Signed-off-by: Khem Raj<raj.khem@gmail.com>
> ---
>   scripts/send-pull-request |   21 +++++++++++++++------
>   1 files changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/scripts/send-pull-request b/scripts/send-pull-request
> index 7f51a1b..c5dc9a9 100755
> --- a/scripts/send-pull-request
> +++ b/scripts/send-pull-request
> @@ -109,15 +109,17 @@ if [ $AUTO -eq 1 ]; then
>       harvest_recipients CC "^.*-[Bb][Yy]: *"
>   fi
>
> -if [ -z "$TO" ]&&  [ -z "$CC" ]; then
> -    echo "ERROR: you have not specified any recipients."
> -    usage
> -    exit 1
> -fi
> -
>   case "$PULL_MTA" in
>       git)
>           FROM="$(git config sendemail.from)"
> +	AUTO_TO="$(git config sendemail.to)"
> +	if [ ! -e "$AUTO_TO" ]; then

-e tests for file existence...

> +	    if [ ! -e $TO ]; then

Here too, and please quote all shell variables.

I think you want -n:

if [ -n "$AUTO_TO" ]; then
	if [ -n "$TO" ]; then

Thanks,

Darren

> +		TO="$TO,$AUTO_TO"
> +	    else
> +		TO="$AUTO_TO"
> +	    fi
> +	fi
>           ;;
>       sendmail)
>           if [ -z "$FROM" ]; then
> @@ -131,6 +133,13 @@ case "$PULL_MTA" in
>           ;;
>   esac
>
> +if [ -z "$TO" ]&&  [ -z "$CC" ]; then
> +    echo "ERROR: you have not specified any recipients."
> +    usage
> +    exit 1
> +fi
> +
> +
>   # Generate report for the user and require confirmation before sending
>   cat<<EOM
>   The following patches:

Patch

diff --git a/scripts/send-pull-request b/scripts/send-pull-request
index 7f51a1b..c5dc9a9 100755
--- a/scripts/send-pull-request
+++ b/scripts/send-pull-request
@@ -109,15 +109,17 @@  if [ $AUTO -eq 1 ]; then
     harvest_recipients CC "^.*-[Bb][Yy]: *"
 fi
 
-if [ -z "$TO" ] && [ -z "$CC" ]; then
-    echo "ERROR: you have not specified any recipients."
-    usage
-    exit 1
-fi
-
 case "$PULL_MTA" in
     git)
         FROM="$(git config sendemail.from)"
+	AUTO_TO="$(git config sendemail.to)"
+	if [ ! -e "$AUTO_TO" ]; then
+	    if [ ! -e $TO ]; then
+		TO="$TO,$AUTO_TO"
+	    else
+		TO="$AUTO_TO"
+	    fi
+	fi
         ;;
     sendmail)
         if [ -z "$FROM" ]; then
@@ -131,6 +133,13 @@  case "$PULL_MTA" in
         ;;
 esac
 
+if [ -z "$TO" ] && [ -z "$CC" ]; then
+    echo "ERROR: you have not specified any recipients."
+    usage
+    exit 1
+fi
+
+
 # Generate report for the user and require confirmation before sending
 cat <<EOM
 The following patches: