Message ID | patch-1.1-ae6ff9f77f1-20210906T073306Z-avarab@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | b996f84989f78c8f6d2429b5f0b9785e13f7af23 |
Headers | show |
Series | send-email: fix a "first config key wins" regression in v2.33.0 | expand |
On Mon, Sep 6, 2021 at 12:35 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
> This test fails without this bugfix, but not works.
s/not/now
Carlo
On 06/09/21 14.33, Ævar Arnfjörð Bjarmason wrote: > +test_expect_success $PREREQ 'sendemail.8bitEncoding in .git/config overrides --global .gitconfig' ' > + clean_fake_sendmail && > + git config sendemail.assume8bitEncoding UTF-8 && > + test_when_finished "rm -rf home" && > + mkdir home && > + git config -f home/.gitconfig sendemail.assume8bitEncoding "bogus too" && > + echo bogus | > + env HOME="$(pwd)/home" DEBUG=1 \ > + git send-email --from=author@example.com --to=nobody@example.com \ > + --smtp-server="$(pwd)/fake.sendmail" \ > + email-using-8bit >stdout && > + egrep "Content|MIME" msgtxt1 >actual && > + test_cmp content-type-decl actual > +' > + Did you mean overrides global .gitconfig (s/--global/global/)? Anyway, compiled and tested successfully (test suite passed). Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>
On Mon, Sep 06 2021, Bagas Sanjaya wrote: > On 06/09/21 14.33, Ævar Arnfjörð Bjarmason wrote: >> +test_expect_success $PREREQ 'sendemail.8bitEncoding in .git/config overrides --global .gitconfig' ' >> + clean_fake_sendmail && >> + git config sendemail.assume8bitEncoding UTF-8 && >> + test_when_finished "rm -rf home" && >> + mkdir home && >> + git config -f home/.gitconfig sendemail.assume8bitEncoding "bogus too" && >> + echo bogus | >> + env HOME="$(pwd)/home" DEBUG=1 \ >> + git send-email --from=author@example.com --to=nobody@example.com \ >> + --smtp-server="$(pwd)/fake.sendmail" \ >> + email-using-8bit >stdout && >> + egrep "Content|MIME" msgtxt1 >actual && >> + test_cmp content-type-decl actual >> +' >> + > > Did you mean overrides global .gitconfig (s/--global/global/)? I mean config set with the equivalent of "git config --global", but yeah this is probably an awkward way to phrase that. > Anyway, compiled and tested successfully (test suite passed). > > Tested-by: Bagas Sanjaya <bagasdotme@gmail.com> Thanks, FWIW the test suite passing doesn't mean much in this case, the only test that stresses this is the above. The issue being that the regression wasn't caught by any existing test...
diff --git a/git-send-email.perl b/git-send-email.perl index e65d969d0bb..6c7ab3d2e91 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -376,7 +376,7 @@ sub read_config { @$target = @values; } else { - my $v = $known_keys->{$key}->[0]; + my $v = $known_keys->{$key}->[-1]; next unless defined $v; next if $configured->{$setting}++; $$target = $v; diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 57fc10e7f82..eae172e0a05 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -1533,6 +1533,21 @@ test_expect_success $PREREQ 'sendemail.8bitEncoding works' ' test_cmp content-type-decl actual ' +test_expect_success $PREREQ 'sendemail.8bitEncoding in .git/config overrides --global .gitconfig' ' + clean_fake_sendmail && + git config sendemail.assume8bitEncoding UTF-8 && + test_when_finished "rm -rf home" && + mkdir home && + git config -f home/.gitconfig sendemail.assume8bitEncoding "bogus too" && + echo bogus | + env HOME="$(pwd)/home" DEBUG=1 \ + git send-email --from=author@example.com --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + email-using-8bit >stdout && + egrep "Content|MIME" msgtxt1 >actual && + test_cmp content-type-decl actual +' + test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' ' clean_fake_sendmail && git config sendemail.assume8bitEncoding "bogus too" &&