chiark / gitweb /
tg-mail: accept -i/-w
authorBert Wesarg <bert.wesarg@googlemail.com>
Sat, 9 Oct 2010 20:52:19 +0000 (22:52 +0200)
committerBert Wesarg <bert.wesarg@googlemail.com>
Mon, 8 Nov 2010 07:27:29 +0000 (08:27 +0100)
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
README
contrib/tg-completion.bash
tg-mail.sh

diff --git a/README b/README
index fa9d63f74dcb97bf3e4c4ca1a6470be9de0a9676..b9b93efa4e0d0d658406f519c6281b135df85920 100644 (file)
--- a/README
+++ b/README
@@ -323,6 +323,10 @@ tg mail
 
        to let `git send-email` ask for confirmation before sending any mail.
 
 
        to let `git send-email` ask for confirmation before sending any mail.
 
+       Options:
+         -i            base patch generation on index instead of branch
+         -w            base patch generation on working tree instead of branch
+
        TODO: 'tg mail patchfile' to mail an already exported patch
        TODO: mailing patch series
        TODO: specifying additional options and addresses on command
        TODO: 'tg mail patchfile' to mail an already exported patch
        TODO: mailing patch series
        TODO: specifying additional options and addresses on command
index eff85ee2b14034409e1a033886cfa40e2c0dd4c6..ddc7655fde13bacd68cc4191a0414839de0c620c 100755 (executable)
@@ -359,6 +359,14 @@ _tg_mail ()
        local cur="${COMP_WORDS[COMP_CWORD]}"
 
        case "$cur" in
        local cur="${COMP_WORDS[COMP_CWORD]}"
 
        case "$cur" in
+       -*)
+               __tgcomp "
+                       -i
+                       -w
+                       -s
+                       -r
+               "
+               ;;
        *)
                __tgcomp "$(__tg_topics)"
        esac
        *)
                __tgcomp "$(__tg_topics)"
        esac
index dd4a95a74ad9e47ed39dbff05f5f5d53993981e7..17ce02c9f4a904724d802a825e42a22c2aa61a62 100644 (file)
@@ -3,6 +3,7 @@
 # GPLv2
 
 name=
 # GPLv2
 
 name=
+head_from=
 send_email_args=
 in_reply_to=
 
 send_email_args=
 in_reply_to=
 
@@ -12,12 +13,15 @@ in_reply_to=
 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;;
        -r)
                in_reply_to="$1"; shift;;
        -*)
        -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)"
                exit 1;;
        *)
                [ -z "$name" ] || die "name already specified ($name)"
@@ -25,7 +29,8 @@ 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"
 
@@ -36,7 +41,8 @@ fi
 
 patchfile="$(get_temp tg-mail)"
 
 
 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' -e "s,','\\\\'',g" "$patchfile")"
 
 
 header="$(sed -e '/^$/,$d' -e "s,','\\\\'',g" "$patchfile")"