{"thread":{"id":"14878","subject":"[TopGit PATCH] tg-create.sh: Support for multiple {to,cc,bcc} options","startedAt":"2008-08-07T20:31:26Z","lastAt":"2008-08-09T10:49:35Z","messageCount":6,"participants":["Bert Wesarg","Petr Baudis","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"86436","messageId":"1218141086-16063-1-git-send-email-bert.wesarg@googlemail.com","threadId":"14878","inReplyTo":null,"subject":"[TopGit PATCH] tg-create.sh: Support for multiple {to,cc,bcc} options","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2008-08-07T20:31:26Z","receivedAt":"2008-08-07T20:31:26Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Git config supports multiple values for the same config key, so support it\nfor these TopGit config options, too.\n\nSigned-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n\n---\n tg-create.sh |   17 ++++++++++++++---\n 1 files changed, 14 insertions(+), 3 deletions(-)\n\ndiff --git a/tg-create.sh b/tg-create.sh\nindex 6cce7ed..d47959b 100644\n--- a/tg-create.sh\n+++ b/tg-create.sh\n@@ -100,13 +100,24 @@ git checkout -b \"$name\"\n echo \"$deps\" | sed 's/ /\\n/g' >\"$root_dir/.topdeps\"\n git add \"$root_dir/.topdeps\"\n \n+# Print each config value for a key ($1, without \"topgit.\" prefix)\n+# with the given prefix ($2)\n+get_multi_config()\n+{\n+\t# escape any / in prefix for sed\n+\tprefix=\"$(echo \"$2\" | sed -e 's/\\//\\\\\\\\\\//g')\"\n+\n+\tgit config --get-all topgit.$1 2>/dev/null |\n+\t\tsed -e \"s/^/$prefix /g\"\n+}\n+\n author=\"$(git var GIT_AUTHOR_IDENT)\"\n author_addr=\"${author%> *}>\"\n {\n \techo \"From: $author_addr\"\n-\t! header=\"$(git config topgit.to)\" || echo \"To: $header\"\n-\t! header=\"$(git config topgit.cc)\" || echo \"Cc: $header\"\n-\t! header=\"$(git config topgit.bcc)\" || echo \"Bcc: $header\"\n+\tget_multi_config to  \"To:\"\n+\tget_multi_config cc  \"Cc:\"\n+\tget_multi_config bcc \"Bcc:\"\n \t! subject_prefix=\"$(git config topgit.subjectprefix)\" || subject_prefix=\"$subject_prefix \"\n \techo \"Subject: [${subject_prefix}PATCH] $name\"\n \techo\n-- \ntg: (e311d15..) t/support-for-multiple-to-cc-bcc-options (depends on: master)\n"},{"id":"86565","messageId":"20080809003357.GQ10151@machine.or.cz","threadId":"14878","inReplyTo":"1218141086-16063-1-git-send-email-bert.wesarg@googlemail.com","subject":"Re: [TopGit PATCH] tg-create.sh: Support for multiple {to,cc,bcc} options","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2008-08-09T00:33:57Z","receivedAt":"2008-08-09T00:33:57Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"  Hi,\n\nOn Thu, Aug 07, 2008 at 10:31:26PM +0200, Bert Wesarg wrote:\n> Git config supports multiple values for the same config key, so support it\n> for these TopGit config options, too.\n> \n> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n> \n> ---\n>  tg-create.sh |   17 ++++++++++++++---\n>  1 files changed, 14 insertions(+), 3 deletions(-)\n> \n> diff --git a/tg-create.sh b/tg-create.sh\n> index 6cce7ed..d47959b 100644\n> --- a/tg-create.sh\n> +++ b/tg-create.sh\n> @@ -100,13 +100,24 @@ git checkout -b \"$name\"\n>  echo \"$deps\" | sed 's/ /\\n/g' >\"$root_dir/.topdeps\"\n>  git add \"$root_dir/.topdeps\"\n>  \n> +# Print each config value for a key ($1, without \"topgit.\" prefix)\n> +# with the given prefix ($2)\n> +get_multi_config()\n> +{\n> +\t# escape any / in prefix for sed\n> +\tprefix=\"$(echo \"$2\" | sed -e 's/\\//\\\\\\\\\\//g')\"\n\nMaybe use s### ? ;-)\n\n> +\n> +\tgit config --get-all topgit.$1 2>/dev/null |\n> +\t\tsed -e \"s/^/$prefix /g\"\n> +}\n\nWon't this return an error code and terminate the script in case no\noption is defined? And why the stderr redirect?\n\n>  author=\"$(git var GIT_AUTHOR_IDENT)\"\n>  author_addr=\"${author%> *}>\"\n>  {\n>  \techo \"From: $author_addr\"\n> -\t! header=\"$(git config topgit.to)\" || echo \"To: $header\"\n> -\t! header=\"$(git config topgit.cc)\" || echo \"Cc: $header\"\n> -\t! header=\"$(git config topgit.bcc)\" || echo \"Bcc: $header\"\n> +\tget_multi_config to  \"To:\"\n> +\tget_multi_config cc  \"Cc:\"\n> +\tget_multi_config bcc \"Bcc:\"\n>  \t! subject_prefix=\"$(git config topgit.subjectprefix)\" || subject_prefix=\"$subject_prefix \"\n>  \techo \"Subject: [${subject_prefix}PATCH] $name\"\n>  \techo\n\nOne trouble here is that I've seen mailers mess up when there is\nmultiple occurences of these headers, so it would be probably safer to\nconcatenate them all to single line, comma-separated.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nThe next generation of interesting software will be done\non the Macintosh, not the IBM PC.  -- Bill Gates\n"},{"id":"86572","messageId":"7vbq039dfa.fsf@gitster.siamese.dyndns.org","threadId":"14878","inReplyTo":"20080809003357.GQ10151@machine.or.cz","subject":"Re: [TopGit PATCH] tg-create.sh: Support for multiple {to,cc,bcc} options","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-09T01:37:13Z","receivedAt":"2008-08-09T01:37:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Petr Baudis <pasky@suse.cz> writes:\n\n>> +\tprefix=\"$(echo \"$2\" | sed -e 's/\\//\\\\\\\\\\//g')\"\n>\n> Maybe use s### ? ;-)\n\nPersonally I like '|' instead.  It's much less visually distracting than #.\n\n>> +\n>> +\tgit config --get-all topgit.$1 2>/dev/null |\n>> +\t\tsed -e \"s/^/$prefix /g\"\n>> +}\n>\n> Won't this return an error code and terminate the script in case no\n> option is defined?\n\nExit code from upstream of a pipe does not affect the exit code from the\npipeline, and sed does not exit non-zero just because there was no\nsubstitution.\n\n>> -\t! header=\"$(git config topgit.to)\" || echo \"To: $header\"\n>> -\t! header=\"$(git config topgit.cc)\" || echo \"Cc: $header\"\n>> -\t! header=\"$(git config topgit.bcc)\" || echo \"Bcc: $header\"\n>> +\tget_multi_config to  \"To:\"\n>> +\tget_multi_config cc  \"Cc:\"\n>> +\tget_multi_config bcc \"Bcc:\"\n>>  \t! subject_prefix=\"$(git config topgit.subjectprefix)\" || subject_prefix=\"$subject_prefix \"\n>>  \techo \"Subject: [${subject_prefix}PATCH] $name\"\n>>  \techo\n>\n> One trouble here is that I've seen mailers mess up when there is\n> multiple occurences of these headers, so it would be probably safer to\n> concatenate them all to single line, comma-separated.\n\nIt is not just \"I've seen mailers\"; RFC2822 wants you to have at most one\n(see the table on Page 20).\n"},{"id":"86577","messageId":"36ca99e90808090023r545bbef4ie6fbe6e5561f3a55@mail.gmail.com","threadId":"14878","inReplyTo":"7vbq039dfa.fsf@gitster.siamese.dyndns.org","subject":"Re: [TopGit PATCH] tg-create.sh: Support for multiple {to,cc,bcc} options","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2008-08-09T07:23:15Z","receivedAt":"2008-08-09T07:23:15Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Sat, Aug 9, 2008 at 03:37, Junio C Hamano <gitster@pobox.com> wrote:\n> Petr Baudis <pasky@suse.cz> writes:\n>\n>>> +    prefix=\"$(echo \"$2\" | sed -e 's/\\//\\\\\\\\\\//g')\"\n>>\n>> Maybe use s### ? ;-)\n>\n> Personally I like '|' instead.  It's much less visually distracting than #.\n  ^^^^^^^^^^ says it all ;-)\n>\n>>> +\n>>> +    git config --get-all topgit.$1 2>/dev/null |\n>>> +            sed -e \"s/^/$prefix /g\"\n>>> +}\n>>\n>> Won't this return an error code and terminate the script in case no\n>> option is defined?\nI tested it with none defined options: no error, no distracting empty\nlines, no error messages. so it worked here.\n\n>>> -    ! header=\"$(git config topgit.to)\" || echo \"To: $header\"\n>>> -    ! header=\"$(git config topgit.cc)\" || echo \"Cc: $header\"\n>>> -    ! header=\"$(git config topgit.bcc)\" || echo \"Bcc: $header\"\n>>> +    get_multi_config to  \"To:\"\n>>> +    get_multi_config cc  \"Cc:\"\n>>> +    get_multi_config bcc \"Bcc:\"\n>>>      ! subject_prefix=\"$(git config topgit.subjectprefix)\" || subject_prefix=\"$subject_prefix \"\n>>>      echo \"Subject: [${subject_prefix}PATCH] $name\"\n>>>      echo\n>>\n>> One trouble here is that I've seen mailers mess up when there is\n>> multiple occurences of these headers, so it would be probably safer to\n>> concatenate them all to single line, comma-separated.\n>\n> It is not just \"I've seen mailers\"; RFC2822 wants you to have at most one\n> (see the table on Page 20).\nBut do we generate a valid mail with tg patch, or just a patch file\nwith some special looking lines? Anyway, I thought about the comma\nseparated solution too, but git send-mail handles these multi lines\nwell. So I take the easy road.\n\nBert\n"},{"id":"86586","messageId":"20080809082701.GE32184@machine.or.cz","threadId":"14878","inReplyTo":"7vbq039dfa.fsf@gitster.siamese.dyndns.org","subject":"Re: [TopGit PATCH] tg-create.sh: Support for multiple {to,cc,bcc} options","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2008-08-09T08:27:01Z","receivedAt":"2008-08-09T08:27:01Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"On Fri, Aug 08, 2008 at 06:37:13PM -0700, Junio C Hamano wrote:\n> Petr Baudis <pasky@suse.cz> writes:\n> \n> >> +\tprefix=\"$(echo \"$2\" | sed -e 's/\\//\\\\\\\\\\//g')\"\n> >\n> > Maybe use s### ? ;-)\n> \n> Personally I like '|' instead.  It's much less visually distracting than #.\n\nI'm just used to '#' more, but either is fine for me.\n\n> >> +\n> >> +\tgit config --get-all topgit.$1 2>/dev/null |\n> >> +\t\tsed -e \"s/^/$prefix /g\"\n> >> +}\n> >\n> > Won't this return an error code and terminate the script in case no\n> > option is defined?\n> \n> Exit code from upstream of a pipe does not affect the exit code from the\n> pipeline, and sed does not exit non-zero just because there was no\n> substitution.\n\nOh, you're right - somehow I didn't quite absorb that pipe is used late\nat the night. ;-) I still don't understand the stderr redirect, though.\n\n\t\t\t\tPetr \"Pasky\" Baudis\n"},{"id":"86596","messageId":"36ca99e90808090349sf08fab5sa0a3194f8a68ead7@mail.gmail.com","threadId":"14878","inReplyTo":"20080809082701.GE32184@machine.or.cz","subject":"Re: [TopGit PATCH] tg-create.sh: Support for multiple {to,cc,bcc} options","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2008-08-09T10:49:35Z","receivedAt":"2008-08-09T10:49:35Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Sat, Aug 9, 2008 at 10:27, Petr Baudis <pasky@suse.cz> wrote:\n>> >> +\n>> >> +  git config --get-all topgit.$1 2>/dev/null |\n>> >> +          sed -e \"s/^/$prefix /g\"\n>> >> +}\n> I still don't understand the stderr redirect, though.\nJust precaution, I think. It seems unnecessary.\n\nBert\n>\n>                                Petr \"Pasky\" Baudis\n>\n"}]}