git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [TopGit RFC PATCH] tg mail: new command for mailing patches
@ 2008-09-19  9:08 Kirill Smelkov
  2008-09-19  9:52 ` Bert Wesarg
  0 siblings, 1 reply; 5+ messages in thread
From: Kirill Smelkov @ 2008-09-19  9:08 UTC (permalink / raw)
  To: Petr Baudis, Petr Baudis; +Cc: Kirill Smelkov, Git Mailing List

Petr, since you've asked for help on this, here you are:

    $ tg mail [NAME]

a simple script to send one patch over email.


All it does is

    - call `tg patch` for actual patch preparation
    - extract email addresses from whom and where to send a mail
    - boils down to `git send-email`


It is self-hosted -- this mail was send by me with

    $ tg mail t/tg-mail


P.S. I'm not a bash guy, please do not beat me too much...

Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>

---
 .gitignore |    2 ++
 README     |   18 ++++++++++++++++++
 tg-mail.sh |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 73 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore
index aa39db4..df4a662 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,8 @@ tg-delete
 tg-delete.txt
 tg-info
 tg-info.txt
+tg-mail
+tg-mail.txt
 tg-patch
 tg-patch.txt
 tg-summary
diff --git a/README b/README
index b99b036..1a001a6 100644
--- a/README
+++ b/README
@@ -272,6 +272,24 @@ tg patch
 	TODO: tg patch -i to base at index instead of branch,
 		-w for working tree
 
+tg mail
+~~~~~~~
+	Send a patch from the current or specified topic branch as
+	email.
+
+	Takes the patch given on the command line and emails it out.
+	Destination addresses such as To, Cc and Bcc are taken from the
+	patch header.
+
+	Since it actually boils down to `git send-email` please refer to
+	it's documentation for details on how to setup email for git.
+
+
+	TODO: tg mail patchfile  to mail an already exported patch
+	TODO: mailing patch series
+	TODO: specifying additional options and addresses on command
+	      line
+
 tg remote
 ~~~~~~~~~
 	Register given remote as TopGit-controlled. This will create
diff --git a/tg-mail.sh b/tg-mail.sh
new file mode 100644
index 0000000..f3abd2c
--- /dev/null
+++ b/tg-mail.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+# TopGit - A different patch queue manager
+# GPLv2
+
+name=
+
+
+## Parse options
+
+while [ -n "$1" ]; do
+	arg="$1"; shift
+	case "$arg" in
+	-*)
+		echo "Usage: tg [...] mail [NAME]" >&2
+		exit 1;;
+	*)
+		[ -z "$name" ] || die "name already specified ($name)"
+		name="$arg";;
+	esac
+done
+
+# TODO refactor me into something common?
+[ -n "$name" ] || name="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')"
+base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
+	die "not a TopGit-controlled branch"
+
+
+patchfile="$(mktemp -t tg-mail.XXXXXX)"
+
+$tg patch $name >"$patchfile"
+
+hlines=$(grep -n -m 1 '^---' "$patchfile" | sed 's/:---//')
+header=$(head -$(($hlines - 1)) "$patchfile")
+
+
+
+from="$(echo "$header" | grep '^From:' | sed 's/From:\s*//')"
+to="$(echo "$header" | grep '^To:' | sed 's/To:\s*//')"
+
+
+# XXX I can't get quoting right without arrays
+[ -n "$from" ] && from=(--from "$from")
+[ -n "$to"   ] && to=(--to "$to") # FIXME there could be multimple To
+
+people=()
+[ -n "$from" ] && people=("${people[@]}" "${from[@]}")
+[ -n "$to" ]   && people=("${people[@]}" "${to[@]}")
+
+
+# NOTE git-send-email handles cc itself
+git send-email "${people[@]}" "$patchfile"
+
+rm "$patchfile"
-- 
tg: (6b5d0b8..) t/tg-mail (depends on: kirr)

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [TopGit RFC PATCH] tg mail: new command for mailing patches
  2008-09-19  9:08 [TopGit RFC PATCH] tg mail: new command for mailing patches Kirill Smelkov
@ 2008-09-19  9:52 ` Bert Wesarg
  2008-09-19 10:04   ` Kirill Smelkov
  0 siblings, 1 reply; 5+ messages in thread
From: Bert Wesarg @ 2008-09-19  9:52 UTC (permalink / raw)
  To: Kirill Smelkov; +Cc: Petr Baudis, Git Mailing List

On Fri, Sep 19, 2008 at 11:08, Kirill Smelkov <kirr@landau.phys.spbu.ru> wrote:
> Petr, since you've asked for help on this, here you are:
>
>    $ tg mail [NAME]
>
> a simple script to send one patch over email.
>
>
> All it does is
>
>    - call `tg patch` for actual patch preparation
>    - extract email addresses from whom and where to send a mail
That shouldn't be needed. git send-email parses Cc: headers and the
To: comes from 'git config topgit.to', so you can re-use this.

Bert

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [TopGit RFC PATCH] tg mail: new command for mailing patches
  2008-09-19  9:52 ` Bert Wesarg
@ 2008-09-19 10:04   ` Kirill Smelkov
  2008-09-19 10:20     ` Bert Wesarg
  0 siblings, 1 reply; 5+ messages in thread
From: Kirill Smelkov @ 2008-09-19 10:04 UTC (permalink / raw)
  To: Bert Wesarg; +Cc: Kirill Smelkov, Petr Baudis, Git Mailing List

