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

Function pruneTaskGetRetainedWorktree

commands/command_prune.go:506–545  ·  view source on GitHub ↗

Background task, must call waitg.Done() once at end

(gitscanner *lfs.GitScanner, fetchconf lfs.FetchPruneConfig, retainChan chan string, errorChan chan error, waitg *sync.WaitGroup, sem *semaphore.Weighted)

Source from the content-addressed store, hash-verified

504
505// Background task, must call waitg.Done() once at end
506func pruneTaskGetRetainedWorktree(gitscanner *lfs.GitScanner, fetchconf lfs.FetchPruneConfig, retainChan chan string, errorChan chan error, waitg *sync.WaitGroup, sem *semaphore.Weighted) {
507 defer waitg.Done()
508
509 // Retain other worktree HEADs too
510 // Working copy, branch & maybe commit is different but repo is shared
511 allWorktrees, err := git.GetAllWorktrees(cfg.LocalGitStorageDir())
512 if err != nil {
513 errorChan <- err
514 return
515 }
516 // Don't repeat any commits, worktrees are always on their own branches but
517 // may point to the same commit
518 commits := tools.NewStringSet()
519
520 if !fetchconf.PruneForce {
521 // current HEAD is done elsewhere
522 headref, err := git.CurrentRef()
523 if err != nil {
524 errorChan <- err
525 return
526 }
527
528 commits.Add(headref.Sha)
529 }
530
531 for _, worktree := range allWorktrees {
532 if !fetchconf.PruneForce && commits.Add(worktree.Ref.Sha) {
533 // Worktree is on a different commit
534 waitg.Add(1)
535 // Don't need to 'cd' to worktree since we share same repo
536 go pruneTaskGetRetainedAtRef(gitscanner, worktree.Ref.Sha, retainChan, errorChan, waitg, sem)
537 }
538
539 if !worktree.Prunable {
540 // Always scan the index of the worktree if it exists
541 waitg.Add(1)
542 go pruneTaskGetRetainedIndex(gitscanner, worktree.Ref.Sha, worktree.Dir, retainChan, errorChan, waitg, sem)
543 }
544 }
545}
546
547// Background task, must call waitg.Done() once at end
548func pruneTaskGetRetainedStashed(gitscanner *lfs.GitScanner, retainChan chan string, errorChan chan error, waitg *sync.WaitGroup, sem *semaphore.Weighted) {

Callers 1

pruneFunction · 0.85

Calls 9

AddMethod · 0.95
GetAllWorktreesFunction · 0.92
NewStringSetFunction · 0.92
CurrentRefFunction · 0.92
LocalGitStorageDirMethod · 0.80
AddMethod · 0.65
DoneMethod · 0.45

Tested by

no test coverage detected