Re: [PATCH v4 12/13] send-email: move trivial config handling to Perl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 24, 2021 at 09:53:01AM +0200, Ævar Arnfjörð Bjarmason wrote:

> diff --git a/git-send-email.perl b/git-send-email.perl
> index 1e9273fd4f5..1ea4d9589d8 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -324,7 +324,11 @@ sub read_config {
>  		my $target = $config_bool_settings{$setting};
>  		my $key = "$prefix.$setting";
>  		next unless exists $known_keys->{$key};
> -		my $v = Git::config_bool(@repo, $key);
> +		my $v = (@{$known_keys->{$key}} == 1 &&
> +			 (defined $known_keys->{$key}->[0] &&
> +			  $known_keys->{$key}->[0] =~ /^(?:true|false)$/s))
> +			? $known_keys->{$key}->[0] eq 'true'
> +			: Git::config_bool(@repo, $key);

Thanks for addressing this. It looks like an undefined value will kick
back to the Git::config_bool() case. That's probably fine, as I'd think
it's relatively rare (and this is all just optimization anyway).

> @@ -353,14 +357,12 @@ sub read_config {
>  		my $key = "$prefix.$setting";
>  		next unless exists $known_keys->{$key};
>  		if (ref($target) eq "ARRAY") {
> -			my @values = Git::config(@repo, $key);
> -			next unless @values;
> +			my @values = @{$known_keys->{$key}};
>  			next if $configured->{$setting}++;
>  			@$target = @values;
>  		}

I do wonder what happens for non-bool values here. I.e., would we return
a list that contains undef? Before your change, the value comes from
Git::config(), and now it comes from our pre-read $known_keys.

It seems fine either way:

  $ git -c sendemail.smtpsslcertpath send-email -1
  error: missing value for 'sendemail.smtpsslcertpath'
  fatal: unable to parse command-line config
  config --path --get sendemail.smtpsslcertpath: command returned error: 128

but I didn't carefully follow all the paths that config can take. So I
raise it only as a potential issue. Your response is hopefully "yes, I
thought of that, and it is fine." :)

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux