MCPcopy
hub / github.com/git-lfs/git-lfs / fastWalkWithExcludeFiles

Function fastWalkWithExcludeFiles

tools/filetools.go:292–324  ·  view source on GitHub ↗

fastWalkWithExcludeFiles walks the contents of a dir, respecting include/exclude patterns. rootDir - Absolute path to the top of the repository working directory

(rootDir string)

Source from the content-addressed store, hash-verified

290//
291// rootDir - Absolute path to the top of the repository working directory
292func fastWalkWithExcludeFiles(rootDir string) *fastWalker {
293 excludePaths := []filepathfilter.Pattern{
294 filepathfilter.NewPattern(".git", filepathfilter.GitIgnore),
295 filepathfilter.NewPattern("**/.git", filepathfilter.GitIgnore),
296 }
297
298 limit, _ := strconv.Atoi(os.Getenv("LFS_FASTWALK_LIMIT"))
299 if limit < 1 {
300 limit = runtime.GOMAXPROCS(-1) * 20
301 }
302
303 c := int32(0)
304 w := &fastWalker{
305 rootDir: rootDir,
306 limit: int32(limit),
307 cur: &c,
308 ch: make(chan fastWalkInfo, 256),
309 wg: &sync.WaitGroup{},
310 }
311
312 go func() {
313 defer w.Wait()
314
315 dirFi, err := os.Stat(w.rootDir)
316 if err != nil {
317 w.ch <- fastWalkInfo{Err: err}
318 return
319 }
320
321 w.Walk(true, "", dirFi, excludePaths)
322 }()
323 return w
324}
325
326// Walk is the main recursive implementation of fast walk. Sends the file/dir
327// and any contents to the channel so long as it passes the include/exclude

Callers 2

TestFastWalkBasicFunction · 0.85
FastWalkDirFunction · 0.85

Calls 3

WaitMethod · 0.95
WalkMethod · 0.95
NewPatternFunction · 0.92

Tested by 1

TestFastWalkBasicFunction · 0.68