{"thread":{"id":"40802","subject":"[PATCH v2 2/2] completion: add support for completing email aliases","startedAt":"2015-11-15T20:22:19Z","lastAt":"2015-11-17T16:27:18Z","messageCount":14,"participants":["Jacob Keller","Eric Sunshine","Keller, Jacob E","SZEDER Gábor"],"isPatch":true,"patchVersion":2,"patchTotal":2},"messages":[{"id":"273348","messageId":"1447618940-27446-1-git-send-email-jacob.e.keller@intel.com","threadId":"40802","inReplyTo":null,"subject":"[PATCH v2 1/2] sendemail: teach git-send-email to list aliases","fromName":"Jacob Keller","fromEmail":"jacob.e.keller@intel.com","sentAt":"2015-11-15T20:22:19Z","receivedAt":"2015-11-15T20:22:19Z","isPatch":true,"sender":{"key":"jacob.e.keller@intel.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"From: Jacob Keller <jacob.keller@gmail.com>\n\nAdd an option \"list-aliases\" which changes the default behavior of\ngit-send-email. This mode will simply read the alias files configured by\nsendemail.aliasesfile and sendemail.aliasfiletype and print a list of\nall known aliases. The intended usecase for this option is the\nbash-completion script which will use it to autocomplete aliases on the\noptions which take addresses.\n\nSigned-off-by: Jacob Keller <jacob.keller@gmail.com>\n---\n Documentation/git-send-email.txt | 10 ++++++++++\n git-send-email.perl              | 11 +++++++++++\n 2 files changed, 21 insertions(+)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex b9134d234f53..481770d72e13 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -10,6 +10,7 @@ SYNOPSIS\n --------\n [verse]\n 'git send-email' [options] <file|directory|rev-list options>...\n+'git send-email' --list-aliases\n \n \n DESCRIPTION\n@@ -387,6 +388,15 @@ default to '--validate'.\n \tSend emails even if safety checks would prevent it.\n \n \n+Information\n+~~~~~~~~~~~\n+\n+--list-aliases::\n+\tInstead of the standard operation, list all aliases found in the\n+\tconfigured alias file(s), and then exit. See 'sendemail.aliasesfile'\n+\tfor more information about aliases.\n+\n+\n CONFIGURATION\n -------------\n \ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex e907e0eacf31..ee14894b172b 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -46,6 +46,7 @@ package main;\n sub usage {\n \tprint <<EOT;\n git send-email [options] <file | directory | rev-list options >\n+git send-email --list-aliases\n \n   Composing:\n     --from                  <str>  * Email From:\n@@ -101,6 +102,9 @@ git send-email [options] <file | directory | rev-list options >\n                                      `git format-patch` ones.\n     --force                        * Send even if safety checks would prevent it.\n \n+  Information:\n+    --list-aliases                 * read the aliases from configured alias files\n+\n EOT\n \texit(1);\n }\n@@ -180,6 +184,7 @@ my ($quiet, $dry_run) = (0, 0);\n my $format_patch;\n my $compose_filename;\n my $force = 0;\n+my $list_aliases = 0;\n \n # Handle interactive edition of files.\n my $multiedit;\n@@ -344,6 +349,7 @@ my $rc = GetOptions(\"h\" => \\$help,\n \t\t    \"force\" => \\$force,\n \t\t    \"xmailer!\" => \\$use_xmailer,\n \t\t    \"no-xmailer\" => sub {$use_xmailer = 0},\n+                    \"list-aliases\" => \\$list_aliases,\n \t );\n \n usage() if $help;\n@@ -551,6 +557,11 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {\n \t}\n }\n \n+if ($list_aliases) {\n+    print $_,\"\\n\" for (keys %aliases);\n+    exit(0);\n+}\n+\n # is_format_patch_arg($f) returns 0 if $f names a patch, or 1 if\n # $f is a revision list specification to be passed to format-patch.\n sub is_format_patch_arg {\n-- \n2.6.3.491.g3e3f6ce\n"},{"id":"273347","messageId":"1447618940-27446-2-git-send-email-jacob.e.keller@intel.com","threadId":"40802","inReplyTo":"1447618940-27446-1-git-send-email-jacob.e.keller@intel.com","subject":"[PATCH v2 2/2] completion: add support for completing email aliases","fromName":"Jacob Keller","fromEmail":"jacob.e.keller@intel.com","sentAt":"2015-11-15T20:22:20Z","receivedAt":"2015-11-15T20:22:20Z","isPatch":true,"sender":{"key":"jacob.e.keller@intel.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"From: Jacob Keller <jacob.keller@gmail.com>\n\nUsing the new --list-aliases option from git-send-email, add completion\nfor --to, --cc, and --bcc with the available configured aliases.\n\nSigned-off-by: Jacob Keller <jacob.keller@gmail.com>\n---\n\nNotes:\n    - v2\n    * reuse parsing from git-send-email via --list-aliases\n\n contrib/completion/git-completion.bash | 16 ++++++++++++++++\n 1 file changed, 16 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 482ca84b451b..fde246e2943e 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -10,6 +10,7 @@\n #    *) local and remote tag names\n #    *) .git/remotes file names\n #    *) git 'subcommands'\n+#    *) git email aliases for git-send-email\n #    *) tree paths within 'ref:path/to/file' expressions\n #    *) file paths within current working directory and index\n #    *) common --long-options\n@@ -1711,6 +1712,15 @@ __git_send_email_suppresscc_options=\"author self cc bodycc sob cccmd body all\"\n \n _git_send_email ()\n {\n+\tcase \"$prev\" in\n+\t--to|--cc|--bcc)\n+\t\t__gitcomp \"\n+\t\t$(git --git-dir=\"$(__gitdir)\" send-email --list-aliases 2>/dev/null)\n+\t\t\" \"\" \"\"\n+\t\treturn\n+\t\t;;\n+\tesac\n+\n \tcase \"$cur\" in\n \t--confirm=*)\n \t\t__gitcomp \"\n@@ -1735,6 +1745,12 @@ _git_send_email ()\n \t\t\t\" \"\" \"${cur##--thread=}\"\n \t\treturn\n \t\t;;\n+\t--to=*|--cc=*|--bcc=*)\n+\t\t__gitcomp \"\n+\t\t$(git --git-dir=\"$(__gitdir)\" send-email --list-aliases 2>/dev/null)\n+\t\t\" \"\" \"${cur#--*=}\"\n+\t\treturn\n+\t\t;;\n \t--*)\n \t\t__gitcomp \"--annotate --bcc --cc --cc-cmd --chain-reply-to\n \t\t\t--compose --confirm= --dry-run --envelope-sender\n-- \n2.6.3.491.g3e3f6ce\n"},{"id":"273389","messageId":"CAPig+cQ929oAZqQM+X68x3PVQ-opwdi3VzjcQTUsaCfVK3411g@mail.gmail.com","threadId":"40802","inReplyTo":"1447618940-27446-1-git-send-email-jacob.e.keller@intel.com","subject":"Re: [PATCH v2 1/2] sendemail: teach git-send-email to list aliases","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-11-16T23:30:16Z","receivedAt":"2015-11-16T23:30:16Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Nov 15, 2015 at 3:22 PM, Jacob Keller <jacob.e.keller@intel.com> wrote:\n> Add an option \"list-aliases\" which changes the default behavior of\n> git-send-email. This mode will simply read the alias files configured by\n> sendemail.aliasesfile and sendemail.aliasfiletype and print a list of\n> all known aliases. The intended usecase for this option is the\n> bash-completion script which will use it to autocomplete aliases on the\n> options which take addresses.\n\nAs this is primarily a plumbing option, I wonder if --dump-aliases\nmight be a more suitable name.\n\nAlso, is it possible that some consumer down the road might want\nricher output which includes the expansion of each alias? For\ninstance, it could emit the alias name as the first token on each line\nand the expansion as the remainder. Consumers interested in only the\nalias name would grab the first token on the line and ignore\neverything else.\n\n> Signed-off-by: Jacob Keller <jacob.keller@gmail.com>\n> ---\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> @@ -101,6 +102,9 @@ git send-email [options] <file | directory | rev-list options >\n>                                       `git format-patch` ones.\n>      --force                        * Send even if safety checks would prevent it.\n>\n> +  Information:\n> +    --list-aliases                 * read the aliases from configured alias files\n\nThis description is odd. It seems to imply that aliases will be loaded\n(and used) only if this option is given, and says nothing about its\nactual purpose of dumping the aliases.\n\nAlso, with one exception, all the other option descriptions are\ncapitalized. This probably ought to follow suit.\n\n> +if ($list_aliases) {\n> +    print $_,\"\\n\" for (keys %aliases);\n> +    exit(0);\n> +}\n\nNew test(s) seem to be missing.\n"},{"id":"273390","messageId":"CAPig+cST4iGdv0B91C_sWs85OMyw5c77ivjZ50xkbF+_uTr1YA@mail.gmail.com","threadId":"40802","inReplyTo":"1447618940-27446-2-git-send-email-jacob.e.keller@intel.com","subject":"Re: [PATCH v2 2/2] completion: add support for completing email aliases","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-11-16T23:33:10Z","receivedAt":"2015-11-16T23:33:10Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Nov 15, 2015 at 3:22 PM, Jacob Keller <jacob.e.keller@intel.com> wrote:\n> Using the new --list-aliases option from git-send-email, add completion\n> for --to, --cc, and --bcc with the available configured aliases.\n>\n> Signed-off-by: Jacob Keller <jacob.keller@gmail.com>\n> ---\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> @@ -1711,6 +1712,15 @@ __git_send_email_suppresscc_options=\"author self cc bodycc sob cccmd body all\"\n>\n>  _git_send_email ()\n>  {\n> +       case \"$prev\" in\n> +       --to|--cc|--bcc)\n\nWhat about --from, which also undergoes alias expansion?\n\n> +               __gitcomp \"\n> +               $(git --git-dir=\"$(__gitdir)\" send-email --list-aliases 2>/dev/null)\n> +               \" \"\" \"\"\n> +               return\n> +               ;;\n> +       esac\n> +\n>         case \"$cur\" in\n>         --confirm=*)\n>                 __gitcomp \"\n> @@ -1735,6 +1745,12 @@ _git_send_email ()\n>                         \" \"\" \"${cur##--thread=}\"\n>                 return\n>                 ;;\n> +       --to=*|--cc=*|--bcc=*)\n> +               __gitcomp \"\n> +               $(git --git-dir=\"$(__gitdir)\" send-email --list-aliases 2>/dev/null)\n> +               \" \"\" \"${cur#--*=}\"\n> +               return\n> +               ;;\n>         --*)\n>                 __gitcomp \"--annotate --bcc --cc --cc-cmd --chain-reply-to\n>                         --compose --confirm= --dry-run --envelope-sender\n> --\n> 2.6.3.491.g3e3f6ce\n"},{"id":"273391","messageId":"1447717227.23262.10.camel@intel.com","threadId":"40802","inReplyTo":"CAPig+cQ929oAZqQM+X68x3PVQ-opwdi3VzjcQTUsaCfVK3411g@mail.gmail.com","subject":"Re: [PATCH v2 1/2] sendemail: teach git-send-email to list aliases","fromName":"Keller, Jacob E","fromEmail":"jacob.e.keller@intel.com","sentAt":"2015-11-16T23:40:27Z","receivedAt":"2015-11-16T23:40:27Z","isPatch":true,"sender":{"key":"jacob.e.keller@intel.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Mon, 2015-11-16 at 18:30 -0500, Eric Sunshine wrote:\n> On Sun, Nov 15, 2015 at 3:22 PM, Jacob Keller <jacob.e.keller@intel.c\n> om> wrote:\n> > Add an option \"list-aliases\" which changes the default behavior of\n> > git-send-email. This mode will simply read the alias files\n> > configured by\n> > sendemail.aliasesfile and sendemail.aliasfiletype and print a list\n> > of\n> > all known aliases. The intended usecase for this option is the\n> > bash-completion script which will use it to autocomplete aliases on\n> > the\n> > options which take addresses.\n> \n> As this is primarily a plumbing option, I wonder if --dump-aliases\n> might be a more suitable name.\n> \n\nSure that would be reasonable.\n\n> Also, is it possible that some consumer down the road might want\n> richer output which includes the expansion of each alias? For\n> instance, it could emit the alias name as the first token on each\n> line\n> and the expansion as the remainder. Consumers interested in only the\n> alias name would grab the first token on the line and ignore\n> everything else.\n> \n\nMaybe? The problem with printing the full address is that it may not be\nquoted or similar, and it makes the bash completion require an extra\nparameter.. I am not sure how valuable the alias expansion would be for\nuse? The main concern I have is we'd need to use another process on top\nto extract only alias names.\n\n> > Signed-off-by: Jacob Keller <jacob.keller@gmail.com>\n> > ---\n> > diff --git a/git-send-email.perl b/git-send-email.perl\n> > @@ -101,6 +102,9 @@ git send-email [options] <file | directory |\n> > rev-list options >\n> >                                       `git format-patch` ones.\n> >      --force                        * Send even if safety checks\n> > would prevent it.\n> > \n> > +  Information:\n> > +    --list-aliases                 * read the aliases from\n> > configured alias files\n> \n> This description is odd. It seems to imply that aliases will be\n> loaded\n> (and used) only if this option is given, and says nothing about its\n> actual purpose of dumping the aliases.\n> \n\nI can re-word this.\n\n> Also, with one exception, all the other option descriptions are\n> capitalized. This probably ought to follow suit.\n> \n> > +if ($list_aliases) {\n> > +    print $_,\"\\n\" for (keys %aliases);\n> > +    exit(0);\n> > +}\n> \n> New test(s) seem to be missing.\n> \n\nI had removed the tests from the old version because they weren't\nnecessary anymore. New ones wouldn't hurt here either, though.. I'll\nwork on that.\n\nRegards,\nJake\n\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html"},{"id":"273392","messageId":"1447717246.23262.11.camel@intel.com","threadId":"40802","inReplyTo":"CAPig+cST4iGdv0B91C_sWs85OMyw5c77ivjZ50xkbF+_uTr1YA@mail.gmail.com","subject":"Re: [PATCH v2 2/2] completion: add support for completing email aliases","fromName":"Keller, Jacob E","fromEmail":"jacob.e.keller@intel.com","sentAt":"2015-11-16T23:40:46Z","receivedAt":"2015-11-16T23:40:46Z","isPatch":true,"sender":{"key":"jacob.e.keller@intel.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Mon, 2015-11-16 at 18:33 -0500, Eric Sunshine wrote:\n> On Sun, Nov 15, 2015 at 3:22 PM, Jacob Keller <jacob.e.keller@intel.c\n> om> wrote:\n> > Using the new --list-aliases option from git-send-email, add\n> > completion\n> > for --to, --cc, and --bcc with the available configured aliases.\n> > \n> > Signed-off-by: Jacob Keller <jacob.keller@gmail.com>\n> > ---\n> > diff --git a/contrib/completion/git-completion.bash\n> > b/contrib/completion/git-completion.bash\n> > @@ -1711,6 +1712,15 @@ __git_send_email_suppresscc_options=\"author\n> > self cc bodycc sob cccmd body all\"\n> > \n> >  _git_send_email ()\n> >  {\n> > +       case \"$prev\" in\n> > +       --to|--cc|--bcc)\n> \n> What about --from, which also undergoes alias expansion?\n> \n\nMakes sense, yep.\n\n"},{"id":"273393","messageId":"CAPig+cSMW2UmTzuyvBFpcpr4tF1FRdxHUPH4+wS3vrZSP9AzJA@mail.gmail.com","threadId":"40802","inReplyTo":"1447717227.23262.10.camel@intel.com","subject":"Re: [PATCH v2 1/2] sendemail: teach git-send-email to list aliases","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-11-16T23:50:55Z","receivedAt":"2015-11-16T23:50:55Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Nov 16, 2015 at 6:40 PM, Keller, Jacob E\n<jacob.e.keller@intel.com> wrote:\n> On Mon, 2015-11-16 at 18:30 -0500, Eric Sunshine wrote:\n>> Also, is it possible that some consumer down the road might want\n>> richer output which includes the expansion of each alias? For\n>> instance, it could emit the alias name as the first token on each\n>> line\n>> and the expansion as the remainder. Consumers interested in only the\n>> alias name would grab the first token on the line and ignore\n>> everything else.\n>\n> Maybe? The problem with printing the full address is that it may not be\n> quoted or similar, and it makes the bash completion require an extra\n> parameter.. I am not sure how valuable the alias expansion would be for\n> use? The main concern I have is we'd need to use another process on top\n> to extract only alias names.\n\nIt should be possible to extract the alias within the shell itself\nwithout a separate process. For instance:\n\n    read alias rest\n\nwill leave the first token in $alias and the remainder of the line in\n$rest, and it's all done within the shell process.\n\n>> New test(s) seem to be missing.\n>\n> I had removed the tests from the old version because they weren't\n> necessary anymore. New ones wouldn't hurt here either, though.. I'll\n> work on that.\n\nI'm not sure which tests you mean, but I was referring to tests to\nmake sure that git-send-email recognizes --list-aliases (or\n--dump-aliases if you switch to that) and that it produces the\nexpected output in the expected format.\n\nAlso, shouldn't --list-aliases (or --dump-aliases) be mutually\nexclusive with many of the other options? New tests would check such\nexclusivity as well.\n"},{"id":"273394","messageId":"CAPig+cR2t9w6x4YX6Fuc6sk6VMpMU=gfF4GaTz_3a47Px6mwPg@mail.gmail.com","threadId":"40802","inReplyTo":"CAPig+cSMW2UmTzuyvBFpcpr4tF1FRdxHUPH4+wS3vrZSP9AzJA@mail.gmail.com","subject":"Re: [PATCH v2 1/2] sendemail: teach git-send-email to list aliases","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-11-16T23:56:11Z","receivedAt":"2015-11-16T23:56:11Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Nov 16, 2015 at 6:50 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> Also, shouldn't --list-aliases (or --dump-aliases) be mutually\n> exclusive with many of the other options? New tests would check such\n> exclusivity as well.\n\nIn fact, while I agree with Szeder that it makes sense to re-use\nsend-email's aliases parsing functionality (and was going to suggest\nthe same, but he beat me to it), this new option is awfully orthogonal\nto the overall purpose of send-email, thus, doesn't really fit in well\nand almost cries out for a command of its own which would be used by\nsend-email and bash completion (though I'm not convinced that it's\nworth going that route for this one minor use-case).\n"},{"id":"273395","messageId":"1447718958.23262.15.camel@intel.com","threadId":"40802","inReplyTo":"CAPig+cR2t9w6x4YX6Fuc6sk6VMpMU=gfF4GaTz_3a47Px6mwPg@mail.gmail.com","subject":"Re: [PATCH v2 1/2] sendemail: teach git-send-email to list aliases","fromName":"Keller, Jacob E","fromEmail":"jacob.e.keller@intel.com","sentAt":"2015-11-17T00:09:18Z","receivedAt":"2015-11-17T00:09:18Z","isPatch":true,"sender":{"key":"jacob.e.keller@intel.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Mon, 2015-11-16 at 18:56 -0500, Eric Sunshine wrote:\n> On Mon, Nov 16, 2015 at 6:50 PM, Eric Sunshine <sunshine@sunshineco.c\n> om> wrote:\n> > Also, shouldn't --list-aliases (or --dump-aliases) be mutually\n> > exclusive with many of the other options? New tests would check\n> > such\n> > exclusivity as well.\n> \n> In fact, while I agree with Szeder that it makes sense to re-use\n> send-email's aliases parsing functionality (and was going to suggest\n> the same, but he beat me to it), this new option is awfully\n> orthogonal\n> to the overall purpose of send-email, thus, doesn't really fit in\n> well\n> and almost cries out for a command of its own which would be used by\n> send-email and bash completion (though I'm not convinced that it's\n> worth going that route for this one minor use-case).\n\nI don't think it's worth it at this point, because we'd have to extract\nout the alias parsing logic from send-email, which is not easy.\n\nThe option is pretty orthogonal to git-send-email, but until/unless\ngit-send-email is re-implemented in C, i don't really see value in\ntrying to separate the logic out... That is a lot more effort for very\nlittle gain.\n\nRegards,\nJake"},{"id":"273396","messageId":"1447719035.23262.17.camel@intel.com","threadId":"40802","inReplyTo":"CAPig+cSMW2UmTzuyvBFpcpr4tF1FRdxHUPH4+wS3vrZSP9AzJA@mail.gmail.com","subject":"Re: [PATCH v2 1/2] sendemail: teach git-send-email to list aliases","fromName":"Keller, Jacob E","fromEmail":"jacob.e.keller@intel.com","sentAt":"2015-11-17T00:10:35Z","receivedAt":"2015-11-17T00:10:35Z","isPatch":true,"sender":{"key":"jacob.e.keller@intel.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Mon, 2015-11-16 at 18:50 -0500, Eric Sunshine wrote:\n> It should be possible to extract the alias within the shell itself\n> without a separate process. For instance:\n> \n>     read alias rest\n> \n> will leave the first token in $alias and the remainder of the line in\n> $rest, and it's all done within the shell process.\n> \n\nI'll look into this :)\n\n> > > New test(s) seem to be missing.\n> > \n> > I had removed the tests from the old version because they weren't\n> > necessary anymore. New ones wouldn't hurt here either, though..\n> > I'll\n> > work on that.\n> \n> I'm not sure which tests you mean, but I was referring to tests to\n> make sure that git-send-email recognizes --list-aliases (or\n> --dump-aliases if you switch to that) and that it produces the\n> expected output in the expected format.\n> \n\nYep, I added some in my respin.\n\n> Also, shouldn't --list-aliases (or --dump-aliases) be mutually\n> exclusive with many of the other options? New tests would check such\n> exclusivity as well.\n\nI am at a loss for how to do that correctly in the perl. Help would be\nappreciated here.\n\nRegards,\nJak"},{"id":"273408","messageId":"20151117072049.GA25414@flurp.local","threadId":"40802","inReplyTo":"1447719035.23262.17.camel@intel.com","subject":"Re: [PATCH v2 1/2] sendemail: teach git-send-email to list aliases","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-11-17T07:20:49Z","receivedAt":"2015-11-17T07:20:49Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Nov 17, 2015 at 12:10:35AM +0000, Keller, Jacob E wrote:\n> On Mon, 2015-11-16 at 18:50 -0500, Eric Sunshine wrote:\n> > It should be possible to extract the alias within the shell itself\n> > without a separate process. For instance:\n> > \n> >     read alias rest\n> > \n> > will leave the first token in $alias and the remainder of the line in\n> > $rest, and it's all done within the shell process.\n> \n> I'll look into this :)\n\nMy reason for asking is concern about scripts possibly breaking if\nsomeone comes along and wants to \"fix\" --dump-aliases to also dump\nthe alias expansions. One possibility is just to punt today and say\nthat when that feature is needed in the future, then that someone can\nadd a --verbose option to complement --dump-aliases which would emit\nthe alias expansions as well. One nice thing about punting at this\npoint is that we don't (today) have to define a format for the output\nof the expansions. If we did want to think about it, one verbose,\nnon-ambiguous format would be to show the alias name on a line by\nitself, and each expansion value on a line by itself indented by a\ntab. For instance:\n\n    managers\n        bob\n\tfred\n    devs\n        jane\n\tjohn\n\n> > Also, shouldn't --list-aliases (or --dump-aliases) be mutually\n> > exclusive with many of the other options? New tests would check such\n> > exclusivity as well.\n> \n> I am at a loss for how to do that correctly in the perl. Help would be\n> appreciated here.\n\nSince git-send-email.perl already configures GetOpt::Long with the\n'pass_through' option, one possibility would be to invoke\nGetOptions() once for --list-aliases (or --dump-aliases), and then\nagain for the normal options. Doing so may be a bit ugly; on the\nother hand, it does indicate pretty clearly that --list-aliases is a\ndistinct \"mode\" of operation. On top of your patch, it might look\nsomething like this:\n\n--- 8< ---\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex ee14894..cada5ea 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -296,6 +296,12 @@ $SIG{INT}  = \\&signal_handler;\n \n my $help;\n my $rc = GetOptions(\"h\" => \\$help,\n+\t\t    \"list-aliases\" => \\$list_aliases);\n+usage() unless $rc;\n+die \"--list-aliases incompatible with other options\\n\"\n+\tif !$help and $list_aliases and @ARGV;\n+\n+$rc = GetOptions(\n \t\t    \"sender|from=s\" => \\$sender,\n                     \"in-reply-to=s\" => \\$initial_reply_to,\n \t\t    \"subject=s\" => \\$initial_subject,\n@@ -349,7 +355,6 @@ my $rc = GetOptions(\"h\" => \\$help,\n \t\t    \"force\" => \\$force,\n \t\t    \"xmailer!\" => \\$use_xmailer,\n \t\t    \"no-xmailer\" => sub {$use_xmailer = 0},\n-                    \"list-aliases\" => \\$list_aliases,\n \t );\n \n usage() if $help;\n--- 8< ---\n\nThough, it may be overkill for this minor use-case.\n"},{"id":"273412","messageId":"CA+P7+xo_ecs6iVK2byF1E7disNvKiKbacBUk4r2eSNWQtR+X-Q@mail.gmail.com","threadId":"40802","inReplyTo":"20151117072049.GA25414@flurp.local","subject":"Re: [PATCH v2 1/2] sendemail: teach git-send-email to list aliases","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2015-11-17T08:25:23Z","receivedAt":"2015-11-17T08:25:23Z","isPatch":true,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Mon, Nov 16, 2015 at 11:20 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> Since git-send-email.perl already configures GetOpt::Long with the\n> 'pass_through' option, one possibility would be to invoke\n> GetOptions() once for --list-aliases (or --dump-aliases), and then\n> again for the normal options. Doing so may be a bit ugly; on the\n> other hand, it does indicate pretty clearly that --list-aliases is a\n> distinct \"mode\" of operation. On top of your patch, it might look\n> something like this:\n>\n> --- 8< ---\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index ee14894..cada5ea 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -296,6 +296,12 @@ $SIG{INT}  = \\&signal_handler;\n>\n>  my $help;\n>  my $rc = GetOptions(\"h\" => \\$help,\n> +                   \"list-aliases\" => \\$list_aliases);\n> +usage() unless $rc;\n> +die \"--list-aliases incompatible with other options\\n\"\n> +       if !$help and $list_aliases and @ARGV;\n> +\n> +$rc = GetOptions(\n>                     \"sender|from=s\" => \\$sender,\n>                      \"in-reply-to=s\" => \\$initial_reply_to,\n>                     \"subject=s\" => \\$initial_subject,\n> @@ -349,7 +355,6 @@ my $rc = GetOptions(\"h\" => \\$help,\n>                     \"force\" => \\$force,\n>                     \"xmailer!\" => \\$use_xmailer,\n>                     \"no-xmailer\" => sub {$use_xmailer = 0},\n> -                    \"list-aliases\" => \\$list_aliases,\n>          );\n>\n>  usage() if $help;\n> --- 8< ---\n>\n> Though, it may be overkill for this minor use-case.\n\nI actually really like this approach. I will squash it in.\n\nRegards,\nJake\n"},{"id":"273430","messageId":"20151117132644.Horde.0sLxtm6pFWvFfyP7Yzukk0F@webmail.informatik.kit.edu","threadId":"40802","inReplyTo":"20151117072049.GA25414@flurp.local","subject":"Re: [PATCH v2 1/2] sendemail: teach git-send-email to list aliases","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2015-11-17T12:26:44Z","receivedAt":"2015-11-17T12:26:44Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"\nQuoting Eric Sunshine <sunshine@sunshineco.com>:\n\n> On Tue, Nov 17, 2015 at 12:10:35AM +0000, Keller, Jacob E wrote:\n>> On Mon, 2015-11-16 at 18:50 -0500, Eric Sunshine wrote:\n>> > It should be possible to extract the alias within the shell itself\n>> > without a separate process. For instance:\n>> >\n>> >     read alias rest\n>> >\n>> > will leave the first token in $alias and the remainder of the line in\n>> > $rest, and it's all done within the shell process.\n\nActually, putting this read in a while loop and feeding 'git  \nsend-email's output into that does fork() a subshell:\n\n   $ echo \"outside: $BASH_SUBSHELL\" |while read line ; do echo \"$line   \ninside: $BASH_SUBSHELL\" ; done\n   outside: 0  inside: 1\n\n>> I'll look into this :)\n>\n> My reason for asking is concern about scripts possibly breaking if\n> someone comes along and wants to \"fix\" --dump-aliases to also dump\n> the alias expansions. One possibility is just to punt today and say\n> that when that feature is needed in the future, then that someone can\n> add a --verbose option to complement --dump-aliases which would emit\n> the alias expansions as well. One nice thing about punting at this\n> point is that we don't (today) have to define a format for the output\n> of the expansions.\n\nI think we should cross the bridge when we get to it.\n\nHowever, we could still be nice to that brave soul who might want to  \ncross it in the future, and since at this point we are interested in  \nlisting only alias names, perhaps we should not appropriate the  \nbroader '--dump-alias' option, but go with the more specific  \n'--dump-alias-names' instead.\n\n\nGábor\n"},{"id":"273437","messageId":"CA+P7+xp5x+WhQ418aDEHdVv=GWvEpzsvOGbKpNMZ8ko5xcFr8w@mail.gmail.com","threadId":"40802","inReplyTo":"20151117132644.Horde.0sLxtm6pFWvFfyP7Yzukk0F@webmail.informatik.kit.edu","subject":"Re: [PATCH v2 1/2] sendemail: teach git-send-email to list aliases","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2015-11-17T16:27:18Z","receivedAt":"2015-11-17T16:27:18Z","isPatch":true,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Tue, Nov 17, 2015 at 4:26 AM, SZEDER Gábor <szeder@ira.uka.de> wrote:\n>\n> Quoting Eric Sunshine <sunshine@sunshineco.com>:\n>\n>> On Tue, Nov 17, 2015 at 12:10:35AM +0000, Keller, Jacob E wrote:\n>>>\n>>> On Mon, 2015-11-16 at 18:50 -0500, Eric Sunshine wrote:\n>>> > It should be possible to extract the alias within the shell itself\n>>> > without a separate process. For instance:\n>>> >\n>>> >     read alias rest\n>>> >\n>>> > will leave the first token in $alias and the remainder of the line in\n>>> > $rest, and it's all done within the shell process.\n>\n>\n> Actually, putting this read in a while loop and feeding 'git send-email's\n> output into that does fork() a subshell:\n>\n\nYea, I realized this. One extra subshell isn't a big deal but if we\ncan eliminate that it is good.\n\n>   $ echo \"outside: $BASH_SUBSHELL\" |while read line ; do echo \"$line\n> inside: $BASH_SUBSHELL\" ; done\n>   outside: 0  inside: 1\n>\n>>> I'll look into this :)\n>>\n>>\n>> My reason for asking is concern about scripts possibly breaking if\n>> someone comes along and wants to \"fix\" --dump-aliases to also dump\n>> the alias expansions. One possibility is just to punt today and say\n>> that when that feature is needed in the future, then that someone can\n>> add a --verbose option to complement --dump-aliases which would emit\n>> the alias expansions as well. One nice thing about punting at this\n>> point is that we don't (today) have to define a format for the output\n>> of the expansions.\n>\n>\n> I think we should cross the bridge when we get to it.\n\nAgreed.\n\n>\n> However, we could still be nice to that brave soul who might want to cross\n> it in the future, and since at this point we are interested in listing only\n> alias names, perhaps we should not appropriate the broader '--dump-alias'\n> option, but go with the more specific '--dump-alias-names' instead.\n>\n\nDisagree. I think the best approach for expanding --dump-aliases\noutput is turning it into a keyword-option argument such as:\n\n--dump-aliases=format\n\nand we can say \"historic reasons the format is always names only\",\nthen we can extend the support that way. I don't really think that\n\"--dump-alias-names\" is nice since then we'd need separate option if\nthis ever does change, and it's rather long if it never changes.\n\nI suspect it won't be something people need either.\n\nRegards,\nJake\n\n>\n> Gábor\n>\n"}]}