From: Vincent Pit Date: Wed, 24 Feb 2010 16:39:41 +0000 (+0100) Subject: Always canonify the root, the git path and the repo directory X-Git-Tag: v0.07~9 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=a35a1fae17b8e75696ef1e5474aaa99222594a6a;p=perl%2Fmodules%2Frgit.git Always canonify the root, the git path and the repo directory On Windows, abs_path returns a path with forward slashes, while File::Spec uses native backslashes. --- diff --git a/lib/App/Rgit/Config.pm b/lib/App/Rgit/Config.pm index dd6dff2..2ac22b2 100644 --- a/lib/App/Rgit/Config.pm +++ b/lib/App/Rgit/Config.pm @@ -3,9 +3,9 @@ package App::Rgit::Config; use strict; use warnings; -use Carp (); -use Cwd qw/abs_path/; -use File::Spec::Functions qw/file_name_is_absolute/; +use Carp (); +use Cwd qw/abs_path/; +use File::Spec::Functions qw/canonpath/; use App::Rgit::Repository; use App::Rgit::Utils qw/:levels/; @@ -46,7 +46,7 @@ sub new { my $root = $args{root}; return unless defined $root and -d $root; - $root = abs_path $root unless file_name_is_absolute $root; + $root = canonpath abs_path $root; my $git = $args{git}; return unless defined $git; @@ -58,7 +58,7 @@ sub new { } else { return unless -x $git; } - $git = abs_path $git unless file_name_is_absolute $git; + $git = canonpath abs_path $git; my $conf = 'App::Rgit::Config::Default'; eval "require $conf; 1" or Carp::confess("Couldn't load $conf: $@"); diff --git a/lib/App/Rgit/Repository.pm b/lib/App/Rgit/Repository.pm index f859f8f..0ca5e94 100644 --- a/lib/App/Rgit/Repository.pm +++ b/lib/App/Rgit/Repository.pm @@ -3,8 +3,8 @@ package App::Rgit::Repository; use strict; use warnings; -use Cwd qw/cwd abs_path/; -use File::Spec::Functions qw/canonpath catdir splitdir abs2rel file_name_is_absolute/; +use Cwd qw/cwd abs_path/; +use File::Spec::Functions qw/canonpath catdir splitdir abs2rel/; use POSIX qw/WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG SIGINT SIGQUIT/; BEGIN { @@ -48,9 +48,12 @@ sub new { my %args = @_; my $dir = $args{dir}; - $dir = abs_path $dir if defined $dir and not file_name_is_absolute $dir; - $dir = cwd unless defined $dir; - $dir = canonpath $dir; + if (defined $dir) { + $dir = abs_path $dir; + } else { + $dir = cwd; + } + $dir = canonpath $dir; my ($repo, $bare, $name, $work); if ($args{fake}) { diff --git a/t/20-each.t b/t/20-each.t index aa978cd..a3a26e5 100644 --- a/t/20-each.t +++ b/t/20-each.t @@ -4,7 +4,7 @@ use strict; use warnings; use Cwd qw/cwd abs_path/; -use File::Spec::Functions qw/curdir catdir catfile/; +use File::Spec::Functions qw/catdir catfile/; use File::Temp qw/tempfile tempdir/; use Test::More; @@ -129,7 +129,7 @@ sub try { ); my $ar = App::Rgit->new( - git => catfile(curdir, qw/t bin git/), + git => 't/bin/git', root => $tmpdir, cmd => $cmd, args => [ abs_path($filename), $cmd, qw/%n %g %w %b %G %W %B %R %%n %x/ ], diff --git a/t/21-once.t b/t/21-once.t index 93a184c..46c6975 100644 --- a/t/21-once.t +++ b/t/21-once.t @@ -25,7 +25,7 @@ my @expected = ( ); local $ENV{GIT_DIR} = 't'; -local $ENV{GIT_EXEC_PATH} = abs_path('t/bin/git'); +local $ENV{GIT_EXEC_PATH} = 't/bin/git'; for my $cmd (qw/daemon gui help init version/) { my ($fh, $filename) = tempfile(UNLINK => 1);