From: Junio C Hamano <gitster@pobox.com>
To: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Cc: git@vger.kernel.org, Phillip Wood <phillip.wood123@gmail.com>
Subject: Re: [PATCH v3] send-email: prompt-dependent exit codes
Date: Mon, 07 Aug 2023 11:55:29 -0700 [thread overview]
Message-ID: <xmqqbkfifzry.fsf@gitster.g> (raw)
In-Reply-To: <20230807165850.2335067-1-oswald.buddenhagen@gmx.de> (Oswald Buddenhagen's message of "Mon, 7 Aug 2023 18:58:50 +0200")
Oswald Buddenhagen <oswald.buddenhagen@gmx.de> writes:
> From the perspective of a scripted caller, failure to send (some) mails
> is an error even if it was interactively requested, so it should be
> indicated by the exit code.
I am not sure if unconditional change of exit code this late in the
game. When was the interactive "no, do not send this one" feature
introduced? The end-users (not necessarily all of them, of course)
have been happily using the command and have appreciated not having
to see non-zero exit code after skipping some messages. I wonder if
this should be hidden behind an opt-in command line option and possibly
a configuration variable that defaults to "no".
> To make it somewhat specific, the exit code is 10 when only some mails
> were skipped, and 11 if the user quit on the first prompt.
If 10 and 11 were *not* taken out of thin air, but there is a
precedent to use these two values in e-mail related programs, please
share. It may give us a good justification.
With or without other people's precedents, and with or without
making it conditional, the new behaviour must be documented, if the
command has already a documentation (and it seems that there exists
the Documentation/git-send-email.txt file). It may be preferrable
to protect the new feature with a test or two added to t9001 but it
obviously depends on how hard you find testing interactive stuff is.
> For interactive calls from the command line, interactive cancellation is
> arguably not really an error, but there the exit code will be more or
> less ignored anyway.
Not necessarily. Some people prefer to see it and show it in their
command line prompt.
> diff --git a/git-send-email.perl b/git-send-email.perl
> index affbb88509..cd4db84b7f 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -256,6 +256,26 @@ sub system_or_die {
> die $msg if $msg;
> }
>
> +my $sent_files = 0;
> +
> +sub do_exit {
> + if ($sent_files == @files) {
> + # All specified messages were sent
> + exit(0);
> + } elsif ($sent_files) {
> + # At least some messages were sent
> + exit(10);
> + } else {
> + # User cancelled on first message already
> + exit(11);
> + }
> +}
OK. As log as we won't start doing
while (loop) {
$file = shift @files;
send $file;
}
this will keep working fine, and the logic is very clear to see.
Thanks. Will queue but expect at least some documentation updates.
next prev parent reply other threads:[~2023-08-07 18:55 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-26 6:16 [PATCH v2] send-email: prompt-dependent exit codes Oswald Buddenhagen
2023-04-27 15:49 ` Junio C Hamano
2023-05-02 19:04 ` Felipe Contreras
2023-08-07 16:58 ` [PATCH v3] " Oswald Buddenhagen
2023-08-07 18:55 ` Junio C Hamano [this message]
2023-08-08 10:55 ` Oswald Buddenhagen
2023-08-08 16:08 ` Junio C Hamano
2023-08-08 19:11 ` Oswald Buddenhagen
2023-08-09 17:15 ` [PATCH v4] " Oswald Buddenhagen
2023-08-09 19:15 ` Junio C Hamano
2023-08-10 10:00 ` Oswald Buddenhagen
2023-08-10 19:56 ` Junio C Hamano
2023-08-11 12:11 ` Oswald Buddenhagen
2023-08-21 17:07 ` [PATCH v5] " Oswald Buddenhagen
2023-08-21 17:57 ` Junio C Hamano
2023-08-21 18:57 ` Oswald Buddenhagen
2023-08-30 0:46 ` Junio C Hamano
2023-08-30 10:06 ` Oswald Buddenhagen
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=xmqqbkfifzry.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=oswald.buddenhagen@gmx.de \
--cc=phillip.wood123@gmail.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.