From: Vincent Pit Date: Mon, 6 Oct 2008 15:57:53 +0000 (+0200) Subject: App::Rgit::Repository::new: split the dir to decide what we should try for the repo X-Git-Tag: v0.03~5 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Frgit.git;a=commitdiff_plain;h=d9762c0e9806aa955f290f36740496f0013747fd App::Rgit::Repository::new: split the dir to decide what we should try for the repo --- diff --git a/lib/App/Rgit/Repository.pm b/lib/App/Rgit/Repository.pm index 83241a1..c282ebd 100644 --- a/lib/App/Rgit/Repository.pm +++ b/lib/App/Rgit/Repository.pm @@ -47,8 +47,10 @@ sub new { $work = $dir; } else { my @tries = ($dir); - push @tries, "$dir.git" unless $dir =~ /\.git$/; - push @tries, catdir($dir, '.git') unless $dir eq '.git'; + my @chunks = splitdir $dir; + my $last = pop @chunks; + push @tries, "$dir.git" unless $last =~ /\.git$/; + push @tries, catdir($dir, '.git') unless $last eq '.git'; for (@tries) { if (-d $_ && -d "$_/refs" and -d "$_/objects" and -e "$_/HEAD") { $repo = $_; @@ -56,12 +58,12 @@ sub new { } } return unless defined $repo; - my @chunks = splitdir($repo); - my $last = pop @chunks; + @chunks = splitdir $repo; + $last = pop @chunks; if ($last eq '.git') { $bare = 0; $name = $chunks[-1]; - $work = catdir(@chunks); + $work = catdir @chunks; } else { $bare = 1; ($name) = $last =~ /(.*)\.git$/;