X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=topgit.git;a=blobdiff_plain;f=tg-mail.sh;h=17ce02c9f4a904724d802a825e42a22c2aa61a62;hp=4a684644a3977d0c2174e7aa7a8f7f5eeed97031;hb=7fc96160f2d30e75194eb3d8958a4f910a101735;hpb=7d934bdd48268f8134679185aab4b7bb5c5d2361 diff --git a/tg-mail.sh b/tg-mail.sh index 4a68464..17ce02c 100644 --- a/tg-mail.sh +++ b/tg-mail.sh @@ -3,6 +3,7 @@ # GPLv2 name= +head_from= send_email_args= in_reply_to= @@ -12,12 +13,15 @@ in_reply_to= while [ -n "$1" ]; do arg="$1"; shift case "$arg" in + -i|-w) + [ -z "$head_from" ] || die "-i and -w are mutually exclusive" + head_from="$arg";; -s) send_email_args="$1"; shift;; -r) in_reply_to="$1"; shift;; -*) - echo "Usage: tg [...] mail [-s SEND_EMAIL_ARGS] [-r REFERENCE_MSGID] [NAME]" >&2 + echo "Usage: tg [...] mail [-s SEND_EMAIL_ARGS] [-r REFERENCE_MSGID] [-i | -w] [NAME]" >&2 exit 1;; *) [ -z "$name" ] || die "name already specified ($name)" @@ -25,24 +29,22 @@ while [ -n "$1" ]; do esac done -[ -n "$name" ] || name="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')" +head="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')" +[ -n "$name" ] || name="$head" base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" || die "not a TopGit-controlled branch" -if ! git send-email --help >/dev/null 2>&1; then - die "git send-email command not available" -fi - if [ -n "$in_reply_to" ]; then - send_email_args="$send_email_args --in-reply-to=$in_reply_to" + send_email_args="$send_email_args --in-reply-to='$in_reply_to'" fi -patchfile="$(mktemp -t tg-mail.XXXXXX)" +patchfile="$(get_temp tg-mail)" -$tg patch "$name" >"$patchfile" +# let tg patch sort out whether $head_from makes sense for $name +$tg patch "$name" $head_from >"$patchfile" -header="$(sed -e '/^$/,$d' "$patchfile")" +header="$(sed -e '/^$/,$d' -e "s,','\\\\'',g" "$patchfile")" @@ -58,6 +60,4 @@ people= # NOTE: git-send-email handles cc itself eval git send-email $send_email_args "$people" "$patchfile" -rm "$patchfile" - # vim:noet