Since every non-worktree git repo has an `objects' directory, we
can quickly stat(2) to check for its presence and avoid an
expensive process spawn. This should be the common case on
servers since it's rare to use worktrees on servers for
coderepos (or inboxes).
sub git_path ($$) {
my ($self, $path) = @_;
$self->{-git_path}->{$path} //= do {
- my $d = "$self->{git_dir}/$path";
- if (-e $d) {
- $d;
+ my $d = $self->{git_dir};
+ my $f = "$d/$path";
+ if (-d "$d/objects") {
+ $f;
} else {
local $/ = "\n";
my $rdr = { 2 => \my $err };
chomp $s;
# git prior to 2.5.0 did not understand --git-path
- $s eq "--git-path\n$path" ? $d : $s;
+ $s eq "--git-path\n$path" ? $f : $s;
}
};
}