( worktreePath: string, filePaths: string[], )
| 86 | * avoiding multiple sequential git calls and lock conflicts. |
| 87 | */ |
| 88 | export async function gitCheckoutFiles( |
| 89 | worktreePath: string, |
| 90 | filePaths: string[], |
| 91 | ): Promise<void> { |
| 92 | assertRegisteredWorktree(worktreePath); |
| 93 | for (const filePath of filePaths) { |
| 94 | assertValidGitPath(filePath); |
| 95 | } |
| 96 | |
| 97 | if (filePaths.length === 0) return; |
| 98 | |
| 99 | const git = createGit(worktreePath); |
| 100 | |
| 101 | // Process in batches to avoid command line length limits |
| 102 | for (let i = 0; i < filePaths.length; i += BATCH_SIZE) { |
| 103 | const batch = filePaths.slice(i, i + BATCH_SIZE); |
| 104 | await withLockRetry(worktreePath, () => git.checkout(["--", ...batch])); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Stage a file for commit. |
no test coverage detected