git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH RFC3.5 06/12] send-email: Cleanup and streamline the SMTP code in send_message

From
Michael Witten <mfwitten@gmail.com>
Date
Apr 20, 2009, 05:38 UTC
Message-ID
<b4087cc50904192238j744f353dtf5f6a616cada8cd8@mail.gmail.com>
In-Reply-To
<7vskk4nlrg.fsf@gitster.siamese.dyndns.org>
On Sun, Apr 19, 2009 at 20:42, Junio C Hamano <gitster@pobox.com> wrote:
Show 18 quoted lines
> Michael Witten <mfwitten@gmail.com> writes:
>
>> +                             die "Server does not support STARTTLS: " . $smtp->message . "\n"
>> +                                     unless $smtp->code == 220;
>
> ...
> But the following, which is equivalent to what you did, is inexcuable.
>
>        do this;
>        do that;
>        do something unusual
>                if some condition that rarely holds true;
>        do some other thing;
>
> When your eyes and brain are coasting over this segment of code, your
> thought process needs to stumble and hiccup at the statment that does
> something unusual, and then need to realize that it is qualified with a
> statement modifier that says "this is only for rare case".

I mostly agree, and I frequently consider[ed] exactly those points. However, there are 2 things that played a role in my decision:

    * For most conditional cases, I personally
      loathe curly braces around one statement.
    * The flow is actually:
            do this;
            do that;
            DIE "whisper some curses with the last breath"
                UNLESS some condition that holds mostly true;
            do some other thing;
      The "die" and thoughtful spacing should be pretty good clues.
      However, the "unless" can be strange to think with (at first);
      I figured Perlers would be happy with it.
In any case, I also like:
    condition and/or (do something);
or:
    condition and/or do something;

The only thing keeping me from using that more often is that I assume other people would be less comfortable with it and that it may introduce an unnecessary comparison of the return value of "do something"; also, it might make the line a little long, which some people get really angry about.

Show 8 quoted lines
> Written without statement modifier:
>
>        do this;
>        do that;
>        if (some consition that rarely holds true) {
>                do something unusual
>        }
>        do some other thing;

I just have a hard time stomaching those curly braces. I really wish perl didn't enforce them when there's only one statement. Also, I would use some whitespace:

    do this;
    do that;
    if (some consition that rarely holds true) {
        do something unusual
    }
    do some other thing;
Show 9 quoted lines
>> +             $smtp->mail($raw_from)               and
>> +             $smtp->to(@recipients)               and
>> +             $smtp->data                          and
>> +             $smtp->datasend("$header\n$message") and
>> +             $smtp->dataend                       or
>> +
>> +             die "Failed to send '$subject': " . $smtp->message . "\n";
>
> These do make things more pleasant to read.
Thanks!
P.S.

Sorry if the formatting of this email is bad; I'm in the middle of a large move between systems, and currently I'm stuck with gmail's webmail, which insists on reformatting my text and refusing to render in fixed-width font (though I bet I could hack firefox's css to get that one working.... hmmm.....), and firefox doesn't make it easy to input tabs.

So, I've actually been writing and sending some emails with a combination of:
    * vim
    * date +'%a, %e %b %Y %T %z'
    * uuidgen (though I've found gmail makes a Message-ID for me)
    * cat path/to/email.txt | perl -pe 's/\n/\r\n/; END {print
"\r\n"}' | msmtp -t

This email was written in the webmail in firefox; I actually counted spaces for indentation in the hope that things line up. ;-)

Previous: Junio C HamanoNext: Junio C Hamano
Message 23 of 50 in “Introduction to Decreasing send-email Entropy”
  1. 00/12 Introduction to Decreasing send-email EntropyMichael Witten, Apr 18, 2009
  2. 01/12 send-email: Cleanup the usage text and docs a bitMichael Witten, Apr 18, 2009
  3. 02/12 send-email: No longer repeatedly test if $smtp_server is a commandMichael Witten, Apr 18, 2009
  4. 03/12 send-email: Interpret --smtp-server "" as "use a default".Michael Witten, Apr 18, 2009
  5. 04/12 send-email: Verification for --smtp-server and --smpt-server-portMichael Witten, Apr 18, 2009
  6. 05/12 send-email: Improve redability and error-handling in send_message's sendmail codeMichael Witten, Apr 18, 2009
  7. 06/12 send-email: Cleanup and streamline the SMTP code in send_messageMichael Witten, Apr 18, 2009
  8. 07/12 send-email: Cleanup send_message 'log' codeMichael Witten, Apr 18, 2009
  9. 08/12 send-email: Move Subject sanitization from --compose code to send_messageMichael Witten, Apr 18, 2009
  10. 09/12 Docs: send-email: Reorganize the CONFIGURATION sectionMichael Witten, Apr 18, 2009
  11. 10/12 Docs: Embolden the CONFIGURATION referencesMichael Witten, Apr 18, 2009
  12. 11/12 Docs: send-email: Clarification of sendemail.<identity>Michael Witten, Apr 18, 2009
  13. 12/12 Docs: send-email: git send-email -> 'send-email'Michael Witten, Apr 18, 2009
  14. Jay SoffianApr 19, 2009
  15. Michael WittenApr 19, 2009
  16. Jay SoffianApr 19, 2009
  17. Michael WittenApr 19, 2009
  18. Michael WittenApr 19, 2009
  19. 08/12 send-email: Simplify --compose subject sanitationMichael Witten, Apr 19, 2009
  20. Jeff KingApr 21, 2009
  21. Michael WittenApr 21, 2009
  22. Junio C HamanoApr 20, 2009
  23. Michael WittenApr 20, 2009
  24. Junio C HamanoApr 20, 2009
  25. Jay SoffianApr 19, 2009
  26. Michael WittenApr 19, 2009
  27. Thomas AdamApr 19, 2009
  28. Michael WittenApr 19, 2009
  29. Junio C HamanoApr 19, 2009
  30. 05/12 send-email: Improve readability and error-handling in send_message's sendmail codeMichael Witten, Apr 19, 2009
  31. Jay SoffianApr 19, 2009
  32. Junio C HamanoApr 20, 2009
  33. Junio C HamanoApr 20, 2009
  34. Jeff KingApr 21, 2009
  35. Jeff KingApr 21, 2009
  36. 04/12 send-email: Verification for --smtp-server and --smpt-server-portMichael Witten, Apr 19, 2009
  37. Michael WittenApr 20, 2009
  38. Junio C HamanoApr 20, 2009
  39. Junio C HamanoApr 20, 2009
  40. Michael WittenApr 20, 2009
  41. Michael WittenApr 20, 2009
  42. Wesley J. LandakerApr 18, 2009
  43. Michael WittenApr 19, 2009
  44. 03/12 send-email: Interpret --smtp-server "" as "use a default".Michael Witten, Apr 19, 2009
  45. Junio C HamanoApr 20, 2009
  46. Michael WittenApr 20, 2009
  47. Junio C HamanoApr 20, 2009
  48. Michael WittenApr 20, 2009
  49. Junio C HamanoApr 20, 2009
  50. Subject: Re: [PATCH RFC3.5 02/12] send-email: No longer repeatedly test if $smtp_server is a commandMichael Witten, Apr 20, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.