From 65bc3fa874924d922c7910e84275ec3c766293cd Mon Sep 17 00:00:00 2001 From: Diab Jerius Date: Sun, 22 Jan 2023 14:23:20 -0500 Subject: [PATCH] stop upwards search if find .hg as well as .git directory --- bin/plx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/plx b/bin/plx index b4a5437..267a2a7 100644 --- a/bin/plx +++ b/bin/plx @@ -64,8 +64,8 @@ sub _build_layout_base_dir { while (@parts > 1) { # go back to one step before root at most $cand = $fs->catdir(@parts); return $cand if -d $fs->catdir($cand, '.plx'); - if (-d $fs->catdir($cand, '.git')) { # don't escape current repository - $reason = ' due to .git directory'; + if ( (my $vcs) = grep { -d $fs->catdir($cand, $_) } '.git', '.hg' ) { # don't escape current repository + $reason = " due to $vcs directory"; last; } pop @parts; @@ -921,7 +921,7 @@ Identical to C<--init> but creates no default configs except for C. Without arguments, shows the selected base dir - C finds this by checking for a C<.plx> directory in the current directory, and if not tries the parent directory, recursively. The search stops either when C finds -a C<.git> directory, to avoid accidentally escaping a project repository, or +a C<.git> or C<.hg> directory, to avoid accidentally escaping a project repository, or at the last directory before the root - i.e. C will test C but not C.