mirror of
https://github.com/git/git.git
synced 2026-04-11 17:30:08 +02:00
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 ine67a228cd8("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 of5483c71d7a("git-send-email: make options easier to configure.", 2007-06-27) and have been dealing with the fallout since, e.g. in463b0ea22b("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 ine67a228cd8. 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>
This commit is contained in:
committed by
Junio C Hamano
parent
e60f6d13f3
commit
3494dfd3ee
@@ -1433,7 +1433,18 @@ test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEnc
|
||||
test -z "$(ls msgtxt*)"
|
||||
'
|
||||
|
||||
test_expect_success $PREREQ 'sendemail.transferencoding=8bit' '
|
||||
test_expect_success $PREREQ 'sendemail.transferencoding=8bit via config' '
|
||||
clean_fake_sendmail &&
|
||||
git -c sendemail.transferencoding=8bit send-email \
|
||||
--smtp-server="$(pwd)/fake.sendmail" \
|
||||
email-using-8bit \
|
||||
2>errors >out &&
|
||||
sed '1,/^$/d' msgtxt1 >actual &&
|
||||
sed '1,/^$/d' email-using-8bit >expected &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_expect_success $PREREQ 'sendemail.transferencoding=8bit via cli' '
|
||||
clean_fake_sendmail &&
|
||||
git send-email \
|
||||
--transfer-encoding=8bit \
|
||||
|
||||
Reference in New Issue
Block a user