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)
| 504 | |
| 505 | // Background task, must call waitg.Done() once at end |
| 506 | func 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 |
| 548 | func pruneTaskGetRetainedStashed(gitscanner *lfs.GitScanner, retainChan chan string, errorChan chan error, waitg *sync.WaitGroup, sem *semaphore.Weighted) { |
no test coverage detected