From 9fef9e279055423363e110b7246a9b8bbcf0bd72 Mon Sep 17 00:00:00 2001 From: Cord Seele Date: Fri, 30 Sep 2011 12:52:24 +0200 Subject: Add Git::config_path() Use --path option when calling 'git config' thus allow for pathname expansion, e.g. a tilde. Signed-off-by: Cord Seele Signed-off-by: Junio C Hamano --- perl/Git.pm | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/perl/Git.pm b/perl/Git.pm index a86ab709c2..c279bfb244 100644 --- a/perl/Git.pm +++ b/perl/Git.pm @@ -627,6 +627,38 @@ sub config_bool { }; } + +=item config_path ( VARIABLE ) + +Retrieve the path configuration C. The return value +is an expanded path or C if it's not defined. + +This currently wraps command('config') so it is not so fast. + +=cut + +sub config_path { + my ($self, $var) = _maybe_self(@_); + + try { + my @cmd = ('config', '--path'); + unshift @cmd, $self if $self; + if (wantarray) { + return command(@cmd, '--get-all', $var); + } else { + return command_oneline(@cmd, '--get', $var); + } + } catch Git::Error::Command with { + my $E = shift; + if ($E->value() == 1) { + # Key not found. + return undef; + } else { + throw $E; + } + }; +} + =item config_int ( VARIABLE ) Retrieve the integer configuration C. The return value -- cgit v1.2.3 From cec5dae827f2255578807be6214ece1e0619b8e1 Mon Sep 17 00:00:00 2001 From: Cord Seele Date: Fri, 30 Sep 2011 12:52:25 +0200 Subject: use new Git::config_path() for aliasesfile Signed-off-by: Cord Seele Signed-off-by: Junio C Hamano --- git-send-email.perl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/git-send-email.perl b/git-send-email.perl index 98ab33aae7..f17f7b3995 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -225,7 +225,6 @@ my %config_settings = ( "cccmd" => \$cc_cmd, "aliasfiletype" => \$aliasfiletype, "bcc" => \@bcclist, - "aliasesfile" => \@alias_files, "suppresscc" => \@suppress_cc, "envelopesender" => \$envelope_sender, "multiedit" => \$multiedit, @@ -234,6 +233,10 @@ my %config_settings = ( "assume8bitencoding" => \$auto_8bit_encoding, ); +my %config_path_settings = ( + "aliasesfile" => \@alias_files, +); + # Help users prepare for 1.7.0 sub chain_reply_to { if (defined $chain_reply_to && @@ -330,6 +333,11 @@ sub read_config { $$target = Git::config_bool(@repo, "$prefix.$setting") unless (defined $$target); } + foreach my $setting (keys %config_path_settings) { + my $target = $config_path_settings{$setting}->[0]; + $$target = Git::config_path(@repo, "$prefix.$setting") unless (defined $$target); + } + foreach my $setting (keys %config_settings) { my $target = $config_settings{$setting}; next if $setting eq "to" and defined $no_to; -- cgit v1.2.3