diff options
author | Jay Soffian <jaysoffian@gmail.com> | 2009-03-28 21:39:10 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-03-29 21:41:03 -0700 |
commit | 6e1825186bd052fc1f77b7c8c9a31fbb9a67d90c (patch) | |
tree | 2a008a9d06ad2ca6325d226a9cc0ee3c7eb5792c /branch.h | |
parent | 18d5cf908fe89c780872acc8a9f11d061e4556b6 (diff) | |
download | git-6e1825186bd052fc1f77b7c8c9a31fbb9a67d90c.tar.gz git-6e1825186bd052fc1f77b7c8c9a31fbb9a67d90c.tar.xz |
send-email: refactor and ensure prompting doesn't loop forever
Several places in send-email prompt for input, and will do so forever
when the input is EOF. This is poor behavior when send-email is run
unattended (say from cron).
This patch refactors the prompting to an ask() function which takes a
prompt, an optional default, and an optional regex to validate the
input. The function returns on EOF, or if a default is provided and the
user simply types return, or if the input passes the validating regex
(which accepts all input by default). The ask() function gives up after
10 tries in case of invalid input.
There are four callers of the function:
1) "Who should the emails appear to be from?" which provides a default
sender. Previously the user would have to type ctrl-d to accept the
default. Now the user can just hit return, or type ctrl-d.
2) "Who should the emails be sent to?". Previously this prompt passed a
second argument ("") to $term->readline() which was ignored. I believe
the intent was to allow the user to just hit return. Now the user
can do so, or type ctrl-d.
3) "Message-ID to be used as In-Reply-To for the first email?".
Previously this prompt passed a second argument (effectively undef) to
$term->readline() which was ignored. I believe the intent was the same
as for (2), to allow the user to just hit return. Now the user can do
so, or type ctrl-d.
4) "Send this email?". Previously this prompt would loop forever until
it got a valid reply. Now it stops prompting on EOF or a valid reply. In
the case where confirm = "inform", it now defaults to "y" on EOF or the
user hitting return, otherwise an invalid reply causes send-email to
terminate.
A followup patch adds tests for the new functionality.
Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'branch.h')
0 files changed, 0 insertions, 0 deletions