From c3be35ae03314f4d74450eee6d15b6e4d85f1816 Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 24 Feb 2023 22:36:43 -0800 Subject: [PATCH] correct ** vs ./** behavior The previous implementation was only valid prior to minimatch preserving the leading portions before an initial **, resulting in some incorrect follows in some cases. Now that we can determine whether the ** leads the pattern, the corrected behavior is more easily implemented. --- src/processor.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/processor.ts b/src/processor.ts index 30fcdff3..cca4a855 100644 --- a/src/processor.ts +++ b/src/processor.ts @@ -146,12 +146,14 @@ export class Processor { // if it's a symlink, but we didn't get here by way of a // globstar match (meaning it's the first time THIS globstar // has traversed a symlink), then we follow it. Otherwise, stop. - if ( - !t.isSymbolicLink() || - this.follow || - pattern.followGlobstar() - ) { + if (this.follow || !t.isSymbolicLink()) { this.subwalks.add(t, pattern) + } else if ( + t.isSymbolicLink() && + pattern.followGlobstar() && + rest + ) { + this.subwalks.add(t, rest) } const rp = rest?.pattern() const rrest = rest?.rest() @@ -219,12 +221,6 @@ export class Processor { if (!pattern.hasMore()) { this.matches.add(e, absolute, false) } - // record that this globstar is following a symlink, so we - // can know to stop traversing when we encounter it again - // in processPatterns. - if (e.isSymbolicLink()) { - pattern.followGlobstar() - } if (e.canReaddir()) { this.subwalks.add(e, pattern) }