X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Frgit.git;a=blobdiff_plain;f=lib%2FApp%2FRgit%2FRepository.pm;h=83241a15d941d0c9fb3d13ca1a38b8c2ecc321ea;hp=5ef1553032909949e1baee4867c998d47fdcf0c3;hb=a478eb47772af0e18b0b557f7830de989e7cb44d;hpb=4c6f2bc56bc50a662b2c2625bcc012d4757f9abf diff --git a/lib/App/Rgit/Repository.pm b/lib/App/Rgit/Repository.pm index 5ef1553..83241a1 100644 --- a/lib/App/Rgit/Repository.pm +++ b/lib/App/Rgit/Repository.pm @@ -4,7 +4,7 @@ use strict; use warnings; use Cwd qw/cwd abs_path/; -use File::Spec::Functions qw/catdir splitdir abs2rel/; +use File::Spec::Functions qw/catdir splitdir abs2rel file_name_is_absolute/; use Object::Tiny qw/fake repo bare name work/; @@ -40,11 +40,11 @@ If the C option is passed, C<$dir> isn't checked to be a valid C repo sub new { my ($class, %args) = &validate; my $dir = $args{dir}; - $dir = abs_path $dir if defined $dir; + $dir = abs_path $dir if defined $dir and not file_name_is_absolute $dir; $dir = cwd unless defined $dir; my ($repo, $bare, $name, $work); if ($args{fake}) { - $repo = $dir; + $work = $dir; } else { my @tries = ($dir); push @tries, "$dir.git" unless $dir =~ /\.git$/; @@ -85,9 +85,9 @@ C into the repository's directory. sub chdir { my $self = shift; - my $repo = $self->repo; - chdir $repo or do { - warn "Couldn't chdir into $repo: $!"; + my $dir = $self->work; + chdir $dir or do { + warn "Couldn't chdir into $dir: $!"; return; }; return 1;