- 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 = $_;
- last;
- }
- }
- return unless defined $repo;
- @chunks = splitdir $repo;
- $last = pop @chunks;