Merge branch 'maint'
[gitweb.git] / contrib / hooks / post-receive-email
index d1bef9125bca0997e0e714b3f89e9c2df307d598..2aa9bb501c2768770d8aed5de93dda8afc29b427 100644 (file)
@@ -138,7 +138,15 @@ generate_email()
 
        # Check if we've got anyone to send to
        if [ -z "$recipients" ]; then
-               echo >&2 "*** hooks.recipients is not set so no email will be sent"
+               case "$refname_type" in
+                       "annotated tag")
+                               config_name="hooks.announcelist"
+                               ;;
+                       *)
+                               config_name="hooks.mailinglist"
+                               ;;
+               esac
+               echo >&2 "*** $config_name is not set so no email will be sent"
                echo >&2 "*** for $refname update $oldrev->$newrev"
                exit 0
        fi
@@ -177,7 +185,6 @@ generate_email_header()
        # --- Email (all stdout will be the email)
        # Generate header
        cat <<-EOF
-       From: $committer
        To: $recipients
        Subject: ${EMAILPREFIX}$projectdesc $refname_type, $short_refname, ${change_type}d. $describe
        X-Git-Refname: $refname
@@ -199,7 +206,7 @@ generate_email_footer()
 
 
        hooks/post-receive
-       -- 
+       --
        $projectdesc
        EOF
 }
@@ -324,7 +331,7 @@ generate_update_branch_email()
                echo "       via  $rev ($revtype)"
        done
 
-       if [ -z "$fastforward" ]; then
+       if [ "$fast_forward" ]; then
                echo "      from  $oldrev ($oldrev_type)"
        else
                #  1. Existing revisions were removed.  In this case newrev is a
@@ -571,6 +578,15 @@ generate_delete_general_email()
        echo $LOGEND
 }
 
+send_mail()
+{
+       if [ -n "$envelopesender" ]; then
+               /usr/sbin/sendmail -t -f "$envelopesender"
+       else
+               /usr/sbin/sendmail -t
+       fi
+}
+
 # ---------------------------- main()
 
 # --- Constants
@@ -607,13 +623,8 @@ if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
        # resend an email; they could redirect the output to sendmail themselves
        PAGER= generate_email $2 $3 $1
 else
-       if [ -n "$envelopesender" ]; then
-               envelopesender="-f '$envelopesender'"
-       fi
-
        while read oldrev newrev refname
        do
-               generate_email $oldrev $newrev $refname |
-               /usr/sbin/sendmail -t $envelopesender
+               generate_email $oldrev $newrev $refname | send_mail
        done
 fi