On Fri, Sep 19, 2008 at 11:52:03AM +0200, Bert Wesarg wrote:
> On Fri, Sep 19, 2008 at 11:08, Kirill Smelkov <kirr@landau.phys.spbu.ru> wrote:
> > Petr, since you've asked for help on this, here you are:
> >
> >    $ tg mail [NAME]
> >
> > a simple script to send one patch over email.
> >
> >
> > All it does is
> >
> >    - call `tg patch` for actual patch preparation
> >    - extract email addresses from whom and where to send a mail
> That shouldn't be needed. git send-email parses Cc: headers and the

Exactly for this reason I do not extract Cc. And git send-mail does not
extract From: -- it just asks to confirm From is GIT_COMMITTER_IDENT,
and there is no option to stop it doing so except providing explicit
--from <someone> (maybe i'm missing something?).

> To: comes from 'git config topgit.to', so you can re-use this.

Yes, it comes directly to .topmsg when `tg create` is done, so I thought
the main source of information is the patch itself -- users may want to
edit that To: by hand or add another To: lines.

and what If a patch is already exported as a file, and I want to
send/resend it upstream right from that file?

We may want to look for topgit.to too though.

-- 
    Всего хорошего, Кирилл.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [TopGit RFC PATCH] tg mail: new command for mailing patches
  2008-09-19 10:04   ` Kirill Smelkov
@ 2008-09-19 10:20     ` Bert Wesarg
  2008-09-19 10:23       ` Kirill Smelkov
  0 siblings, 1 reply; 5+ messages in thread
From: Bert Wesarg @ 2008-09-19 10:20 UTC (permalink / raw)
  To: Kirill Smelkov; +Cc: Petr Baudis, Git Mailing List

On Fri, Sep 19, 2008 at 12:04, Kirill Smelkov <kirr@landau.phys.spbu.ru> wrote:
> On Fri, Sep 19, 2008 at 11:52:03AM +0200, Bert Wesarg wrote:
>> On Fri, Sep 19, 2008 at 11:08, Kirill Smelkov <kirr@landau.phys.spbu.ru> wrote:
>> > Petr, since you've asked for help on this, here you are:
>> >
>> >    $ tg mail [NAME]
>> >
>> > a simple script to send one patch over email.
>> >
>> >
>> > All it does is
>> >
>> >    - call `tg patch` for actual patch preparation
>> >    - extract email addresses from whom and where to send a mail
>> That shouldn't be needed. git send-email parses Cc: headers and the
>
> Exactly for this reason I do not extract Cc. And git send-mail does not
> extract From: -- it just asks to confirm From is GIT_COMMITTER_IDENT,
> and there is no option to stop it doing so except providing explicit
> --from <someone> (maybe i'm missing something?).
Ahh, my fault, I should take a break, sorry for the noise.

>
>> To: comes from 'git config topgit.to', so you can re-use this.
>
> Yes, it comes directly to .topmsg when `tg create` is done, so I thought
> the main source of information is the patch itself -- users may want to
> edit that To: by hand or add another To: lines.
Yeah, my fault, I noticed this too, its just a template. better to
extract it from the patch.

>
> and what If a patch is already exported as a file, and I want to
> send/resend it upstream right from that file?
>
> We may want to look for topgit.to too though.
>
> --
>    Всего хорошего, Кирилл.
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [TopGit RFC PATCH] tg mail: new command for mailing patches
  2008-09-19 10:20     ` Bert Wesarg
@ 2008-09-19 10:23       ` Kirill Smelkov
  0 siblings, 0 replies; 5+ messages in thread
From: Kirill Smelkov @ 2008-09-19 10:23 UTC (permalink / raw)
  To: Bert Wesarg; +Cc: Kirill Smelkov, Petr Baudis, Git Mailing List

On Fri, Sep 19, 2008 at 12:20:49PM +0200, Bert Wesarg wrote:
> On Fri, Sep 19, 2008 at 12:04, Kirill Smelkov <kirr@landau.phys.spbu.ru> wrote:
> > On Fri, Sep 19, 2008 at 11:52:03AM +0200, Bert Wesarg wrote:
> >> On Fri, Sep 19, 2008 at 11:08, Kirill Smelkov <kirr@landau.phys.spbu.ru> wrote:
> >> > Petr, since you've asked for help on this, here you are:
> >> >
> >> >    $ tg mail [NAME]
> >> >
> >> > a simple script to send one patch over email.
> >> >
> >> >
> >> > All it does is
> >> >
> >> >    - call `tg patch` for actual patch preparation
> >> >    - extract email addresses from whom and where to send a mail
> >> That shouldn't be needed. git send-email parses Cc: headers and the
> >
> > Exactly for this reason I do not extract Cc. And git send-mail does not
> > extract From: -- it just asks to confirm From is GIT_COMMITTER_IDENT,
> > and there is no option to stop it doing so except providing explicit
> > --from <someone> (maybe i'm missing something?).
> Ahh, my fault, I should take a break, sorry for the noise.

No problem, your "noise" is welcome :)

-- 
    Всего хорошего, Кирилл.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-09-19 10:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-19  9:08 [TopGit RFC PATCH] tg mail: new command for mailing patches Kirill Smelkov
2008-09-19  9:52 ` Bert Wesarg
2008-09-19 10:04   ` Kirill Smelkov
2008-09-19 10:20     ` Bert Wesarg
2008-09-19 10:23       ` Kirill Smelkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).