X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Frgit.git;a=blobdiff_plain;f=lib%2FApp%2FRgit%2FConfig.pm;fp=lib%2FApp%2FRgit%2FConfig.pm;h=94a3359ff98767303214c7a5e1a8a25afb0cbd8e;hp=0442966b805d058f8bb7b27c639c228cbb0c5d12;hb=1df4b5b8d8d71567094a0c6ec3702ab71b614bd9;hpb=511d4fe4b46173353cd1fdcac0d26ac067868280 diff --git a/lib/App/Rgit/Config.pm b/lib/App/Rgit/Config.pm index 0442966..94a3359 100644 --- a/lib/App/Rgit/Config.pm +++ b/lib/App/Rgit/Config.pm @@ -5,7 +5,7 @@ use warnings; use Carp (); # confess use Cwd (); # abs_path -use File::Spec (); # canonpath +use File::Spec (); # canonpath, catfile, path use App::Rgit::Repository; use App::Rgit::Utils qw/:levels/; @@ -48,16 +48,28 @@ sub new { return unless defined $root and -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';