{"thread":{"id":"15588","subject":"Re: [TopGit RFC PATCH] tg mail: new command for mailing patches","startedAt":"2008-09-19T09:08:21Z","lastAt":"2008-09-19T10:23:55Z","messageCount":5,"participants":["Bert Wesarg","Kirill Smelkov"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"299061","messageId":"1221815301-25090-1-git-send-email-kirr@landau.phys.spbu.ru","threadId":"15588","inReplyTo":null,"subject":"[TopGit RFC PATCH] tg mail: new command for mailing patches","fromName":"Kirill Smelkov","fromEmail":"kirr@landau.phys.spbu.ru","sentAt":"2008-09-19T09:08:21Z","receivedAt":"2008-09-19T09:08:21Z","isPatch":true,"sender":{"key":"kirr@navytux.spb.ru","avatar":"https://gravatar.com/avatar/cf3445fdad1849941e17ab25bf1ee7c5ea1be2deb444be25ff5f36b0e50a985f?d=mp&s=160"},"body":"Petr, since you've asked for help on this, here you are:\n\n    $ tg mail [NAME]\n\na simple script to send one patch over email.\n\n\nAll it does is\n\n    - call `tg patch` for actual patch preparation\n    - extract email addresses from whom and where to send a mail\n    - boils down to `git send-email`\n\n\nIt is self-hosted -- this mail was send by me with\n\n    $ tg mail t/tg-mail\n\n\nP.S. I'm not a bash guy, please do not beat me too much...\n\nSigned-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>\n\n---\n .gitignore |    2 ++\n README     |   18 ++++++++++++++++++\n tg-mail.sh |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 73 insertions(+), 0 deletions(-)\n\ndiff --git a/.gitignore b/.gitignore\nindex aa39db4..df4a662 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -5,6 +5,8 @@ tg-delete\n tg-delete.txt\n tg-info\n tg-info.txt\n+tg-mail\n+tg-mail.txt\n tg-patch\n tg-patch.txt\n tg-summary\ndiff --git a/README b/README\nindex b99b036..1a001a6 100644\n--- a/README\n+++ b/README\n@@ -272,6 +272,24 @@ tg patch\n \tTODO: tg patch -i to base at index instead of branch,\n \t\t-w for working tree\n \n+tg mail\n+~~~~~~~\n+\tSend a patch from the current or specified topic branch as\n+\temail.\n+\n+\tTakes the patch given on the command line and emails it out.\n+\tDestination addresses such as To, Cc and Bcc are taken from the\n+\tpatch header.\n+\n+\tSince it actually boils down to `git send-email` please refer to\n+\tit's documentation for details on how to setup email for git.\n+\n+\n+\tTODO: tg mail patchfile  to mail an already exported patch\n+\tTODO: mailing patch series\n+\tTODO: specifying additional options and addresses on command\n+\t      line\n+\n tg remote\n ~~~~~~~~~\n \tRegister given remote as TopGit-controlled. This will create\ndiff --git a/tg-mail.sh b/tg-mail.sh\nnew file mode 100644\nindex 0000000..f3abd2c\n--- /dev/null\n+++ b/tg-mail.sh\n@@ -0,0 +1,53 @@\n+#!/bin/sh\n+# TopGit - A different patch queue manager\n+# GPLv2\n+\n+name=\n+\n+\n+## Parse options\n+\n+while [ -n \"$1\" ]; do\n+\targ=\"$1\"; shift\n+\tcase \"$arg\" in\n+\t-*)\n+\t\techo \"Usage: tg [...] mail [NAME]\" >&2\n+\t\texit 1;;\n+\t*)\n+\t\t[ -z \"$name\" ] || die \"name already specified ($name)\"\n+\t\tname=\"$arg\";;\n+\tesac\n+done\n+\n+# TODO refactor me into something common?\n+[ -n \"$name\" ] || name=\"$(git symbolic-ref HEAD | sed 's#^refs/heads/##')\"\n+base_rev=\"$(git rev-parse --short --verify \"refs/top-bases/$name\" 2>/dev/null)\" ||\n+\tdie \"not a TopGit-controlled branch\"\n+\n+\n+patchfile=\"$(mktemp -t tg-mail.XXXXXX)\"\n+\n+$tg patch $name >\"$patchfile\"\n+\n+hlines=$(grep -n -m 1 '^---' \"$patchfile\" | sed 's/:---//')\n+header=$(head -$(($hlines - 1)) \"$patchfile\")\n+\n+\n+\n+from=\"$(echo \"$header\" | grep '^From:' | sed 's/From:\\s*//')\"\n+to=\"$(echo \"$header\" | grep '^To:' | sed 's/To:\\s*//')\"\n+\n+\n+# XXX I can't get quoting right without arrays\n+[ -n \"$from\" ] && from=(--from \"$from\")\n+[ -n \"$to\"   ] && to=(--to \"$to\") # FIXME there could be multimple To\n+\n+people=()\n+[ -n \"$from\" ] && people=(\"${people[@]}\" \"${from[@]}\")\n+[ -n \"$to\" ]   && people=(\"${people[@]}\" \"${to[@]}\")\n+\n+\n+# NOTE git-send-email handles cc itself\n+git send-email \"${people[@]}\" \"$patchfile\"\n+\n+rm \"$patchfile\"\n-- \ntg: (6b5d0b8..) t/tg-mail (depends on: kirr)\n"},{"id":"91101","messageId":"36ca99e90809190252q45f01eb2xd02b62b88f0cf3a9@mail.gmail.com","threadId":"15588","inReplyTo":"1221815301-25090-1-git-send-email-kirr@landau.phys.spbu.ru","subject":"Re: [TopGit RFC PATCH] tg mail: new command for mailing patches","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2008-09-19T09:52:03Z","receivedAt":"2008-09-19T09:52:03Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Fri, Sep 19, 2008 at 11:08, Kirill Smelkov <kirr@landau.phys.spbu.ru> wrote:\n> Petr, since you've asked for help on this, here you are:\n>\n>    $ tg mail [NAME]\n>\n> a simple script to send one patch over email.\n>\n>\n> All it does is\n>\n>    - call `tg patch` for actual patch preparation\n>    - extract email addresses from whom and where to send a mail\nThat shouldn't be needed. git send-email parses Cc: headers and the\nTo: comes from 'git config topgit.to', so you can re-use this.\n\nBert\n"},{"id":"91103","messageId":"20080919100441.GF4423@roro3","threadId":"15588","inReplyTo":"36ca99e90809190252q45f01eb2xd02b62b88f0cf3a9@mail.gmail.com","subject":"Re: [TopGit RFC PATCH] tg mail: new command for mailing patches","fromName":"Kirill Smelkov","fromEmail":"kirr@landau.phys.spbu.ru","sentAt":"2008-09-19T10:04:41Z","receivedAt":"2008-09-19T10:04:41Z","isPatch":true,"sender":{"key":"kirr@navytux.spb.ru","avatar":"https://gravatar.com/avatar/cf3445fdad1849941e17ab25bf1ee7c5ea1be2deb444be25ff5f36b0e50a985f?d=mp&s=160"},"body":"On Fri, Sep 19, 2008 at 11:52:03AM +0200, Bert Wesarg wrote:\n> On Fri, Sep 19, 2008 at 11:08, Kirill Smelkov <kirr@landau.phys.spbu.ru> wrote:\n> > Petr, since you've asked for help on this, here you are:\n> >\n> >    $ tg mail [NAME]\n> >\n> > a simple script to send one patch over email.\n> >\n> >\n> > All it does is\n> >\n> >    - call `tg patch` for actual patch preparation\n> >    - extract email addresses from whom and where to send a mail\n> That shouldn't be needed. git send-email parses Cc: headers and the\n\nExactly for this reason I do not extract Cc. And git send-mail does not\nextract From: -- it just asks to confirm From is GIT_COMMITTER_IDENT,\nand there is no option to stop it doing so except providing explicit\n--from <someone> (maybe i'm missing something?).\n\n> To: comes from 'git config topgit.to', so you can re-use this.\n\nYes, it comes directly to .topmsg when `tg create` is done, so I thought\nthe main source of information is the patch itself -- users may want to\nedit that To: by hand or add another To: lines.\n\nand what If a patch is already exported as a file, and I want to\nsend/resend it upstream right from that file?\n\nWe may want to look for topgit.to too though.\n\n-- \n    Всего хорошего, Кирилл.\n"},{"id":"91105","messageId":"36ca99e90809190320l4765e50eqe38bf1d2672cfcca@mail.gmail.com","threadId":"15588","inReplyTo":"20080919100441.GF4423@roro3","subject":"Re: [TopGit RFC PATCH] tg mail: new command for mailing patches","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2008-09-19T10:20:49Z","receivedAt":"2008-09-19T10:20:49Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Fri, Sep 19, 2008 at 12:04, Kirill Smelkov <kirr@landau.phys.spbu.ru> wrote:\n> On Fri, Sep 19, 2008 at 11:52:03AM +0200, Bert Wesarg wrote:\n>> On Fri, Sep 19, 2008 at 11:08, Kirill Smelkov <kirr@landau.phys.spbu.ru> wrote:\n>> > Petr, since you've asked for help on this, here you are:\n>> >\n>> >    $ tg mail [NAME]\n>> >\n>> > a simple script to send one patch over email.\n>> >\n>> >\n>> > All it does is\n>> >\n>> >    - call `tg patch` for actual patch preparation\n>> >    - extract email addresses from whom and where to send a mail\n>> That shouldn't be needed. git send-email parses Cc: headers and the\n>\n> Exactly for this reason I do not extract Cc. And git send-mail does not\n> extract From: -- it just asks to confirm From is GIT_COMMITTER_IDENT,\n> and there is no option to stop it doing so except providing explicit\n> --from <someone> (maybe i'm missing something?).\nAhh, my fault, I should take a break, sorry for the noise.\n\n>\n>> To: comes from 'git config topgit.to', so you can re-use this.\n>\n> Yes, it comes directly to .topmsg when `tg create` is done, so I thought\n> the main source of information is the patch itself -- users may want to\n> edit that To: by hand or add another To: lines.\nYeah, my fault, I noticed this too, its just a template. better to\nextract it from the patch.\n\n>\n> and what If a patch is already exported as a file, and I want to\n> send/resend it upstream right from that file?\n>\n> We may want to look for topgit.to too though.\n>\n> --\n>    Всего хорошего, Кирилл.\n>\n"},{"id":"91106","messageId":"20080919102355.GG4423@roro3","threadId":"15588","inReplyTo":"36ca99e90809190320l4765e50eqe38bf1d2672cfcca@mail.gmail.com","subject":"Re: [TopGit RFC PATCH] tg mail: new command for mailing patches","fromName":"Kirill Smelkov","fromEmail":"kirr@landau.phys.spbu.ru","sentAt":"2008-09-19T10:23:55Z","receivedAt":"2008-09-19T10:23:55Z","isPatch":true,"sender":{"key":"kirr@navytux.spb.ru","avatar":"https://gravatar.com/avatar/cf3445fdad1849941e17ab25bf1ee7c5ea1be2deb444be25ff5f36b0e50a985f?d=mp&s=160"},"body":"On Fri, Sep 19, 2008 at 12:20:49PM +0200, Bert Wesarg wrote:\n> On Fri, Sep 19, 2008 at 12:04, Kirill Smelkov <kirr@landau.phys.spbu.ru> wrote:\n> > On Fri, Sep 19, 2008 at 11:52:03AM +0200, Bert Wesarg wrote:\n> >> On Fri, Sep 19, 2008 at 11:08, Kirill Smelkov <kirr@landau.phys.spbu.ru> wrote:\n> >> > Petr, since you've asked for help on this, here you are:\n> >> >\n> >> >    $ tg mail [NAME]\n> >> >\n> >> > a simple script to send one patch over email.\n> >> >\n> >> >\n> >> > All it does is\n> >> >\n> >> >    - call `tg patch` for actual patch preparation\n> >> >    - extract email addresses from whom and where to send a mail\n> >> That shouldn't be needed. git send-email parses Cc: headers and the\n> >\n> > Exactly for this reason I do not extract Cc. And git send-mail does not\n> > extract From: -- it just asks to confirm From is GIT_COMMITTER_IDENT,\n> > and there is no option to stop it doing so except providing explicit\n> > --from <someone> (maybe i'm missing something?).\n> Ahh, my fault, I should take a break, sorry for the noise.\n\nNo problem, your \"noise\" is welcome :)\n\n-- \n    Всего хорошего, Кирилл.\n"}]}