From: Junio C Hamano <gitster@pobox.com>
To: Dragan Simic <dsimic@manjaro.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2] send-email: make it easy to discern the messages for each patch
Date: Thu, 04 Apr 2024 15:52:31 -0700 [thread overview]
Message-ID: <xmqqzfu8yc40.fsf@gitster.g> (raw)
In-Reply-To: <0e087ed992def0746f3d437253248904c2126464.1712262791.git.dsimic@manjaro.org> (Dragan Simic's message of "Thu, 4 Apr 2024 22:34:28 +0200")
Dragan Simic <dsimic@manjaro.org> writes:
> if ($smtp) {
> print __("Result: "), $smtp->code, ' ',
> - ($smtp->message =~ /\n([^\n]+\n)$/s), "\n";
> + ($smtp->message =~ /\n([^\n]+\n)$/s);
> } else {
> - print __("Result: OK\n");
> + print __("Result: OK");
> }
> + # Make it easy to discern the messages for each patch
I do not think we want this comment.
Before printing the "Result: OK" line, we do not give an obvious and
pointless comment e.g., "# Report success". What this comment says
something similarly obvious. Both choices in the preceding if/else
emit an incomplete line, hence it is clear that we need to terminate
the line here, and this is the last line of output about the message
we just processed.
> }
>
> return 1;
You didn't ran t9001 before sending this version (or any of the
previous rounds) out, did you? Among ~200 tests 10 of them now fail
with this patch applied.
Do we know when we are sending either the first or the last message
of a sequence at this point in the code? It would be superb if you
can make this extra blank line a separator, not a terminator [*], as
there needs no extra blank line after emitting the last message.
[Side note]
* When showing a list of 3 things A B C, you can separate them by
inserting a gap between A and B, and another gap between B and C,
and you are using the "separator" (this is similar to how "git
log --pretty=format:..." works). But you can be lazy and instead
append a gap after each element, in which case you are using the
"terminator" (similar to how "git log --pretty=tformat:..."
works).
But it is harder to do separator correctly if the output is
conditional (e.g., you have 5 input messages, but you may somehow
skip some messages depending on conditions---now your code to decide
if you emit an extra newline needs to take it into account. After
sending the 4th message and showing an extra newline, because you
expect that there is another message to be sent and it needs a gap
before, you may realize that some logic causes you to drop 5th and
final message but then it is too late for you to take that extra
blank line back), and obviously a buggy separator implementation is
worse than a terminator implementation.
Here is my attempt on top of your patch to implement the separator
semantics. After showing a message, we remember that fact, and
before showing the next message, we emit an extra blank line. With
it, all tests in t9001 pass, but you may want to double check how
different ways to leave send_message() would affect the output. I
just randomly decided that there needs no extra blank line before
emitting the message that was edited and that is why in the
following patch, I assign 0 to $want_separator_before_send_message
in that case, but it may not be the right choice (I never "edit"
inside send-email myself, so I would be a wrong person to decide
without second opinion), for example.
git-send-email.perl | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git c/git-send-email.perl w/git-send-email.perl
index ac0c691d3a..d4bbc73f1f 100755
--- c/git-send-email.perl
+++ w/git-send-email.perl
@@ -1689,8 +1689,7 @@ sub send_message {
} else {
print __("Result: OK");
}
- # Make it easy to discern the messages for each patch
- print "\n\n";
+ print "\n";
}
return 1;
@@ -1918,16 +1917,21 @@ sub pre_process_file {
# Prepares the email, prompts the user, and sends it out
# Returns 0 if an edit was done and the function should be called again, or 1
# on the email being successfully sent out.
+my $want_separator_before_send_message = 0;
+
sub process_file {
my ($t) = @_;
pre_process_file($t, $quiet);
+ print "\n" if ($want_separator_before_send_message);
my $message_was_sent = send_message();
if ($message_was_sent == -1) {
do_edit($t);
+ $want_separator_before_send_message = 0;
return 0;
}
+ $want_separator_before_send_message = $message_was_sent;
# set up for the next message
if ($thread) {
next prev parent reply other threads:[~2024-04-04 22:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-04 20:34 [PATCH v2] send-email: make it easy to discern the messages for each patch Dragan Simic
2024-04-04 22:52 ` Junio C Hamano [this message]
2024-04-04 23:44 ` Dragan Simic
2024-04-05 16:44 ` Junio C Hamano
2024-04-05 16:51 ` Dragan Simic
2024-04-05 17:13 ` Junio C Hamano
2024-04-05 17:18 ` Dragan Simic
2024-04-05 6:52 ` Kristoffer Haugsbakk
2024-04-05 7:07 ` Dragan Simic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqzfu8yc40.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=dsimic@manjaro.org \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).