Skip to content

Commit

Permalink
correct ** vs ./** behavior
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
isaacs committed Feb 27, 2023
1 parent cbd84c4 commit c3be35a
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/processor.ts
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit c3be35a

Please sign in to comment.