]> git.ipfire.org Git - thirdparty/git.git/commit
send-email: do defaults -> config -> getopt in that order
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Thu, 9 May 2019 11:48:30 +0000 (13:48 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 May 2019 08:54:07 +0000 (17:54 +0900)
commit3494dfd3ee058bbeab6a462673d9184dcd694a8b
treee87d53e1730d0486d0d70e0087f378f777181c11
parente60f6d13f3b04ee3a8aa50ed5a0b97d2fb58bad8
send-email: do defaults -> config -> getopt in that order

Change the git-send-email command-line argument parsing and config
reading code to parse those two in the right order. I.e. first we set
our hardcoded defaults, then we read our config, and finally we read
the command-line, with later sets overriding earlier sets.

This fixes a bug introduced in e67a228cd8 ("send-email:
automatically determine transfer-encoding", 2018-07-08). That change
broke the reading of sendmail.transferencoding because it wasn't
careful to update the code to parse them in the previous "defaults
-> getopt -> config" order.

But as we can see from the history for this file doing it this way was
never what we actually wanted, it's just something we grew organically
as of 5483c71d7a ("git-send-email: make options easier to configure.",
2007-06-27) and have been dealing with the fallout since, e.g. in
463b0ea22b ("send-email: Fix %config_path_settings handling",
2011-10-14).

As can be seen in this change the only place where we actually want to
do something clever is with the to/cc/bcc variables, where setting
them on the command-line (or using --no-{to,cc,bcc}) should clear out
values we grab from the config.

All the rest are things where the command-line should simply override
the config values, and by reading the config first the config code
doesn't need all this "let's not set it, if it was on the command-line"
special-casing, as [1] shows we'd otherwise need to care about the
difference between whether something was a default or present in
config to fix the bug in e67a228cd8.

1. https://public-inbox.org/git/20190508105607.178244-2-gitster@pobox.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-send-email.perl
t/t9001-send-email.sh