MCPcopy Create free account
hub / github.com/anthropics/claude-code / fetchFileHunks

Function fetchFileHunks

mods/diff/hooks/git/fetch-file-hunks.ts:19–41  ·  view source on GitHub ↗
(
  run: Types.GitRun,
  data: Types.DiffData,
  file: Types.FileStat,
)

Source from the content-addressed store, hash-verified

17 * @returns the parsed body, or null when git failed
18 */
19export async function fetchFileHunks(
20 run: Types.GitRun,
21 data: Types.DiffData,
22 file: Types.FileStat,
23): Promise<Types.FileHunks | null> {
24 const hasNoBody =
25 file.isUntracked || file.isBinary || data.stalePaths.includes(file.path)
26
27 if (hasNoBody) {
28 return EMPTY_FILE_HUNKS
29 }
30
31 const { exitCode, stdout } = await run([
32 '--literal-pathspecs',
33 ...Argv.DIFF_LEADING_ARGS,
34 data.baseRef,
35 '--',
36 ...(file.renamedFrom === null ? [] : [file.renamedFrom]),
37 file.path,
38 ])
39
40 return exitCode === 0 ? GitParse.parseFileDiff(stdout) : null
41}

Callers 1

gitBackendOfFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected