$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 = $_;
}
}
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$/;