MCPcopy
hub / github.com/21st-dev/1code / gitCheckoutFiles

Function gitCheckoutFiles

src/main/lib/git/security/git-commands.ts:88–106  ·  view source on GitHub ↗
(
	worktreePath: string,
	filePaths: string[],
)

Source from the content-addressed store, hash-verified

86 * avoiding multiple sequential git calls and lock conflicts.
87 */
88export 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.

Callers 1

createStagingRouterFunction · 0.90

Calls 4

assertRegisteredWorktreeFunction · 0.90
assertValidGitPathFunction · 0.90
createGitFunction · 0.90
withLockRetryFunction · 0.90

Tested by

no test coverage detected