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

Re: [PATCH] git-send-email: allow re-editing of message

From
EWEric Wong <e@80x24.org>
Date
May 4, 2018, 08:19 UTC
Message-ID
<20180504081936.GA9133@dcvr>
In-Reply-To
<20180502143200.9371-1-sir@cmpwn.com>
Drew DeVault <sir@cmpwn.com> wrote:
> 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.

Thanks, this seems like a good idea for the cover letter, especially. I prefer to get the commit messages right in the git history, first, but I more often screw up the cover letter.

I haven't looked at the code to send-email in a while, so some thinking out loud below :>

Show 15 quoted lines
> --- 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.

OK, -1 is the new return value. Thanks for documenting this. The rest of the prompt implementation looks fine and I won't quote it.

Show 11 quoted lines
> @@ -1552,7 +1559,9 @@ $references = $initial_in_reply_to || '';
>  $subject = $initial_subject;
>  $message_num = 0;
>  
> -foreach my $t (@files) {
> +sub process_file {
> +	my ($t) = @_;
> +
>  	open my $fh, "<", $t or die sprintf(__("can't open file %s"), $t);
>  
>  	my $author = undef;
OK, process_file is a new function...
Show 8 quoted lines
> @@ -1755,6 +1764,10 @@ foreach my $t (@files) {
>  	}
>  
>  	my $message_was_sent = send_message();
> +	if ($message_was_sent == -1) {
> +		do_edit($t);
> +		return 0;
> +	}

And the previously documented -1 return value is used here. Mental note: process_file returns 0 to indicate an edit was done.

Show 8 quoted lines
>  	# set up for the next message
>  	if ($thread && $message_was_sent &&
> @@ -1776,6 +1789,14 @@ foreach my $t (@files) {
>  		undef $auth;
>  		sleep($relogin_delay) if defined $relogin_delay;
>  	}
> +
> +	return 1;
Mental note: process_file normally returns 1
Show 5 quoted lines
> +}
> +
> +foreach my $t (@files) {
> +	while (!process_file($t)) {
> +		# This space deliberately left blank
Cute, but that comment could say something useful, instead:
	# user is still editing the file
Otherwise, I think the patch is great.  Thanks!
Previous: Drew DeVault
Message 2 of 2 in “git-send-email: allow re-editing of message”
  1. git-send-email: allow re-editing of messageDrew DeVault, May 2, 2018
  2. Eric WongMay 4, 2018

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.