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/;
=head1 VERSION
-Version 0.01
+Version 0.02
=cut
-our $VERSION = '0.01';
+our $VERSION = '0.02';
=head1 DESCRIPTION
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$/;
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;