{"thread":{"id":"18716","subject":"git send-email prompting too much","startedAt":"2009-04-04T17:02:45Z","lastAt":"2009-04-05T09:45:21Z","messageCount":7,"participants":["Dan McGee","Bruce Stephens","Jay Soffian","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"110337","messageId":"449c10960904041002s22124b74k8440af216b1de9ee@mail.gmail.com","threadId":"18716","inReplyTo":null,"subject":"git send-email prompting too much","fromName":"Dan McGee","fromEmail":"dpmcgee@gmail.com","sentAt":"2009-04-04T17:02:45Z","receivedAt":"2009-04-04T17:02:45Z","isPatch":false,"sender":{"key":"dpmcgee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/265817?v=4"},"body":"I'm guessing this is related to commit\n6e1825186bd052fc1f77b7c8c9a31fbb9a67d90c but I haven't bisected yet.\nHaving to hit enter 10 times ad the Message-ID prompt seemed a bit odd\nto me. Has anyone else seen this behavior?\n\ndmcgee@galway ~/projects/git (working)\n$ git send-email 000*\n0001-git-repack-use-non-dashed-update-server-info.patch\n0002-pack-objects-report-actual-number-of-threads-to-be.patch\nWho should the emails appear to be from? [Dan McGee <dpmcgee@gmail.com>]\nEmails will be sent from: Dan McGee <dpmcgee@gmail.com>\nMessage-ID to be used as In-Reply-To for the first email?\nMessage-ID to be used as In-Reply-To for the first email?\nMessage-ID to be used as In-Reply-To for the first email?\nMessage-ID to be used as In-Reply-To for the first email?\nMessage-ID to be used as In-Reply-To for the first email?\nMessage-ID to be used as In-Reply-To for the first email?\nMessage-ID to be used as In-Reply-To for the first email?\nMessage-ID to be used as In-Reply-To for the first email?\nMessage-ID to be used as In-Reply-To for the first email?\nMessage-ID to be used as In-Reply-To for the first email?\n(mbox) Adding cc: Dan McGee <dpmcgee@gmail.com> from line 'From: Dan\nMcGee <dpmcgee@gmail.com>'\n(body) Adding cc: Dan McGee <dpmcgee@gmail.com> from line\n'Signed-off-by: Dan McGee <dpmcgee@gmail.com>'\n\nFrom: Dan McGee <dpmcgee@gmail.com>\nTo: git@vger.kernel.org\nCc: Dan McGee <dpmcgee@gmail.com>\nSubject: [PATCH 1/2] git-repack: use non-dashed update-server-info\nDate: Sat,  4 Apr 2009 11:59:55 -0500\nMessage-Id: <1238864396-8964-1-git-send-email-dpmcgee@gmail.com>\nX-Mailer: git-send-email 1.6.2.2.404.ge96f3.dirty\n\n    The Cc list above has been expanded by additional\n    addresses found in the patch commit message. By default\n    send-email prompts before sending whenever this occurs.\n    This behavior is controlled by the sendemail.confirm\n    configuration setting.\n\n    For additional information, run 'git send-email --help'.\n    To retain the current behavior, but squelch this message,\n    run 'git config --global sendemail.confirm auto'.\n\nSend this email? ([y]es|[n]o|[q]uit|[a]ll): a\nOK. Log says:\nSendmail: /usr/bin/msmtp -i git@vger.kernel.org dpmcgee@gmail.com\nFrom: Dan McGee <dpmcgee@gmail.com>\nTo: git@vger.kernel.org\nCc: Dan McGee <dpmcgee@gmail.com>\nSubject: [PATCH 1/2] git-repack: use non-dashed update-server-info\nDate: Sat,  4 Apr 2009 11:59:55 -0500\nMessage-Id: <1238864396-8964-1-git-send-email-dpmcgee@gmail.com>\nX-Mailer: git-send-email 1.6.2.2.404.ge96f3.dirty\n\nResult: OK\n(mbox) Adding cc: Dan McGee <dpmcgee@gmail.com> from line 'From: Dan\nMcGee <dpmcgee@gmail.com>'\n(body) Adding cc: Dan McGee <dpmcgee@gmail.com> from line\n'Signed-off-by: Dan McGee <dpmcgee@gmail.com>'\nOK. Log says:\nSendmail: /usr/bin/msmtp -i git@vger.kernel.org dpmcgee@gmail.com\nFrom: Dan McGee <dpmcgee@gmail.com>\nTo: git@vger.kernel.org\nCc: Dan McGee <dpmcgee@gmail.com>\nSubject: [PATCH 2/2] pack-objects: report actual number of threads to be used\nDate: Sat,  4 Apr 2009 11:59:56 -0500\nMessage-Id: <1238864396-8964-2-git-send-email-dpmcgee@gmail.com>\nX-Mailer: git-send-email 1.6.2.2.404.ge96f3.dirty\nIn-Reply-To: <1238864396-8964-1-git-send-email-dpmcgee@gmail.com>\nReferences: <1238864396-8964-1-git-send-email-dpmcgee@gmail.com>\n\nResult: OK\n"},{"id":"110338","messageId":"80hc148hso.fsf@tiny.isode.net","threadId":"18716","inReplyTo":"449c10960904041002s22124b74k8440af216b1de9ee@mail.gmail.com","subject":"Re: git send-email prompting too much","fromName":"Bruce Stephens","fromEmail":"bruce.stephens@isode.com","sentAt":"2009-04-04T17:12:07Z","receivedAt":"2009-04-04T17:12:07Z","isPatch":false,"sender":{"key":"bruce.stephens@isode.com","avatar":null},"body":"Dan McGee <dpmcgee@gmail.com> writes:\n\n> I'm guessing this is related to commit\n> 6e1825186bd052fc1f77b7c8c9a31fbb9a67d90c but I haven't bisected yet.\n> Having to hit enter 10 times ad the Message-ID prompt seemed a bit odd\n> to me. Has anyone else seen this behavior?\n\nYes.  Apparently one uses \\C-d now.\n\n[...]\n"},{"id":"110368","messageId":"76718490904041913s2c769022t92ca194263e29eb0@mail.gmail.com","threadId":"18716","inReplyTo":"80hc148hso.fsf@tiny.isode.net","subject":"Re: git send-email prompting too much","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-04-05T02:13:17Z","receivedAt":"2009-04-05T02:13:17Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Sat, Apr 4, 2009 at 1:12 PM, Bruce Stephens <bruce.stephens@isode.com> wrote:\n> Dan McGee <dpmcgee@gmail.com> writes:\n>\n>> I'm guessing this is related to commit\n>> 6e1825186bd052fc1f77b7c8c9a31fbb9a67d90c but I haven't bisected yet.\n>> Having to hit enter 10 times ad the Message-ID prompt seemed a bit odd\n>> to me. Has anyone else seen this behavior?\n>\n> Yes.  Apparently one uses \\C-d now.\n\nWait. Did hitting just enter work in the past? Because I tested this\nbefore I made this commit and at least on my machine, hitting enter\njust presented the prompt again. So I retained that behavior.\n\nI looked over the Term::ReadLine code and I don't see how just hitting\nreturn ever worked. But if you tell me it did, I believe that and I\ncan restore that behavior.\n\nOut of curiosity, what is your OS and version, perl version, and what\ndoes does perl -e 'use Term::ReadLine; print\n\"$Term::ReadLine::VERSION\\n\"' return?\n\nThanks,\n\nj.\n"},{"id":"110370","messageId":"76718490904041949w4b66d9ffkbf06299fbff22db9@mail.gmail.com","threadId":"18716","inReplyTo":"76718490904041913s2c769022t92ca194263e29eb0@mail.gmail.com","subject":"Re: git send-email prompting too much","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-04-05T02:49:14Z","receivedAt":"2009-04-05T02:49:14Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Sat, Apr 4, 2009 at 10:13 PM, Jay Soffian <jaysoffian@gmail.com> wrote:\n> Wait. Did hitting just enter work in the past? Because I tested this\n> before I made this commit and at least on my machine, hitting enter\n> just presented the prompt again. So I retained that behavior.\n\nArgh. I should read my own commit message. I claim:\n\n    2) \"Who should the emails be sent to?\". Previously this prompt passed a\n    second argument (\"\") to $term->readline() which was ignored. I believe\n    the intent was to allow the user to just hit return. Now the user\n    can do so, or type ctrl-d.\n\n    3) \"Message-ID to be used as In-Reply-To for the first email?\".\n    Previously this prompt passed a second argument (effectively undef) to\n    $term->readline() which was ignored. I believe the intent was the same\n    as for (2), to allow the user to just hit return. Now the user can do\n    so, or type ctrl-d.\n\nClearly I broke something. Will send a patch shortly. :-(\n\nj.\n"},{"id":"110374","messageId":"1238901801-47109-1-git-send-email-jaysoffian@gmail.com","threadId":"18716","inReplyTo":"449c10960904041002s22124b74k8440af216b1de9ee@mail.gmail.com","subject":"[PATCH] send-email: fix nasty bug in ask() function","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-04-05T03:23:21Z","receivedAt":"2009-04-05T03:23:21Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"Commit 6e18251 (send-email: refactor and ensure prompting doesn't loop\nforever) introduced an ask function, which unfortunately had a nasty\nbug. This caused it not to accept anything but the default reply to the\n\"Who should the emails appear to be from?\" prompt, and nothing but\nctrl-d to the \"Who should the emails be sent to?\" and \"Message-ID to be\nused as In-Reply-To for the first email?\" prompts.\n\nThis commit corrects the issues and adds a test to confirm the fix.\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\nOn Sat, Apr 4, 2009 at 1:02 PM, Dan McGee <dpmcgee@gmail.com> wrote:\n> I'm guessing this is related to commit\n> 6e1825186bd052fc1f77b7c8c9a31fbb9a67d90c but I haven't bisected yet.\n> Having to hit enter 10 times ad the Message-ID prompt seemed a bit odd\n> to me. Has anyone else seen this behavior?\n>\n> dmcgee@galway ~/projects/git (working)\n> $ git send-email 000*\n> 0001-git-repack-use-non-dashed-update-server-info.patch\n> 0002-pack-objects-report-actual-number-of-threads-to-be.patch\n> Who should the emails appear to be from? [Dan McGee <dpmcgee@gmail.com>]\n> Emails will be sent from: Dan McGee <dpmcgee@gmail.com>\n> Message-ID to be used as In-Reply-To for the first email?\n> Message-ID to be used as In-Reply-To for the first email?\n\nI really apologize for this breakage. This patch should fix the issue.\nI'm quite surprised that there wasn't already a test for the prompting,\nbut shame on me for not double-checking before refactoring.\n\nI'm also super confused why the issue is occuring. You can see from the\npatch below that by default the ask() function attempted to match the\nuser's input against the empty regex //, which should match anything:\n\n$ perl -e 'use strict; my $resp=\"something\"; my $re=\"\"; print \"true\\n\" if $resp =~ /$re/'\ntrue\n$ perl -e 'use strict; my $resp=\"\"; my $re=\"\"; print \"true\\n\" if $resp =~ /$re/'\ntrue\n\nAny yet while my demonstration above works as I expect, for some reason\nwhat is basically the same code (AFAICT) in send-email does not match. I\nthought I knew my perl fairly well, but maybe some perl guru can see\nwhat's going wrong.\n\n git-send-email.perl   |    4 ++--\n t/t9001-send-email.sh |   13 +++++++++++++\n 2 files changed, 15 insertions(+), 2 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 6bbdfec..172b53c 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -608,7 +608,7 @@ EOT\n \n sub ask {\n \tmy ($prompt, %arg) = @_;\n-\tmy $valid_re = $arg{valid_re} || \"\"; # \"\" matches anything\n+\tmy $valid_re = $arg{valid_re};\n \tmy $default = $arg{default};\n \tmy $resp;\n \tmy $i = 0;\n@@ -624,7 +624,7 @@ sub ask {\n \t\tif ($resp eq '' and defined $default) {\n \t\t\treturn $default;\n \t\t}\n-\t\tif ($resp =~ /$valid_re/) {\n+\t\tif (!defined $valid_re or $resp =~ /$valid_re/) {\n \t\t\treturn $resp;\n \t\t}\n \t}\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 192b97b..3c90c4f 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -130,6 +130,19 @@ test_expect_success 'Show all headers' '\n \ttest_cmp expected-show-all-headers actual-show-all-headers\n '\n \n+test_expect_success 'Prompting works' '\n+\tclean_fake_sendmail &&\n+\t(echo \"Example <from@example.com>\"\n+\t echo \"to@example.com\"\n+\t echo \"\"\n+\t) | GIT_SEND_EMAIL_NOTTY=1 git send-email \\\n+\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t\t$patches \\\n+\t\t2>errors &&\n+\t\tgrep \"^From: Example <from@example.com>$\" msgtxt1 &&\n+\t\tgrep \"^To: to@example.com$\" msgtxt1\n+'\n+\n z8=zzzzzzzz\n z64=$z8$z8$z8$z8$z8$z8$z8$z8\n z512=$z64$z64$z64$z64$z64$z64$z64$z64\n-- \n1.6.2.2.405.g6d8cc4\n"},{"id":"110375","messageId":"76718490904042031o5009a684xcf10aaff163e657@mail.gmail.com","threadId":"18716","inReplyTo":"1238901801-47109-1-git-send-email-jaysoffian@gmail.com","subject":"Re: [PATCH] send-email: fix nasty bug in ask() function","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-04-05T03:31:42Z","receivedAt":"2009-04-05T03:31:42Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"> I'm also super confused why the issue is occuring. You can see from the\n> patch below that by default the ask() function attempted to match the\n> user's input against the empty regex //, which should match anything:\n>\n> $ perl -e 'use strict; my $resp=\"something\"; my $re=\"\"; print \"true\\n\" if $resp =~ /$re/'\n> true\n> $ perl -e 'use strict; my $resp=\"\"; my $re=\"\"; print \"true\\n\" if $resp =~ /$re/'\n> true\n>\n> Any yet while my demonstration above works as I expect, for some reason\n> what is basically the same code (AFAICT) in send-email does not match. I\n> thought I knew my perl fairly well, but maybe some perl guru can see\n> what's going wrong.\n\nAh, found it in perlreref:\n\n   If 'pattern' is an empty string, the last successfully matched\n   regex is used.\n\nGrumble.\n\nj.\n"},{"id":"110393","messageId":"7v7i1zwi1a.fsf@gitster.siamese.dyndns.org","threadId":"18716","inReplyTo":"76718490904041949w4b66d9ffkbf06299fbff22db9@mail.gmail.com","subject":"Re: git send-email prompting too much","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-05T09:45:21Z","receivedAt":"2009-04-05T09:45:21Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.\n"}]}