#!/bin/bash # # Copyright (C) 2009 David L. Cantrell Jr. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Does a batch send using git-format-patch and git-send-email. I like to # have an intro message with all patches sent as replies to the intro msg. # In a threaded mail reader, it would look like: # # Intro message about patches # [PATCH] patch 1 # [PATCH] patch 2 # [PATCH] patch 3 # .... # # By default, git-send-email sends each patch as a reply to the previous, so # you get a nasty stairstep thing and no intro text. It looks like this: # # [PATCH] patch 1 # [PATCH] patch 2 # [PATCH] patch 3 # .... # CWD="$(pwd)" PROG="$(basename ${0})" usage() { echo "Usage: ${PROG} [single patch]" echo echo "If you specify a single patch file after the recipient email address," echo "${PROG} will send just that patch. If you do not specify a" echo "single patch, ${PROG} will look for a _msg file and send" echo "that first with all *.patch files as replies to the _msg file." } dest="${1}" if [ -z "${dest}" ]; then usage exit 1 fi echo "${dest}" | grep -q '@' if [ $? -eq 1 ]; then usage exit 2 fi if [ ! -f "${CWD}/_msg" ]; then if [ -f "${2}" ]; then git send-email --no-chain-reply-to --quiet --to ${dest} ${2} else echo "Missing intro message, please run git-msg-template first." >&2 echo "Or call ${PROG} with a single patch to send." >&2 exit 3 fi else patches="$(ls -1 ${CWD}/*.patch 2>/dev/null)" if [ -z "${patches}" ]; then echo "No patches found, please run 'git format-patch'." >&2 exit 4 fi git send-email --no-chain-reply-to --quiet --to ${dest} _msg *.patch fi