* [BUG] Asks for "To" even if "To" already specified in letter
@ 2023-12-30 3:20 Askar Safin
2024-01-02 22:23 ` Taylor Blau
0 siblings, 1 reply; 2+ messages in thread
From: Askar Safin @ 2023-12-30 3:20 UTC (permalink / raw)
To: git
Hi. I found a bug. Steps to reproduce:
- Create file /tmp/m with following text:
===
Subject: subj
To: example@example.com
text
===
- Send it using command "git send-email /tmp/m"
You will see that git asks for "To". git says: "To whom should the
emails be sent (if anyone)?"
I don't like this. git should just use "To" from /tmp/m without asking.
Seen with git 2.43.0.
If I execute "git send-email --to-cmd='#' /tmp/m" or
"git send-email --to-cmd=':' /tmp/m" or
"git send-email --to-cmd='true' /tmp/m", then "To" is not asked.
Same happens when I send one single patch without cover letter. Steps
to reproduce:
- Clone some repo
- Make some (single) commit
- Execute in the repo "git send-email --annotate HEAD^"
- Editor will be spawned. Add header "To: example@example.com", then
save and exit from the editor
You will see the question "To whom should the emails be sent (if
anyone)?", too. And again you can workaround using --to-cmd tricks.
--
Askar Safin
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [BUG] Asks for "To" even if "To" already specified in letter
2023-12-30 3:20 [BUG] Asks for "To" even if "To" already specified in letter Askar Safin
@ 2024-01-02 22:23 ` Taylor Blau
0 siblings, 0 replies; 2+ messages in thread
From: Taylor Blau @ 2024-01-02 22:23 UTC (permalink / raw)
To: Askar Safin; +Cc: git
On Sat, Dec 30, 2023 at 06:20:43AM +0300, Askar Safin wrote:
> Hi. I found a bug. Steps to reproduce:
> - Create file /tmp/m with following text:
> ===
> Subject: subj
> To: example@example.com
>
> text
> ===
> - Send it using command "git send-email /tmp/m"
>
> You will see that git asks for "To". git says: "To whom should the
> emails be sent (if anyone)?"
> I don't like this. git should just use "To" from /tmp/m without asking.
>
> Seen with git 2.43.0.
>
> If I execute "git send-email --to-cmd='#' /tmp/m" or
> "git send-email --to-cmd=':' /tmp/m" or
> "git send-email --to-cmd='true' /tmp/m", then "To" is not asked.
I was going to suggest that you use the `--to-cmd=true` trick. I'm
definitely not an expert in the send-email code, but from a cursory
look, I think that this is do-able.
One thing you could do is read all of the messages ahead of time, parse
their headers, and then extract any "To:" headers that you find. This is
pretty similar to what the pre_process_file() function is already doing.
But this might not be the right approach, since FIFOs can only be read
once, and we already have some logic to handle FIFOs specially (see
3c8d3adeae (send-email: export patch counters in validate environment,
2023-04-14)).
But I think that something much simpler would work, which to avoid
asking for a "To:" value altogether, even if one isn't provided. If you
did something like:
--- 8< ---
diff --git a/git-send-email.perl b/git-send-email.perl
index 821b2b3a13..2941278315 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1018,13 +1018,6 @@ sub file_declares_8bit_cte {
my $to_whom = __("To whom should the emails be sent (if anyone)?");
my $prompting = 0;
-if (!@initial_to && !defined $to_cmd) {
- my $to = ask("$to_whom ",
- default => "",
- valid_re => qr/\@.*\./, confirm_only => 1);
- push @initial_to, parse_address_line($to) if defined $to; # sanitized/validated later
- $prompting++;
-}
sub expand_aliases {
return map { expand_one_alias($_) } @_;
--- >8 ---
I think that would more or less do the trick. send-email will happily
continue on even without an initial $to value, and validate it later
when it's actually needed.
I'm not familiar enough with the code to know if this is the right
approach, so hopefully some other send-email experts can chime in and
let me know if I'm on the right track ;-).
Thanks,
Taylor
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-02 22:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-30 3:20 [BUG] Asks for "To" even if "To" already specified in letter Askar Safin
2024-01-02 22:23 ` Taylor Blau
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 NNTP newsgroup(s).