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 <cowose@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Cord Seele committed
Sep 30, 2011 at 12:52 UTC
9fef9e279055423363e110b7246a9b8bbcf0bd72
1 file changed
+32
perl/Git.pm
+32
@@ -627,6 +627,38 @@ sub config_bool {
627
};
628
}
629
630
+
631
+=item config_path ( VARIABLE )
632
+
633
+Retrieve the path configuration C<VARIABLE>. The return value
634
+is an expanded path or C<undef> if it's not defined.
635
+
636
+This currently wraps command('config') so it is not so fast.
637
+
638
+=cut
639
+
640
+sub config_path {
641
+ my ($self, $var) = _maybe_self(@_);
642
+
643
+ try {
644
+ my @cmd = ('config', '--path');
645
+ unshift @cmd, $self if $self;
646
+ if (wantarray) {
647
+ return command(@cmd, '--get-all', $var);
648
+ } else {
649
+ return command_oneline(@cmd, '--get', $var);
650
+ }
651
+ } catch Git::Error::Command with {
652
+ my $E = shift;
653
+ if ($E->value() == 1) {
654
+ # Key not found.
655
+ return undef;
656
+ } else {
657
+ throw $E;
658
+ }
659
+ };
660
+}
661
+
662
=item config_int ( VARIABLE )
663
664
Retrieve the integer configuration C<VARIABLE>. The return value