git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Regression in git send-email parsing sendemail.* config values

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Sep 6, 2021, 00:04 UTC
Message-ID
<87k0jupnxi.fsf@evledraar.gmail.com>
In-Reply-To
<e86f64ff-0395-26f7-5d5b-7df2e6e63ff4@archlinux.org>
On Sun, Sep 05 2021, Eli Schwartz wrote:
Show 6 quoted lines
> I recently noticed that git send-email was attempting to send emails
> using the wrong email address. I have a global email configuration in
> XDG_CONFIG_HOME, and a specific one set in the {repo}/.git/config of
> some repos... this was trying to use the global configuration.
>
> `git config -l | grep ^sendemail.smtpserver=` reports two emails

Don't you mean s/emails/servers/, ditto "wrong email address" should be "the wrong server", right?

Show 14 quoted lines
> `git config --get sendemail.smtpserver` reports only the second,
> repo-specific one
>
>
> I bisected the issue to commit c95e3a3f0b8107b5dc7eac9dfdb9e5238280c9fb
>
>     send-email: move trivial config handling to Perl
>
>
> Using this commit, git-send-email disagrees with git config --get on
> which email to use.
>
> Using commit f4dc9432fd287bde9100488943baf3c6a04d90d1 immediately
> preceding this commit, git send-email agrees with git config --get.

That's a pretty bad bug, sorry about that. I believe that the following patch should fix it (needs tests obviously). I.e. when we had N config keys we'd previously pick the normal "last key wins", which my c95e3a3f0b8107b5dc7eac9dfdb9e5238280c9fb changed to "first wins":

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;
Previous: Eli SchwartzNext: Eli Schwartz
Message 2 of 7 in “Regression in git send-email parsing sendemail.* config values”
  1. Eli SchwartzSep 5, 2021
  2. Ævar Arnfjörð BjarmasonSep 6, 2021
  3. Eli SchwartzSep 6, 2021
  4. send-email: fix a "first config key wins" regression in v2.33.0Ævar Arnfjörð Bjarmason, Sep 6, 2021
  5. Carlo ArenasSep 6, 2021
  6. Bagas SanjayaSep 6, 2021
  7. Ævar Arnfjörð BjarmasonSep 7, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.