{"thread":{"id":"14908","subject":"[TopGit PATCH v2] tg-create.sh: Support for multiple {to,cc,bcc} options","startedAt":"2008-08-09T18:48:56Z","lastAt":"2008-08-12T05:14:51Z","messageCount":3,"participants":["Bert Wesarg","Petr Baudis"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"86605","messageId":"1218307736-24891-1-git-send-email-bert.wesarg@googlemail.com","threadId":"14908","inReplyTo":null,"subject":"[TopGit PATCH v2] tg-create.sh: Support for multiple {to,cc,bcc} options","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2008-08-09T18:48:56Z","receivedAt":"2008-08-09T18:48:56Z","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\nNew in v2:\nPrint a RFC2822 compliant header.\n\nSigned-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n\n---\n tg-create.sh |   35 ++++++++++++++++++++++++++++++++---\n 1 files changed, 32 insertions(+), 3 deletions(-)\n\ndiff --git a/tg-create.sh b/tg-create.sh\nindex 6cce7ed..d7ee1d2 100644\n--- a/tg-create.sh\n+++ b/tg-create.sh\n@@ -100,13 +100,42 @@ git checkout -b \"$name\"\n echo \"$deps\" | sed 's/ /\\n/g' >\"$root_dir/.topdeps\"\n git add \"$root_dir/.topdeps\"\n \n+# Print a RFC2822 compliant header ($2) with values from the config option\n+# ($1 without the topgit. prefix)\n+get_multi_config()\n+{\n+\t# Do we need to escape it for awk double quotes?\n+\tprefix=\"$2\"\n+\tprefix_align=\"$(printf \"%*s  \" \"${#2}\" \"\")\"\n+\n+\tgit config --get-all topgit.$1 |\n+\t\tawk '\n+\t\t\tBEGIN {\n+\t\t\t\tline = \"\"\n+\t\t\t\tprefix = \"'\"$prefix\"': \"\n+\t\t\t}\n+\t\t\t\t{\n+\t\t\t\t\tif (line != \"\") {\n+\t\t\t\t\t\tprint prefix line \",\"\n+\t\t\t\t\t\tprefix = \"'\"$prefix_align\"'\"\n+\t\t\t\t\t}\n+\t\t\t\t\tline = $0\n+\t\t\t\t}\n+\t\t\tEND {\n+\t\t\t\tif (line != \"\") {\n+\t\t\t\t\tprint prefix line\n+\t\t\t\t}\n+\t\t\t}\n+\t\t'\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: (2e5b885..) t/support-for-multiple-to-cc-bcc-options (depends on: master)\n"},{"id":"86831","messageId":"20080811204723.GF10151@machine.or.cz","threadId":"14908","inReplyTo":"1218307736-24891-1-git-send-email-bert.wesarg@googlemail.com","subject":"Re: [TopGit PATCH v2] tg-create.sh: Support for multiple {to,cc,bcc} options","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2008-08-11T20:47:23Z","receivedAt":"2008-08-11T20:47:23Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"  Hi,\n\nOn Sat, Aug 09, 2008 at 08:48:56PM +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> New in v2:\n> Print a RFC2822 compliant header.\n> \n> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n\n  oops, I'm really sorry! I thought I already commented on this while\napparently, I forgot to.\n\n> ---\n>  tg-create.sh |   35 ++++++++++++++++++++++++++++++++---\n>  1 files changed, 32 insertions(+), 3 deletions(-)\n> \n> diff --git a/tg-create.sh b/tg-create.sh\n> index 6cce7ed..d7ee1d2 100644\n> --- a/tg-create.sh\n> +++ b/tg-create.sh\n> @@ -100,13 +100,42 @@ git checkout -b \"$name\"\n>  echo \"$deps\" | sed 's/ /\\n/g' >\"$root_dir/.topdeps\"\n>  git add \"$root_dir/.topdeps\"\n>  \n> +# Print a RFC2822 compliant header ($2) with values from the config option\n> +# ($1 without the topgit. prefix)\n> +get_multi_config()\n> +{\n> +\t# Do we need to escape it for awk double quotes?\n> +\tprefix=\"$2\"\n> +\tprefix_align=\"$(printf \"%*s  \" \"${#2}\" \"\")\"\n> +\n> +\tgit config --get-all topgit.$1 |\n> +\t\tawk '\n> +\t\t\tBEGIN {\n> +\t\t\t\tline = \"\"\n> +\t\t\t\tprefix = \"'\"$prefix\"': \"\n> +\t\t\t}\n> +\t\t\t\t{\n> +\t\t\t\t\tif (line != \"\") {\n> +\t\t\t\t\t\tprint prefix line \",\"\n> +\t\t\t\t\t\tprefix = \"'\"$prefix_align\"'\"\n> +\t\t\t\t\t}\n> +\t\t\t\t\tline = $0\n> +\t\t\t\t}\n> +\t\t\tEND {\n> +\t\t\t\tif (line != \"\") {\n> +\t\t\t\t\tprint prefix line\n> +\t\t\t\t}\n> +\t\t\t}\n> +\t\t'\n> +}\n> +\n\nI'm not too happy about this, for several reasons:\n\n\t(i) This code is so awfully complicated.\n\n\t(ii) It would be simpler to just prefix all the further lines\nwith a tab; wouldn't something like\n\n\t\tsed '2,$s/^/\\t/'\n\nactually work?\n\n\t(iii) This is troublesome because now header values can span\nmultiple lines. Until now, we were just blisfully ignorant about this\npossibility. At least tg export needs to be adjusted to account for this\nnow, and I fear dealing with this will be pretty annoying when\nprototyping new features.\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> -- \n> tg: (2e5b885..) t/support-for-multiple-to-cc-bcc-options (depends on: master)\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":"86899","messageId":"36ca99e90808112214hb8f01f0j30cff74e4f6c1ead@mail.gmail.com","threadId":"14908","inReplyTo":"20080811204723.GF10151@machine.or.cz","subject":"Re: [TopGit PATCH v2] tg-create.sh: Support for multiple {to,cc,bcc} options","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2008-08-12T05:14:51Z","receivedAt":"2008-08-12T05:14:51Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Mon, Aug 11, 2008 at 22:47, Petr Baudis <pasky@suse.cz> wrote:\n>  Hi,\n>\n> On Sat, Aug 09, 2008 at 08:48:56PM +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>> New in v2:\n>> Print a RFC2822 compliant header.\n>>\n>> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n>\n>  oops, I'm really sorry! I thought I already commented on this while\n> apparently, I forgot to.\n>\n>> ---\n>>  tg-create.sh |   35 ++++++++++++++++++++++++++++++++---\n>>  1 files changed, 32 insertions(+), 3 deletions(-)\n>>\n>> diff --git a/tg-create.sh b/tg-create.sh\n>> index 6cce7ed..d7ee1d2 100644\n>> --- a/tg-create.sh\n>> +++ b/tg-create.sh\n>> @@ -100,13 +100,42 @@ git checkout -b \"$name\"\n>>  echo \"$deps\" | sed 's/ /\\n/g' >\"$root_dir/.topdeps\"\n>>  git add \"$root_dir/.topdeps\"\n>>\n>> +# Print a RFC2822 compliant header ($2) with values from the config option\n>> +# ($1 without the topgit. prefix)\n>> +get_multi_config()\n>> +{\n>> +     # Do we need to escape it for awk double quotes?\n>> +     prefix=\"$2\"\n>> +     prefix_align=\"$(printf \"%*s  \" \"${#2}\" \"\")\"\n>> +\n>> +     git config --get-all topgit.$1 |\n>> +             awk '\n>> +                     BEGIN {\n>> +                             line = \"\"\n>> +                             prefix = \"'\"$prefix\"': \"\n>> +                     }\n>> +                             {\n>> +                                     if (line != \"\") {\n>> +                                             print prefix line \",\"\n>> +                                             prefix = \"'\"$prefix_align\"'\"\n>> +                                     }\n>> +                                     line = $0\n>> +                             }\n>> +                     END {\n>> +                             if (line != \"\") {\n>> +                                     print prefix line\n>> +                             }\n>> +                     }\n>> +             '\n>> +}\n>> +\n>\n> I'm not too happy about this, for several reasons:\n>\n>        (i) This code is so awfully complicated.\nFor my first awk script, its very clean and not that complicated. I think ;-)\n\n>\n>        (ii) It would be simpler to just prefix all the further lines\n> with a tab; wouldn't something like\n>\n>                sed '2,$s/^/\\t/'\nNo objections with this.\n\n>\n> actually work?\n>\n>        (iii) This is troublesome because now header values can span\n> multiple lines. Until now, we were just blisfully ignorant about this\n> possibility. At least tg export needs to be adjusted to account for this\n> now, and I fear dealing with this will be pretty annoying when\n> prototyping new features.\nThan we should go back to v1. As I asked in a previous line: \"But do\nwe generate a valid mail with tg patch, or just a patch file with some\nspecial looking lines?\"\n\nBert\n> --\n>                                Petr \"Pasky\" Baudis\n"}]}