2 # TopGit - A different patch queue manager
16 send_email_args
="$1"; shift;;
18 in_reply_to
="$1"; shift;;
20 echo "Usage: tg [...] mail [-s SEND_EMAIL_ARGS] [-r REFERENCE_MSGID] [NAME]" >&2
23 [ -z "$name" ] || die
"name already specified ($name)"
28 [ -n "$name" ] || name
="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')"
29 base_rev
="$(git rev-parse --short --verify "refs
/top-bases
/$name" 2>/dev/null)" ||
30 die
"not a TopGit-controlled branch"
32 if [ -n "$in_reply_to" ]; then
33 send_email_args
="$send_email_args --in-reply-to='$in_reply_to'"
37 patchfile
="$(mktemp -t tg-mail.XXXXXX)"
39 $tg patch "$name" >"$patchfile"
41 header
="$(sed -e '/^$/,$d' -e "s
,','\\\\'',g
" "$patchfile")"
45 from
="$(echo "$header" | grep '^From:' | sed 's/From:\s*//')"
46 to
="$(echo "$header" | grep '^To:' | sed 's/To:\s*//')"
50 [ -n "$from" ] && people
="$people --from '$from'"
51 # FIXME: there could be multimple To
52 [ -n "$to" ] && people
="$people --to '$to'"
54 # NOTE: git-send-email handles cc itself
55 eval git send-email
$send_email_args "$people" "$patchfile"