git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Drew DeVault <sir@cmpwn.com>
Cc: git@vger.kernel.org, "Simon Ser" <contact@emersion.fr>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Eric Wong" <e@80x24.org>
Subject: Re: [PATCHv2] git-send-email: allow re-editing of message
Date: Sun, 06 May 2018 12:56:24 +0900	[thread overview]
Message-ID: <xmqq4ljlsahj.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20180504130811.3398-1-sir@cmpwn.com> (Drew DeVault's message of "Fri, 4 May 2018 09:08:11 -0400")

Drew DeVault <sir@cmpwn.com> writes:

> When shown the email summary, an opportunity is presented for the user
> to edit the email as if they had specified --annotate. This also permits
> them to edit it multiple times.
>
> Signed-off-by: Drew DeVault <sir@cmpwn.com>
> Reviewed-by: Simon Ser <contact@emersion.fr>
>
> ---
> Thanks for the review Eric, updated to address your feedback.

Instead you could credit him with Helped-by:, perhaps in place of
Reviewed-by: somebody who does not have any commit in our history,
which does not help others decide how good this patch is because
they do not know how much trust they should place in the ability to
review of somebody they never have heard of---Simon may be a super
human programmer whose name alone should assure us that a patch
endorsed is good, but the thing is, that won't happen until we know
that.

The patch looks good.  Eric may say "This round looks good to me"
before I have a chance to queue it, in which case I'll add his
Reviewed-by: and queue.  In either case, unless there is something
else comes up, there is no need to resend this patch.

Thanks.

>  git-send-email.perl | 38 +++++++++++++++++++++++++++++++-------
>  1 file changed, 31 insertions(+), 7 deletions(-)
>
> diff --git a/git-send-email.perl b/git-send-email.perl
> index 2fa7818ca..b45953733 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -1330,9 +1330,14 @@ sub file_name_is_absolute {
>  	return File::Spec::Functions::file_name_is_absolute($path);
>  }
>  
> -# Returns 1 if the message was sent, and 0 otherwise.
> -# In actuality, the whole program dies when there
> -# is an error sending a message.
> +# Prepares the email, then asks the user what to do.
> +#
> +# If the user chooses to send the email, it's sent and 1 is returned.
> +# If the user chooses not to send the email, 0 is returned.
> +# If the user decides they want to make further edits, -1 is returned and the
> +# caller is expected to call send_message again after the edits are performed.
> +#
> +# If an error occurs sending the email, this just dies.
>  
>  sub send_message {
>  	my @recipients = unique_email_list(@to);
> @@ -1404,15 +1409,17 @@ Message-Id: $message_id
>  
>  EOF
>  		}
> -		# TRANSLATORS: Make sure to include [y] [n] [q] [a] in your
> +		# TRANSLATORS: Make sure to include [y] [n] [e] [q] [a] in your
>  		# translation. The program will only accept English input
>  		# at this point.
> -		$_ = ask(__("Send this email? ([y]es|[n]o|[q]uit|[a]ll): "),
> -		         valid_re => qr/^(?:yes|y|no|n|quit|q|all|a)/i,
> +		$_ = ask(__("Send this email? ([y]es|[n]o|[e]dit|[q]uit|[a]ll): "),
> +		         valid_re => qr/^(?:yes|y|no|n|edit|e|quit|q|all|a)/i,
>  		         default => $ask_default);
>  		die __("Send this email reply required") unless defined $_;
>  		if (/^n/i) {
>  			return 0;
> +		} elsif (/^e/i) {
> +			return -1;
>  		} elsif (/^q/i) {
>  			cleanup_compose_files();
>  			exit(0);
> @@ -1552,7 +1559,12 @@ $references = $initial_in_reply_to || '';
>  $subject = $initial_subject;
>  $message_num = 0;
>  
> -foreach my $t (@files) {
> +# Prepares the email, prompts the user, sends it out
> +# Returns 0 if an edit was done and the function should be called again, or 1
> +# otherwise.
> +sub process_file {
> +	my ($t) = @_;
> +
>  	open my $fh, "<", $t or die sprintf(__("can't open file %s"), $t);
>  
>  	my $author = undef;
> @@ -1755,6 +1767,10 @@ foreach my $t (@files) {
>  	}
>  
>  	my $message_was_sent = send_message();
> +	if ($message_was_sent == -1) {
> +		do_edit($t);
> +		return 0;
> +	}
>  
>  	# set up for the next message
>  	if ($thread && $message_was_sent &&
> @@ -1776,6 +1792,14 @@ foreach my $t (@files) {
>  		undef $auth;
>  		sleep($relogin_delay) if defined $relogin_delay;
>  	}
> +
> +	return 1;
> +}
> +
> +foreach my $t (@files) {
> +	while (!process_file($t)) {
> +		# user edited the file
> +	}
>  }
>  
>  # Execute a command (e.g. $to_cmd) to get a list of email addresses

      reply	other threads:[~2018-05-06  3:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-04 13:08 [PATCHv2] git-send-email: allow re-editing of message Drew DeVault
2018-05-06  3:56 ` Junio C Hamano [this message]

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq4ljlsahj.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=contact@emersion.fr \
    --cc=e@80x24.org \
    --cc=git@vger.kernel.org \
    --cc=sir@cmpwn.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).