2 # TopGit - A different patch queue manager
6 Usage: ${tgname:-tg} [...] mail [-s <send-email-args>] [-r <reference-msgid>] [-i | -w] [<name>]
8 -i use TopGit metadata from index instead of HEAD branch
9 -w use metadata from working directory instead of branch"
13 if [ "${1:-0}" != 0 ]; then
14 printf '%s\n' "$USAGE" >&2
16 printf '%s\n' "$USAGE"
34 [ -z "$head_from" ] || die
"-i and -w are mutually exclusive"
37 send_email_args
="$1"; shift;;
39 in_reply_to
="$1"; shift;;
43 [ -z "$name" ] || die
"name already specified ($name)"
48 v_verify_topgit_branch name
"${name:-HEAD}"
49 base_rev
="$(git rev-parse --short --verify "refs
/$topbases/$name^
0" -- 2>/dev/null)" ||
50 die
"not a TopGit-controlled branch"
52 if [ -n "$in_reply_to" ]; then
53 send_email_args
="$send_email_args --in-reply-to='$in_reply_to'"
57 patchfile
="$(get_temp tg-mail)"
59 [ -z "$head_from" ] || ensure_work_tree
61 # let tg patch sort out whether $head_from makes sense for $name
62 tg
patch "$name" $head_from >"$patchfile"
64 header
="$(sed -e '/^$/,$d' -e "s
,','\\\\'',g
" "$patchfile")"
67 from
="$(echol "$header" | grep '^From:' | sed 's/From:\s*//')"
68 to
="$(echol "$header" | grep '^To:' | sed 's/To:\s*//')"
72 [ -n "$from" ] && people
="$people --from '$from'"
73 # FIXME: there could be multiple To
74 [ -n "$to" ] && people
="$people --to '$to'"
76 # NOTE: git-send-email handles cc itself
77 eval git send-email
$send_email_args "$people" '"$patchfile"'