git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Eli Schwartz <eschwartz@archlinux.org>
Cc: git@vger.kernel.org
Subject: Re: Regression in git send-email parsing sendemail.* config values
Date: Mon, 06 Sep 2021 02:04:44 +0200	[thread overview]
Message-ID: <87k0jupnxi.fsf@evledraar.gmail.com> (raw)
In-Reply-To: <e86f64ff-0395-26f7-5d5b-7df2e6e63ff4@archlinux.org>


On Sun, Sep 05 2021, Eli Schwartz wrote:

> 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?

> `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;

  reply	other threads:[~2021-09-06  0:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-05 23:01 Regression in git send-email parsing sendemail.* config values Eli Schwartz
2021-09-06  0:04 ` Ævar Arnfjörð Bjarmason [this message]
2021-09-06  1:44   ` Eli Schwartz
2021-09-06  7:33     ` [PATCH] send-email: fix a "first config key wins" regression in v2.33.0 Ævar Arnfjörð Bjarmason
2021-09-06  8:32       ` Carlo Arenas
2021-09-06 11:05       ` Bagas Sanjaya
2021-09-07  9:15         ` Ævar Arnfjörð Bjarmason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k0jupnxi.fsf@evledraar.gmail.com \
    --to=avarab@gmail.com \
    --cc=eschwartz@archlinux.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).