Drew DeVault <[email protected]> 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 :>
> --- 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.
> @@ -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...
> @@ -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.
> # 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
> +}
> +
> +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!