chiark
/
gitweb
/
~ian
/
topgit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'i/build' into refs/top-bases/i/basis-merge
[topgit.git]
/
tg-mail.sh
diff --git
a/tg-mail.sh
b/tg-mail.sh
index fb686e945a457e08ed00e16a78f40792a2a99443..17ce02c9f4a904724d802a825e42a22c2aa61a62 100644
(file)
--- a/
tg-mail.sh
+++ b/
tg-mail.sh
@@
-3,7
+3,9
@@
# GPLv2
name=
# GPLv2
name=
+head_from=
send_email_args=
send_email_args=
+in_reply_to=
## Parse options
## Parse options
@@
-11,10
+13,15
@@
send_email_args=
while [ -n "$1" ]; do
arg="$1"; shift
case "$arg" in
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;;
-s)
send_email_args="$1"; shift;;
+ -r)
+ in_reply_to="$1"; shift;;
-*)
-*)
- echo "Usage: tg [...] mail [-s SEND_EMAIL_ARGS] [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)"
exit 1;;
*)
[ -z "$name" ] || die "name already specified ($name)"
@@
-22,16
+29,22
@@
while [ -n "$1" ]; do
esac
done
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"
base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
die "not a TopGit-controlled branch"
+if [ -n "$in_reply_to" ]; then
+ send_email_args="$send_email_args --in-reply-to='$in_reply_to'"
+fi
-patchfile="$(mktemp -t tg-mail.XXXXXX)"
-
$tg patch "$name" >"$patchfile
"
+
patchfile="$(get_temp tg-mail)
"
-header="$(sed -e '/^$/,$d' "$patchfile")"
+# let tg patch sort out whether $head_from makes sense for $name
+$tg patch "$name" $head_from >"$patchfile"
+
+header="$(sed -e '/^$/,$d' -e "s,','\\\\'',g" "$patchfile")"
@@
-39,14
+52,12
@@
from="$(echo "$header" | grep '^From:' | sed 's/From:\s*//')"
to="$(echo "$header" | grep '^To:' | sed 's/To:\s*//')"
to="$(echo "$header" | grep '^To:' | sed 's/To:\s*//')"
-# XXX: I can't get quoting right without arrays
-people=()
-[ -n "$from" ] && people=("${people[@]}" --from "$from")
+people=
+[ -n "$from" ] && people="$people --from '$from'"
# FIXME: there could be multimple To
# FIXME: there could be multimple To
-[ -n "$to" ] && people=("${people[@]}" --to "$to")
-
+[ -n "$to" ] && people="$people --to '$to'"
# NOTE: git-send-email handles cc itself
# NOTE: git-send-email handles cc itself
-
git send-email $send_email_args "${people[@]}
" "$patchfile"
+
eval git send-email $send_email_args "$people
" "$patchfile"
-rm "$patchfile"
+# vim:noet