X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FApp%2FRgit%2FConfig.pm;h=903b3e4f9a433055274f96f511dfed03ed9039f1;hb=569b85b70a20cac15bc2ff0bed6df11ac0e844ec;hp=7a247eb7dc67357b73d018a3c884eeb12ba5a5fa;hpb=20ecc90aa6c17a07fd1200d0bf72d5918e53e106;p=perl%2Fmodules%2Frgit.git diff --git a/lib/App/Rgit/Config.pm b/lib/App/Rgit/Config.pm index 7a247eb..903b3e4 100644 --- a/lib/App/Rgit/Config.pm +++ b/lib/App/Rgit/Config.pm @@ -4,8 +4,8 @@ use strict; use warnings; use Carp (); # confess -use Cwd (); # abs_path -use File::Spec (); # canonpath +use Cwd (); # cwd, abs_path +use File::Spec (); # canonpath, catfile, path use App::Rgit::Repository; use App::Rgit::Utils qw/:levels/; @@ -44,20 +44,36 @@ sub new { my %args = @_; - my $root = $args{root}; - return unless defined $root and -d $root; + my $root = defined $args{root} + ? $args{root} + : defined $ENV{GIT_DIR} + ? $ENV{GIT_DIR} + : Cwd::cwd; + Carp::confess("Invalid root directory") unless -d $root; $root = File::Spec->canonpath(Cwd::abs_path($root)); - my $git = $args{git}; - return unless defined $git; + my $git; + my @candidates = ( + defined $args{git} + ? $args{git} + : defined $ENV{GIT_EXEC_PATH} + ? $ENV{GIT_EXEC_PATH} + : map File::Spec->catfile($_, 'git'), File::Spec->path + ); if (IS_WIN32) { - unless (-x $git) { - $git .= '.bat'; - return unless -x $git; + my @acc; + for my $c (@candidates) { + push @acc, $c, map "$c.$_", qw/exe com bat cmd/; } - } else { - return unless -x $git; + @candidates = @acc; } + for my $c (@candidates) { + if (-x $c) { + $git = $c; + last; + } + } + Carp::confess("Couldn't find a proper git executable") unless defined $git; $git = File::Spec->canonpath(Cwd::abs_path($git)); my $conf = 'App::Rgit::Config::Default'; @@ -134,7 +150,8 @@ You can contact me by mail or on C (vincent). =head1 BUGS -Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. +Please report any bugs or feature requests to C, or through the web interface at L. +I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT