@gitkraken/core-gitlens 0.38.1 → 0.38.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -1
- package/dist/git/parsers/diffParser.d.ts +25 -0
- package/dist/git/parsers/diffParser.js +169 -23
- package/dist/git/parsers/diffParser.js.map +1 -1
- package/dist/git/service.d.ts +4 -1
- package/dist/git/service.js +6 -2
- package/dist/git/service.js.map +1 -1
- package/dist/git/watching/unwatchedCacheValidator.d.ts +26 -4
- package/dist/git/watching/unwatchedCacheValidator.js +110 -10
- package/dist/git/watching/unwatchedCacheValidator.js.map +1 -1
- package/dist/git-cli/exec/statWorkers.d.ts +50 -0
- package/dist/git-cli/exec/statWorkers.js +194 -0
- package/dist/git-cli/exec/statWorkers.js.map +1 -0
- package/dist/git-cli/parsers/blameParser.js +25 -5
- package/dist/git-cli/parsers/blameParser.js.map +1 -1
- package/dist/git-cli/parsers/logParser.js +28 -18
- package/dist/git-cli/parsers/logParser.js.map +1 -1
- package/dist/git-cli/parsers/statusParser.d.ts +5 -1
- package/dist/git-cli/parsers/statusParser.js +17 -6
- package/dist/git-cli/parsers/statusParser.js.map +1 -1
- package/dist/git-cli/parsers/treeParser.js +5 -3
- package/dist/git-cli/parsers/treeParser.js.map +1 -1
- package/dist/git-cli/parsers/worktreeParser.js +1 -41
- package/dist/git-cli/parsers/worktreeParser.js.map +1 -1
- package/dist/git-cli/providers/revision.js +3 -3
- package/dist/git-cli/providers/revision.js.map +1 -1
- package/dist/git-cli/providers/status.js +1 -0
- package/dist/git-cli/providers/status.js.map +1 -1
- package/dist/git-cli/service.d.ts +7 -4
- package/dist/git-cli/service.js +14 -17
- package/dist/git-cli/service.js.map +1 -1
- package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts +2 -0
- package/dist/plus/integrations/authentication/configuredIntegrationService.js +23 -1
- package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
- package/dist/plus/integrations/authentication/models.d.ts +1 -0
- package/dist/plus/integrations/authentication/models.js.map +1 -1
- package/dist/plus/integrations/authentication/observedAuthenticationProvider.js +4 -1
- package/dist/plus/integrations/authentication/observedAuthenticationProvider.js.map +1 -1
- package/dist/plus/integrations/integrationService.js +7 -1
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/models/integration.d.ts +1 -0
- package/dist/plus/integrations/models/integration.js +8 -0
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/models/issuesIntegration.d.ts +5 -0
- package/dist/plus/integrations/models/issuesIntegration.js +33 -1
- package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
- package/dist/plus/integrations/providers/jira.d.ts +3 -2
- package/dist/plus/integrations/providers/jira.js +36 -17
- package/dist/plus/integrations/providers/jira.js.map +1 -1
- package/dist/plus/integrations/providers/linear.d.ts +1 -0
- package/dist/plus/integrations/providers/linear.js +40 -17
- package/dist/plus/integrations/providers/linear.js.map +1 -1
- package/dist/plus/integrations/providers/utils/discoveryCache.d.ts +6 -3
- package/dist/plus/integrations/providers/utils/discoveryCache.js +12 -6
- package/dist/plus/integrations/providers/utils/discoveryCache.js.map +1 -1
- package/dist/utils/env/node/exec.js +24 -22
- package/dist/utils/env/node/exec.js.map +1 -1
- package/dist/utils/string.d.ts +15 -0
- package/dist/utils/string.js +61 -1
- package/dist/utils/string.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logParser.js","names":[],"sources":["../../../../git-cli/src/parsers/logParser.ts"],"sourcesContent":["import type { GitFileIndexStatus } from '@gitlens/git/models/fileStatus.js';\nimport { diffHunkRegex, diffRegex } from '@gitlens/git/parsers/diffParser.js';\nimport { joinPaths, normalizePath } from '@gitlens/utils/path.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport { flattenString, iterateAsyncByDelimiter, iterateByDelimiter } from '@gitlens/utils/string.js';\nimport type { ExtractAll } from '@gitlens/utils/types.js';\n\nconst commitsMapping = {\n\tsha: '%H',\n\tauthor: '%aN',\n\tauthorEmail: '%aE',\n\tauthorDate: '%at',\n\tcommitter: '%cN',\n\tcommitterEmail: '%cE',\n\tcommitterDate: '%ct',\n\tparents: '%P',\n\ttips: '%D',\n\tmessage: '%B',\n};\n\nexport type CommitsLogParser = LogParser<typeof commitsMapping>;\nlet _commitsParser: CommitsLogParser | undefined;\nexport type CommitsWithFilesLogParser = LogParserWithFilesAndStats<typeof commitsMapping>;\nlet _commitsWithFilesParser: CommitsWithFilesLogParser | undefined;\nexport type CommitsInFileRangeLogParser = LogParserWithFiles<typeof commitsMapping>;\nlet _commitsInFileRangeParser: CommitsInFileRangeLogParser | undefined;\n\nexport type ParsedCommit =\n\t| LogParsedEntry<typeof commitsMapping>\n\t| LogParsedEntryWithFiles<typeof commitsMapping>\n\t| LogParsedEntryWithFilesAndStats<typeof commitsMapping>;\n\nexport function getCommitsLogParser(\n\tincludeFiles: boolean,\n\tinFileRange?: boolean,\n): CommitsLogParser | CommitsWithFilesLogParser | CommitsInFileRangeLogParser {\n\tif (inFileRange) {\n\t\t_commitsInFileRangeParser ??= createLogParserWithPatch(commitsMapping);\n\t\treturn _commitsInFileRangeParser;\n\t}\n\n\tif (includeFiles) {\n\t\t_commitsWithFilesParser ??= createLogParserWithFilesAndStats(commitsMapping);\n\t\treturn _commitsWithFilesParser;\n\t}\n\n\t_commitsParser ??= createLogParser(commitsMapping);\n\treturn _commitsParser;\n}\n\nconst contributorsMapping = { sha: '%H', author: '%aN', email: '%aE', date: '%at', message: '%B' };\n\ntype ContributorsLogParser = LogParser<typeof contributorsMapping>;\nlet _contributorsParser: ContributorsLogParser | undefined;\ntype ContributorsWithStatsLogParser = LogParserWithStats<typeof contributorsMapping>;\nlet _contributorsWithStatsParser: ContributorsWithStatsLogParser | undefined;\n\nexport function getContributorsLogParser(stats?: boolean): ContributorsLogParser | ContributorsWithStatsLogParser {\n\tif (stats) {\n\t\t_contributorsWithStatsParser ??= createLogParserWithStats(contributorsMapping);\n\t\treturn _contributorsWithStatsParser;\n\t}\n\n\t_contributorsParser ??= createLogParser(contributorsMapping);\n\treturn _contributorsParser;\n}\n\nconst graphMapping = {\n\tsha: '%H',\n\tauthor: '%aN',\n\tauthorEmail: '%aE',\n\tauthorDate: '%at',\n\tcommitterDate: '%ct',\n\tparents: '%P',\n\ttips: '%D',\n\tmessage: '%B',\n};\n\nexport type GraphLogParser = LogParser<typeof graphMapping>;\nlet _graphParser: GraphLogParser | undefined;\ntype GraphWithStatsLogParser = LogParserWithStats<typeof graphMapping>;\nlet _graphWithStatsParser: GraphWithStatsLogParser | undefined;\n\n/**\n * Prints `tips` as full refnames (`HEAD -> refs/heads/main`, `refs/remotes/origin/main`, `tag: refs/tags/v1`), whatever\n * `log.decorate` says, since short names can't tell a local branch from a remote-tracking ref of the same name\n */\nexport function getGraphParser(stats?: boolean): GraphLogParser | GraphWithStatsLogParser {\n\tif (stats) {\n\t\tif (_graphWithStatsParser == null) {\n\t\t\t_graphWithStatsParser = createLogParserWithStats(graphMapping);\n\t\t\t_graphWithStatsParser.arguments.push('--decorate=full');\n\t\t}\n\t\treturn _graphWithStatsParser;\n\t}\n\n\tif (_graphParser == null) {\n\t\t_graphParser = createLogParser(graphMapping);\n\t\t_graphParser.arguments.push('--decorate=full');\n\t}\n\treturn _graphParser;\n}\n\ntype ShaLogParser = Parser<string>;\nlet _shaParser: ShaLogParser | undefined;\n\nexport function getShaLogParser(): ShaLogParser {\n\t_shaParser ??= createLogParserSingle('%H');\n\treturn _shaParser;\n}\n\nconst shaAndDateMapping = { sha: '%H', authorDate: '%at', committerDate: '%ct' };\nconst shaAndDateAndTipsMapping = { sha: '%H', authorDate: '%at', committerDate: '%ct', tips: '%D' };\n\ntype ShaAndDatesLogParser = LogParser<typeof shaAndDateMapping & { tips?: string }>;\nlet _shaAndDatesParser: ShaAndDatesLogParser | undefined;\ntype ShaAndDatesAndTipsLogParser = LogParser<typeof shaAndDateAndTipsMapping>;\nlet _shaAndDatesAndTipsParser: ShaAndDatesAndTipsLogParser | undefined;\n\nexport function getShaAndDatesLogParser(includeTips?: boolean): ShaAndDatesLogParser | ShaAndDatesAndTipsLogParser {\n\tif (includeTips) {\n\t\t_shaAndDatesAndTipsParser ??= createLogParser(shaAndDateAndTipsMapping);\n\t\treturn _shaAndDatesAndTipsParser;\n\t}\n\n\t_shaAndDatesParser ??= createLogParser(shaAndDateMapping);\n\treturn _shaAndDatesParser;\n}\n\ntype ShaAndDatesWithFilesLogParser = LogParserWithFiles<typeof shaAndDateMapping & { tips?: string }>;\nlet _shaAndDatesWithFilesParser: ShaAndDatesWithFilesLogParser | undefined;\n\ntype ShaAndDatesAndTipsWithFilesLogParser = LogParserWithFiles<typeof shaAndDateAndTipsMapping>;\nlet _shaAndDatesAndTipsWithFilesParser: ShaAndDatesAndTipsWithFilesLogParser | undefined;\n\nexport function getShaAndDatesWithFilesLogParser(\n\tincludeTips?: boolean,\n): ShaAndDatesWithFilesLogParser | ShaAndDatesAndTipsWithFilesLogParser {\n\tif (includeTips) {\n\t\t_shaAndDatesAndTipsWithFilesParser ??= createLogParserWithFiles(shaAndDateAndTipsMapping);\n\t\treturn _shaAndDatesAndTipsWithFilesParser;\n\t}\n\n\t_shaAndDatesWithFilesParser ??= createLogParserWithFiles(shaAndDateMapping);\n\treturn _shaAndDatesWithFilesParser;\n}\n\nconst shaMapping = { sha: '%H' };\n\ntype ShaAndFilesAndStatsLogParser = LogParserWithFilesAndStats<typeof shaMapping>;\nlet _shaAndFilesAndStatsParser: ShaAndFilesAndStatsLogParser | undefined;\n\nexport function getShaAndFilesAndStatsLogParser(): ShaAndFilesAndStatsLogParser {\n\t_shaAndFilesAndStatsParser ??= createLogParserWithFilesAndStats(shaMapping);\n\treturn _shaAndFilesAndStatsParser;\n}\n\ntype ShaAndFileRangeLogParser = LogParserWithFiles<typeof shaMapping>;\nlet _shaAndFileRangeParser: ShaAndFileRangeLogParser | undefined;\n\nexport function getShaAndFileRangeLogParser(): ShaAndFileRangeLogParser {\n\t_shaAndFileRangeParser ??= createLogParserWithPatch(shaMapping);\n\treturn _shaAndFileRangeParser;\n}\n\ntype ShaAndFileSummaryLogParser = LogParserWithFileSummary<typeof shaMapping>;\nlet _shaAndFileSummaryParser: ShaAndFileSummaryLogParser | undefined;\n\nexport function getShaAndFileSummaryLogParser(): ShaAndFileSummaryLogParser {\n\t_shaAndFileSummaryParser ??= createLogParserWithFileSummary(shaMapping);\n\treturn _shaAndFileSummaryParser;\n}\n\ntype ShaAndStatsLogParser = LogParserWithStats<typeof shaMapping>;\nlet _shaAndStatsParser: ShaAndStatsLogParser | undefined;\n\nexport function getShaAndStatsLogParser(): ShaAndStatsLogParser {\n\t_shaAndStatsParser ??= createLogParserWithStats(shaMapping);\n\treturn _shaAndStatsParser;\n}\n\nconst stashMapping = {\n\tsha: '%H',\n\tauthorDate: '%at',\n\tcommittedDate: '%ct',\n\tparents: '%P',\n\tstashName: '%gd',\n\tsummary: '%gs',\n\t// %s (commit subject) is git's authoritative `On <branch>: …` / `WIP on <branch>: …` record,\n\t// present even when the reflog message (%gs) was customized (autostash, `git stash store -m`).\n\t// Used downstream to extract `stashOnRef` reliably.\n\tcommitSubject: '%s',\n};\n\ntype StashLogParser = LogParser<typeof stashMapping>;\nlet _stashParser: StashLogParser | undefined;\ntype StashLogParserWithFiles = LogParserWithFilesAndStats<typeof stashMapping>;\nlet _stashParserWithFiles: StashLogParserWithFiles | undefined;\n\nexport type ParsedStash = LogParsedEntry<typeof stashMapping>;\nexport type ParsedStashWithFiles = LogParsedEntryWithFilesAndStats<typeof stashMapping>;\n\nexport function getStashLogParser(includeFiles?: false): StashLogParser;\nexport function getStashLogParser(includeFiles: true): StashLogParserWithFiles;\nexport function getStashLogParser(includeFiles?: boolean): StashLogParser | StashLogParserWithFiles;\nexport function getStashLogParser(includeFiles?: boolean): StashLogParser | StashLogParserWithFiles {\n\tif (includeFiles) {\n\t\t_stashParserWithFiles ??= createLogParserWithFilesAndStats(stashMapping);\n\t\treturn _stashParserWithFiles;\n\t}\n\n\t_stashParser ??= createLogParser(stashMapping);\n\treturn _stashParser;\n}\n\ntype StashFilesOnlyLogParser = LogParserWithFilesAndStats<void>;\nlet _stashFilesOnlyParser: StashFilesOnlyLogParser | undefined;\n\nexport function getStashFilesOnlyLogParser(): StashFilesOnlyLogParser {\n\t_stashFilesOnlyParser ??= createLogParserWithFilesAndStats();\n\treturn _stashFilesOnlyParser;\n}\n\n// Parser types\nexport type Parser<T> = {\n\targuments: string[];\n\tseparators: { record: string; field: string };\n\tparse: (data: string | Iterable<string> | undefined) => Generator<T> | Iterable<T>;\n\tparseAsync?: never;\n};\nexport type AsyncParser<T> = {\n\targuments: string[];\n\tseparators: { record: string; field: string };\n\tparse: (data: string | Iterable<string> | undefined) => Generator<T> | Iterable<T>;\n\tparseAsync: (stream: AsyncGenerator<string>) => AsyncGenerator<T>;\n\t/**\n\t * Like `parseAsync` but yields one ARRAY of entries per stream chunk, scanning each chunk\n\t * synchronously with plain `indexOf` (no per-field iterator machinery). Bulk consumers (the\n\t * graph walk) avoid two promise hops per record — thousands of awaited yields collapse to one\n\t * per chunk. Only the plain parser implements it; per-record `parseAsync` remains the\n\t * general-purpose path.\n\t */\n\tparseAsyncBatched?: (stream: AsyncGenerator<string>) => AsyncGenerator<T[]>;\n};\n\nexport type LogParser<T> = AsyncParser<LogParsedEntry<T>>;\ntype LogParserWithFiles<T> = AsyncParser<LogParsedEntryWithFiles<T>>;\ntype LogParserWithFilesAndStats<T> = AsyncParser<LogParsedEntryWithFilesAndStats<T>>;\ntype LogParserWithFileSummary<T> = Parser<LogParsedEntryWithFiles<T>>;\ntype LogParserWithStats<T> = AsyncParser<LogParsedEntryWithStats<T>>;\n\n// Parsed entry types\ntype LogParsedEntry<T> = { [K in keyof T]: string } & { files?: never; stats?: never };\ntype LogParsedEntryWithFiles<T> = { [K in keyof T]: string } & { files: LogParsedFile[]; stats?: never };\ntype LogParsedEntryWithFilesAndStats<T> = { [K in keyof T]: string } & {\n\tfiles: LogParsedFileWithStats[];\n\tstats: LogParsedStatsWithFilesStats;\n};\ntype LogParsedEntryWithStats<T> = { [K in keyof T]: string } & { stats: LogParsedStats };\n\n// Parsed types\nexport interface LogParsedFile {\n\tstatus?: string;\n\tpath: string;\n\toriginalPath?: string;\n\tadditions?: never;\n\tdeletions?: never;\n\trange?: LogParsedRange;\n\toriginalRange?: LogParsedRange;\n\t/** Git file mode (e.g., 100644=regular, 100755=executable, 120000=symlink, 160000=submodule) */\n\tmode?: string;\n\t/** For submodule entries (mode 160000), the commit SHA the submodule points to */\n\toid?: string;\n\t/** For submodule entries (mode 160000), the previous commit SHA */\n\tpreviousOid?: string;\n}\ntype LogParsedFileWithStats = Omit<LogParsedFile, 'additions' | 'deletions'> & {\n\tadditions: number;\n\tdeletions: number;\n};\ninterface LogParsedRange {\n\tstartLine: number;\n\tendLine: number;\n}\ninterface LogParsedStats {\n\tfiles: number;\n\tadditions: number;\n\tdeletions: number;\n}\ninterface LogParsedStatsWithFilesStats {\n\tfiles: { added: number; changed: number; deleted: number };\n\tadditions: number;\n\tdeletions: number;\n}\n\nconst recordSep = '\\x1E'; // ASCII Record Separator character\nconst recordFormatSep = '%x1E';\nconst fieldSep = '\\x1D'; // ASCII Group Separator character\nconst fieldFormatSep = '%x1D';\n\n// `push(...items)` throws a RangeError once `items` is large enough to overflow the call stack\nfunction appendAll<T>(target: T[], items: readonly T[]): void {\n\tfor (const item of items) {\n\t\ttarget.push(item);\n\t}\n}\n\n// A complete record terminates every mapped field with a field separator — a cancelled/early-closed\n// stream resolves cleanly with a truncated tail missing at least the final terminator.\nfunction isCompleteRecord(record: string, requiredFields: number): boolean {\n\tlet count = 0;\n\tlet index = -1;\n\twhile (count < requiredFields) {\n\t\tindex = record.indexOf(fieldSep, index + 1);\n\t\tif (index === -1) return false;\n\n\t\tcount++;\n\t}\n\treturn true;\n}\n\nexport function createLogParser<T extends Record<string, string>>(mapping: ExtractAll<T, string>): LogParser<T> {\n\tlet format = recordFormatSep;\n\tconst keys: (keyof ExtractAll<T, string>)[] = [];\n\tfor (const key in mapping) {\n\t\tkeys.push(key);\n\t\tformat += `${mapping[key]}${fieldFormatSep}`;\n\t}\n\n\tconst args = [`--format=${format}`];\n\n\tfunction* parse(data: string | Iterable<string> | undefined): Generator<LogParsedEntry<T>> {\n\t\tusing sw = maybeStopWatch('Git.LogParser.parse', { log: { onlyExit: true, level: 'debug' } });\n\n\t\tif (!data) {\n\t\t\tsw?.stop({ suffix: ` no data` });\n\t\t\treturn;\n\t\t}\n\n\t\tconst records = iterateByDelimiter(data, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntry<T>;\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor (const record of records) {\n\t\t\tif (!record.length) continue;\n\n\t\t\tentry = {} as unknown as LogParsedEntry<T>;\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\t\t\t\tif (fieldCount >= keys.length) continue;\n\n\t\t\t\tcount++;\n\t\t\t\tentry[keys[fieldCount++]] = field.value as T[keyof T];\n\t\t\t}\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\tasync function* parseAsync(stream: AsyncGenerator<string>): AsyncGenerator<LogParsedEntry<T>> {\n\t\tusing sw = maybeStopWatch('Git.LogParser.parseAsync', { log: { onlyExit: true, level: 'debug' } });\n\n\t\tconst records = iterateAsyncByDelimiter(stream, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntry<T>;\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor await (const record of records) {\n\t\t\tif (!record.length) continue;\n\t\t\t// Drop a truncated tail (cancelled/early-closed stream) instead of yielding undefined/partial fields.\n\t\t\tif (!isCompleteRecord(record, keys.length)) continue;\n\n\t\t\tentry = {} as unknown as LogParsedEntry<T>;\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\t\t\t\tif (fieldCount >= keys.length) continue;\n\n\t\t\t\tcount++;\n\t\t\t\tentry[keys[fieldCount++]] = field.value as T[keyof T];\n\t\t\t}\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\t// Builds one entry from a complete record with a plain `indexOf` walk. Matches `parseAsync`'s\n\t// semantics exactly: fields beyond the mapping are ignored, and every mapped field is\n\t// terminated by a field separator (the format string appends one after each field).\n\tfunction parseRecord(record: string): LogParsedEntry<T> {\n\t\t// Fields sliced out of the record become long-lived (graph rows); flatten the record so they\n\t\t// pin a record-sized copy rather than the full walk output the record was sliced from.\n\t\trecord = flattenString(record);\n\t\tconst entry = {} as unknown as LogParsedEntry<T>;\n\t\tlet start = 0;\n\t\tfor (const key of keys) {\n\t\t\tconst end = record.indexOf(fieldSep, start);\n\t\t\tif (end === -1) break;\n\n\t\t\tentry[key] = record.substring(start, end) as T[keyof T];\n\t\t\tstart = end + 1;\n\t\t}\n\t\treturn entry;\n\t}\n\n\tasync function* parseAsyncBatched(stream: AsyncGenerator<string>): AsyncGenerator<LogParsedEntry<T>[]> {\n\t\tusing sw = maybeStopWatch('Git.LogParser.parseAsyncBatched', { log: { onlyExit: true, level: 'debug' } });\n\n\t\tlet count = 0;\n\t\tlet buffer = '';\n\t\tfor await (const chunk of stream) {\n\t\t\tbuffer += chunk;\n\n\t\t\tlet batch: LogParsedEntry<T>[] | undefined;\n\t\t\tlet start = 0;\n\t\t\twhile (true) {\n\t\t\t\tconst end = buffer.indexOf(recordSep, start);\n\t\t\t\tif (end === -1) break;\n\n\t\t\t\tif (end > start) {\n\t\t\t\t\t(batch ??= []).push(parseRecord(buffer.substring(start, end)));\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\tstart = end + 1;\n\t\t\t}\n\t\t\tif (start > 0) {\n\t\t\t\tbuffer = buffer.substring(start);\n\t\t\t}\n\t\t\tif (batch != null) {\n\t\t\t\tyield batch;\n\t\t\t}\n\t\t}\n\t\t// Trailing record (the stream doesn't end with a record separator); a truncated tail from a\n\t\t// cancelled/early-closed stream is missing a field terminator and must be dropped, not parsed.\n\t\tif (buffer.length > 0 && isCompleteRecord(buffer, keys.length)) {\n\t\t\tcount++;\n\t\t\tyield [parseRecord(buffer)];\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\treturn {\n\t\targuments: args,\n\t\tseparators: { record: recordSep, field: fieldSep },\n\t\tparse: parse,\n\t\tparseAsync: parseAsync,\n\t\tparseAsyncBatched: parseAsyncBatched,\n\t};\n}\n\nfunction createLogParserWithFilesAndStats(): LogParserWithFilesAndStats<void>;\nfunction createLogParserWithFilesAndStats<T extends Record<string, string>>(\n\tmapping: ExtractAll<T, string>,\n): LogParserWithFilesAndStats<T>;\nfunction createLogParserWithFilesAndStats<T extends Record<string, string> | void>(\n\tmapping?: ExtractAll<T, string>,\n): LogParserWithFilesAndStats<T> {\n\tlet format = recordFormatSep;\n\tconst keys: (keyof ExtractAll<T, string>)[] = [];\n\tif (mapping != null) {\n\t\tfor (const key in mapping) {\n\t\t\tkeys.push(key);\n\t\t\tformat += `${mapping[key]}${fieldFormatSep}`;\n\t\t}\n\t}\n\t// Use --raw instead of --summary to get accurate mode info for ALL files (not just creates/deletes)\n\t// This allows us to reliably detect submodules (mode 160000) even for modifications\n\tconst args = [`--format=${format}`, '--numstat', '--raw'];\n\n\tfunction parseFilesAndStats(content: string): LogParsedFileWithStats[] {\n\t\tconst files: LogParsedFileWithStats[] = [];\n\t\tif (!content?.length) return files;\n\n\t\t// Map to store info from --raw lines: path -> { mode, status, originalPath, oid?, previousOid? }\n\t\t// Raw format: :<old_mode> <new_mode> <old_sha> <new_sha> <status>[score]\\t<path>[\\t<new_path>]\n\t\tconst infoMap = new Map<\n\t\t\tstring,\n\t\t\t{ mode: string; status: string; originalPath?: string; oid?: string; previousOid?: string }\n\t\t>();\n\n\t\tlet startIndex: number;\n\t\tlet endIndex: number;\n\n\t\t// Single pass: --raw lines come first, then --numstat lines\n\t\tfor (const line of iterateByDelimiter(content, '\\n')) {\n\t\t\tif (!line) continue;\n\n\t\t\tif (line.charCodeAt(0) === 58 /* ':' */) {\n\t\t\t\t// --raw format: :<old_mode> <new_mode> <old_sha> <new_sha> <status>[score]\\t<path>[\\t<new_path>]\n\t\t\t\tconst tabIndex = line.indexOf('\\t');\n\t\t\t\tif (tabIndex === -1) continue;\n\n\t\t\t\t// Parse metadata using indexOf instead of split() to avoid array allocation\n\t\t\t\t// Format after ':': <old_mode> <new_mode> <old_sha> <new_sha> <status>[score]\n\n\t\t\t\t// Skip old_mode, find new_mode\n\t\t\t\tstartIndex = line.indexOf(' ') + 1;\n\t\t\t\tif (startIndex === 0) continue;\n\n\t\t\t\tendIndex = line.indexOf(' ', startIndex);\n\t\t\t\tif (endIndex === -1) continue;\n\n\t\t\t\tconst newMode = line.substring(startIndex, endIndex);\n\n\t\t\t\t// Parse old_sha and new_sha positions\n\t\t\t\tconst oldShaStart = endIndex + 1;\n\t\t\t\tconst oldShaEnd = line.indexOf(' ', oldShaStart);\n\t\t\t\tif (oldShaEnd === -1) continue;\n\n\t\t\t\tconst newShaStart = oldShaEnd + 1;\n\t\t\t\tconst newShaEnd = line.indexOf(' ', newShaStart);\n\t\t\t\tif (newShaEnd === -1) continue;\n\n\t\t\t\t// For submodules (mode 160000), capture the commit SHAs\n\t\t\t\tlet oid: string | undefined;\n\t\t\t\tlet previousOid: string | undefined;\n\t\t\t\tif (newMode === '160000') {\n\t\t\t\t\tpreviousOid = line.substring(oldShaStart, oldShaEnd);\n\t\t\t\t\toid = line.substring(newShaStart, newShaEnd);\n\t\t\t\t}\n\n\t\t\t\t// Status is first char after the last space\n\t\t\t\tstartIndex = newShaEnd;\n\t\t\t\tconst status = line.charAt(startIndex + 1);\n\n\t\t\t\t// Parse path(s) using indexOf instead of split\n\t\t\t\tconst pathPart = line.substring(tabIndex + 1);\n\t\t\t\tlet path: string;\n\t\t\t\tlet originalPath: string | undefined;\n\n\t\t\t\tconst pathTabIndex = pathPart.indexOf('\\t');\n\t\t\t\tif ((status === 'R' || status === 'C') && pathTabIndex !== -1) {\n\t\t\t\t\t// For renames/copies: old_path\\tnew_path\n\t\t\t\t\toriginalPath = pathPart.substring(0, pathTabIndex);\n\t\t\t\t\tpath = pathPart.substring(pathTabIndex + 1);\n\t\t\t\t} else {\n\t\t\t\t\tpath = pathPart;\n\t\t\t\t}\n\n\t\t\t\t// Trim to match parseCopyOrRename which trims renamed paths\n\t\t\t\tinfoMap.set(path.trim(), {\n\t\t\t\t\tmode: newMode,\n\t\t\t\t\tstatus: status,\n\t\t\t\t\toriginalPath: originalPath?.trim(),\n\t\t\t\t\toid: oid,\n\t\t\t\t\tpreviousOid: previousOid,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// --numstat format: <additions>\\t<deletions>\\t<path>\n\t\t\t\t// With renames: <additions>\\t<deletions>\\t{prefix/old => new/suffix}\n\t\t\t\tendIndex = line.indexOf('\\t');\n\t\t\t\tif (endIndex === -1) {\n\t\t\t\t\tdebugger;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst additions = line.substring(0, endIndex);\n\n\t\t\t\tstartIndex = endIndex + 1;\n\t\t\t\tendIndex = line.indexOf('\\t', startIndex);\n\t\t\t\tif (endIndex === -1) {\n\t\t\t\t\tdebugger;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst deletions = line.substring(startIndex, endIndex);\n\n\t\t\t\tlet path = line.substring(endIndex + 1);\n\t\t\t\tlet originalPath: string | undefined;\n\n\t\t\t\t// Parse rename format from numstat (e.g., \"{old => new}/path\")\n\t\t\t\t({ path, originalPath } = parseCopyOrRename(path, false));\n\n\t\t\t\t// Look up --raw info for this path (keyed by trimmed new/destination path)\n\t\t\t\tconst info = infoMap.get(path.trim());\n\n\t\t\t\t// Use status from --raw if available; provides accurate status (A/D/M/R/C/T)\n\t\t\t\tconst status = info?.status ?? (originalPath ? 'R' : 'M');\n\n\t\t\t\t// Use originalPath from --raw if available (cleaner than numstat format)\n\t\t\t\tif (info?.originalPath) {\n\t\t\t\t\toriginalPath = info.originalPath;\n\t\t\t\t}\n\n\t\t\t\tconst file: LogParsedFileWithStats = {\n\t\t\t\t\tstatus: status,\n\t\t\t\t\tpath: path.trim(),\n\t\t\t\t\toriginalPath: originalPath?.trim(),\n\t\t\t\t\tadditions: additions === '-' ? 0 : parseInt(additions, 10) || 0,\n\t\t\t\t\tdeletions: deletions === '-' ? 0 : parseInt(deletions, 10) || 0,\n\t\t\t\t\t// Store mode for consumers to derive file type (160000=submodule, 100755=executable, etc.)\n\t\t\t\t\tmode: info?.mode,\n\t\t\t\t\toid: info?.oid,\n\t\t\t\t\tpreviousOid: info?.previousOid,\n\t\t\t\t};\n\n\t\t\t\tfiles.push(file);\n\t\t\t}\n\t\t}\n\n\t\treturn files;\n\t}\n\n\tfunction* parse(data: string | Iterable<string> | undefined): Generator<LogParsedEntryWithFilesAndStats<T>> {\n\t\tusing sw = maybeStopWatch('Git.LogParserWithFilesAndStats.parse', { log: { onlyExit: true, level: 'debug' } });\n\n\t\tif (!data) {\n\t\t\tsw?.stop({ suffix: ` no data` });\n\t\t\treturn;\n\t\t}\n\n\t\tconst records = iterateByDelimiter(data, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntryWithFilesAndStats<T>;\n\t\tlet files: LogParsedFileWithStats[];\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor (const record of records) {\n\t\t\tif (!record.length) continue;\n\n\t\t\tcount++;\n\t\t\tentry = {} as unknown as LogParsedEntryWithFilesAndStats<T>;\n\t\t\tfiles = [];\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\n\t\t\t\tif (fieldCount < keys.length) {\n\t\t\t\t\tentry[keys[fieldCount++]] = field.value as LogParsedEntryWithFilesAndStats<T>[keyof T];\n\t\t\t\t} else if (fieldCount === keys.length) {\n\t\t\t\t\t// Slice off the first newlines between the commits and files/summary, if any\n\t\t\t\t\tconst summary = field.value.startsWith('\\n\\n')\n\t\t\t\t\t\t? field.value.substring(2)\n\t\t\t\t\t\t: field.value.startsWith('\\n')\n\t\t\t\t\t\t\t? field.value.substring(1)\n\t\t\t\t\t\t\t: field.value;\n\t\t\t\t\tappendAll(files, parseFilesAndStats(summary));\n\t\t\t\t} else {\n\t\t\t\t\tdebugger;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tentry.files = files;\n\t\t\tif (files.length) {\n\t\t\t\tentry.stats = { additions: 0, deletions: 0, files: { added: 0, deleted: 0, changed: 0 } };\n\n\t\t\t\tfor (const f of files) {\n\t\t\t\t\tif (f.additions || f.deletions) {\n\t\t\t\t\t\tentry.stats.additions += f.additions ?? 0;\n\t\t\t\t\t\tentry.stats.deletions += f.deletions ?? 0;\n\t\t\t\t\t\tif (f.status === 'A' || f.status === '?') {\n\t\t\t\t\t\t\tentry.stats.files.added++;\n\t\t\t\t\t\t} else if (f.status === 'D') {\n\t\t\t\t\t\t\tentry.stats.files.deleted++;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tentry.stats.files.changed++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\tasync function* parseAsync(stream: AsyncGenerator<string>): AsyncGenerator<LogParsedEntryWithFilesAndStats<T>> {\n\t\tusing sw = maybeStopWatch('Git.LogParserWithFilesAndStats.parseAsync', {\n\t\t\tlog: { onlyExit: true, level: 'debug' },\n\t\t});\n\n\t\tconst records = iterateAsyncByDelimiter(stream, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntryWithFilesAndStats<T>;\n\t\tlet files: LogParsedFileWithStats[];\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor await (const record of records) {\n\t\t\tif (!record.length) continue;\n\t\t\t// Drop a truncated tail (cancelled/early-closed stream) instead of yielding undefined/partial fields.\n\t\t\tif (!isCompleteRecord(record, keys.length)) continue;\n\n\t\t\tcount++;\n\t\t\tentry = {} as unknown as LogParsedEntryWithFilesAndStats<T>;\n\t\t\tfiles = [];\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\n\t\t\t\tif (fieldCount < keys.length) {\n\t\t\t\t\tentry[keys[fieldCount++]] = field.value as LogParsedEntryWithFilesAndStats<T>[keyof T];\n\t\t\t\t} else if (fieldCount === keys.length) {\n\t\t\t\t\t// Slice off the first newlines between the commits and files/summary, if any\n\t\t\t\t\tconst summary = field.value.startsWith('\\n\\n')\n\t\t\t\t\t\t? field.value.substring(2)\n\t\t\t\t\t\t: field.value.startsWith('\\n')\n\t\t\t\t\t\t\t? field.value.substring(1)\n\t\t\t\t\t\t\t: field.value;\n\t\t\t\t\tappendAll(files, parseFilesAndStats(summary));\n\t\t\t\t} else {\n\t\t\t\t\tdebugger;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tentry.files = files;\n\t\t\tif (files.length) {\n\t\t\t\tentry.stats = { additions: 0, deletions: 0, files: { added: 0, deleted: 0, changed: 0 } };\n\n\t\t\t\tfor (const f of files) {\n\t\t\t\t\tif (f.additions || f.deletions) {\n\t\t\t\t\t\tentry.stats.additions += f.additions ?? 0;\n\t\t\t\t\t\tentry.stats.deletions += f.deletions ?? 0;\n\t\t\t\t\t\tif (f.status === 'A' || f.status === '?') {\n\t\t\t\t\t\t\tentry.stats.files.added++;\n\t\t\t\t\t\t} else if (f.status === 'D') {\n\t\t\t\t\t\t\tentry.stats.files.deleted++;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tentry.stats.files.changed++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\treturn {\n\t\targuments: args,\n\t\tseparators: { record: recordSep, field: fieldSep },\n\t\tparse: parse,\n\t\tparseAsync: parseAsync,\n\t};\n}\n\nfunction createLogParserWithFileSummary(): LogParserWithFileSummary<void>;\nfunction createLogParserWithFileSummary<T extends Record<string, string>>(\n\tmapping: ExtractAll<T, string>,\n): LogParserWithFileSummary<T>;\nfunction createLogParserWithFileSummary<T extends Record<string, string> | void>(\n\tmapping?: ExtractAll<T, string>,\n): LogParserWithFileSummary<T> {\n\tlet format = recordFormatSep;\n\tconst keys: (keyof ExtractAll<T, string>)[] = [];\n\tif (mapping != null) {\n\t\tfor (const key in mapping) {\n\t\t\tkeys.push(key);\n\t\t\tformat += `${mapping[key]}${fieldFormatSep}`;\n\t\t}\n\t}\n\tconst args = [`--format=${format}`, '--summary'];\n\n\tfunction parseFileSummary(content: string): LogParsedFile[] {\n\t\tconst files: LogParsedFile[] = [];\n\t\tif (!content?.length) return files;\n\n\t\tlet startIndex;\n\n\t\tlet path;\n\t\tlet originalPath;\n\t\tlet status;\n\n\t\tfor (const line of iterateByDelimiter(content, '\\n')) {\n\t\t\tif (!line) continue;\n\n\t\t\tif (line.startsWith(' rename ')) {\n\t\t\t\t({ path, originalPath } = parseCopyOrRename(line.substring(8 /* move past ' rename ' */), true));\n\t\t\t\tfiles.push({ path: path, originalPath: originalPath, status: 'R' });\n\t\t\t} else if (line.startsWith(' copy ')) {\n\t\t\t\t({ path, originalPath } = parseCopyOrRename(line.substring(6 /* move past ' copy ' */), true));\n\t\t\t\tfiles.push({ path: path, originalPath: originalPath, status: 'C' });\n\t\t\t} else {\n\t\t\t\tif (line.startsWith(' create mode ')) {\n\t\t\t\t\tstatus = 'A';\n\t\t\t\t} else if (line.startsWith(' delete mode ')) {\n\t\t\t\t\tstatus = 'D';\n\t\t\t\t} else {\n\t\t\t\t\t// Ignore \" mode change \" lines\n\t\t\t\t\tif (!line.startsWith(' mode change ')) {\n\t\t\t\t\t\tdebugger;\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tstartIndex = line.indexOf(' ', 13 /* move past 'create mode <num>' or 'delete mode <num>' */);\n\t\t\t\tif (startIndex > -1) {\n\t\t\t\t\tpath = line.substring(startIndex + 1);\n\t\t\t\t\tfiles.push({ path: path, status: status });\n\t\t\t\t} else {\n\t\t\t\t\tdebugger;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn files;\n\t}\n\n\tfunction* parse(data: string | Iterable<string> | undefined): Generator<LogParsedEntryWithFiles<T>> {\n\t\tusing sw = maybeStopWatch('Git.LogParserWithFileSummary.parse', { log: { onlyExit: true, level: 'debug' } });\n\n\t\tif (!data) {\n\t\t\tsw?.stop({ suffix: ` no data` });\n\t\t\treturn;\n\t\t}\n\n\t\tconst records = iterateByDelimiter(data, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntryWithFiles<T>;\n\t\tlet files: LogParsedFile[];\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor (const record of records) {\n\t\t\tif (!record.length) continue;\n\n\t\t\tcount++;\n\t\t\tentry = {} as unknown as LogParsedEntryWithFiles<T>;\n\t\t\tfiles = [];\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\n\t\t\t\tif (fieldCount < keys.length) {\n\t\t\t\t\tentry[keys[fieldCount++]] = field.value as LogParsedEntryWithFiles<T>[keyof T];\n\t\t\t\t} else if (fieldCount === keys.length) {\n\t\t\t\t\t// Slice off the first newlines between the commits and files/summary, if any\n\t\t\t\t\tconst summary = field.value.startsWith('\\n\\n')\n\t\t\t\t\t\t? field.value.substring(2)\n\t\t\t\t\t\t: field.value.startsWith('\\n')\n\t\t\t\t\t\t\t? field.value.substring(1)\n\t\t\t\t\t\t\t: field.value;\n\t\t\t\t\tappendAll(files, parseFileSummary(summary));\n\t\t\t\t} else {\n\t\t\t\t\tdebugger;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tentry.files = files;\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\treturn {\n\t\targuments: args,\n\t\tseparators: { record: recordSep, field: fieldSep },\n\t\tparse: parse,\n\t};\n}\n\nfunction parseCopyOrRename(path: string, stripPercentage: boolean): { path: string; originalPath?: string } {\n\tconst renameIndex = path.indexOf(' => ');\n\tif (renameIndex === -1) return { path: path };\n\n\tlet hasBraces = true;\n\n\tlet openIndex = path.indexOf('{');\n\tif (openIndex === -1) {\n\t\thasBraces = false;\n\t\topenIndex = 0;\n\t}\n\n\tlet closeIndex = path.indexOf('}', openIndex);\n\tif (closeIndex === -1) {\n\t\thasBraces = false;\n\t\tcloseIndex = path.length;\n\t}\n\n\tconst prefix = path.substring(0, openIndex);\n\tconst fromPart = path.substring(hasBraces ? openIndex + 1 : 0, renameIndex);\n\tlet toPart = path.substring(renameIndex + 4, closeIndex);\n\tlet suffix = path.substring(closeIndex + 1);\n\n\t// Check for percentage marker which always appears at the end as (xx%)\n\tif (stripPercentage) {\n\t\tif (hasBraces) {\n\t\t\tif (suffix.endsWith('%)')) {\n\t\t\t\t// Find the last open paren that starts the percentage\n\t\t\t\tconst percentPos = suffix.lastIndexOf(' (');\n\t\t\t\tif (percentPos > -1) {\n\t\t\t\t\tsuffix = suffix.substring(0, percentPos);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (toPart.endsWith('%)')) {\n\t\t\t// Find the last open paren that starts the percentage\n\t\t\tconst percentPos = toPart.lastIndexOf(' (');\n\t\t\tif (percentPos > -1) {\n\t\t\t\ttoPart = toPart.substring(0, percentPos);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tpath: normalizePath(joinPaths(prefix, toPart, suffix).trim()),\n\t\toriginalPath: normalizePath(joinPaths(prefix, fromPart, suffix).trim()),\n\t};\n}\n\nfunction createLogParserSingle(field: string): Parser<string> {\n\tconst args = ['-z', `--format=${field}`];\n\n\tfunction parse(data: string | Iterable<string> | undefined): Iterable<string> {\n\t\tusing _sw = maybeStopWatch('Git.LogParserSingle.parse', { log: { onlyExit: true, level: 'debug' } });\n\n\t\treturn data ? iterateByDelimiter(data, '\\0') : [];\n\t}\n\n\treturn { arguments: args, separators: { record: '\\0', field: '\\0' }, parse: parse };\n}\n\nfunction createLogParserWithPatch<T extends Record<string, string>>(\n\tmapping: ExtractAll<T, string>,\n): LogParserWithFiles<T> {\n\tlet format = recordFormatSep;\n\tconst keys: (keyof ExtractAll<T, string>)[] = [];\n\tfor (const key in mapping) {\n\t\tkeys.push(key);\n\t\tformat += `${mapping[key]}${fieldFormatSep}`;\n\t}\n\n\tconst args = [`--format=${format}`];\n\n\tfunction parsePatch(content: string): LogParsedFile | undefined {\n\t\tconst lines = iterateByDelimiter(content, '\\n');\n\t\tlet line = lines.next();\n\t\tif (line.done) return undefined;\n\n\t\tconst fileMatch = diffRegex.exec(line.value);\n\t\tif (fileMatch == null) return undefined;\n\n\t\twhile (!line.done && !line.value.startsWith('@@ ')) {\n\t\t\tline = lines.next();\n\t\t}\n\n\t\tconst rangeMatch = line.value.match(diffHunkRegex);\n\n\t\tlet range: LogParsedRange | undefined;\n\t\tlet originalRange: LogParsedRange | undefined;\n\t\tif (rangeMatch != null) {\n\t\t\tlet start = parseInt(rangeMatch[1], 10);\n\t\t\tlet count = rangeMatch[2] ? parseInt(rangeMatch[2], 10) : 1;\n\n\t\t\toriginalRange = start && count ? { startLine: start, endLine: start + count - 1 } : undefined;\n\n\t\t\tstart = parseInt(rangeMatch[3], 10);\n\t\t\tcount = rangeMatch[4] ? parseInt(rangeMatch[4], 10) : 1;\n\n\t\t\trange = start && count ? { startLine: start, endLine: start + count - 1 } : undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tstatus: (fileMatch[1] === 'rename' ? 'R' : 'M') satisfies GitFileIndexStatus,\n\t\t\tpath: fileMatch[2],\n\t\t\toriginalPath: fileMatch[1] === 'rename' ? fileMatch[3] : undefined,\n\t\t\trange: range,\n\t\t\toriginalRange: originalRange,\n\t\t};\n\t}\n\n\tfunction* parse(data: string | Iterable<string> | undefined): Generator<LogParsedEntryWithFiles<T>> {\n\t\tusing sw = maybeStopWatch('Git.LogParserWithPatch.parse', { log: { onlyExit: true, level: 'debug' } });\n\n\t\tif (!data) {\n\t\t\tsw?.stop({ suffix: ` no data` });\n\t\t\treturn;\n\t\t}\n\n\t\tconst records = iterateByDelimiter(data, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntryWithFiles<T>;\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor (const record of records) {\n\t\t\tif (!record.length) continue;\n\n\t\t\tcount++;\n\t\t\tentry = {} as unknown as LogParsedEntryWithFiles<T>;\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\n\t\t\t\tif (fieldCount < keys.length) {\n\t\t\t\t\tentry[keys[fieldCount++]] = field.value as LogParsedEntryWithFiles<T>[keyof T];\n\t\t\t\t} else if (fieldCount === keys.length) {\n\t\t\t\t\t// Slice off the first newlines between the commit data and patch, if any\n\t\t\t\t\tconst patch = field.value.startsWith('\\n\\n')\n\t\t\t\t\t\t? field.value.substring(2)\n\t\t\t\t\t\t: field.value.startsWith('\\n')\n\t\t\t\t\t\t\t? field.value.substring(1)\n\t\t\t\t\t\t\t: field.value;\n\t\t\t\t\tconst file = parsePatch(patch);\n\t\t\t\t\tentry.files = file != null ? [file] : [];\n\t\t\t\t} else {\n\t\t\t\t\tdebugger;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\tasync function* parseAsync(stream: AsyncGenerator<string>): AsyncGenerator<LogParsedEntryWithFiles<T>> {\n\t\tusing sw = maybeStopWatch('Git.LogParserWithPatch.parseAsync', { log: { onlyExit: true, level: 'debug' } });\n\n\t\tconst records = iterateAsyncByDelimiter(stream, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntryWithFiles<T>;\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor await (const record of records) {\n\t\t\tif (!record.length) continue;\n\t\t\t// Drop a truncated tail (cancelled/early-closed stream) instead of yielding undefined/partial fields.\n\t\t\tif (!isCompleteRecord(record, keys.length)) continue;\n\n\t\t\tcount++;\n\t\t\tentry = {} as unknown as LogParsedEntryWithFiles<T>;\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\n\t\t\t\tif (fieldCount < keys.length) {\n\t\t\t\t\tentry[keys[fieldCount++]] = field.value as LogParsedEntryWithFiles<T>[keyof T];\n\t\t\t\t} else if (fieldCount === keys.length) {\n\t\t\t\t\t// Slice off the first newlines between the commit data and patch, if any\n\t\t\t\t\tconst patch = field.value.startsWith('\\n\\n')\n\t\t\t\t\t\t? field.value.substring(2)\n\t\t\t\t\t\t: field.value.startsWith('\\n')\n\t\t\t\t\t\t\t? field.value.substring(1)\n\t\t\t\t\t\t\t: field.value;\n\t\t\t\t\tconst file = parsePatch(patch);\n\t\t\t\t\tentry.files = file != null ? [file] : [];\n\t\t\t\t} else {\n\t\t\t\t\tdebugger;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\treturn {\n\t\targuments: args,\n\t\tseparators: { record: recordSep, field: fieldSep },\n\t\tparse: parse,\n\t\tparseAsync: parseAsync,\n\t};\n}\n\nfunction createLogParserWithStats<T extends Record<string, string>>(\n\tmapping: ExtractAll<T, string>,\n): LogParserWithStats<T> {\n\tlet format = recordFormatSep;\n\tconst keys: (keyof ExtractAll<T, string>)[] = [];\n\tfor (const key in mapping) {\n\t\tkeys.push(key);\n\t\tformat += `${mapping[key]}${fieldFormatSep}`;\n\t}\n\n\tconst args = [`--format=${format}`, '--shortstat'];\n\n\tfunction parseStats(content: string): LogParsedStats {\n\t\tconst stats: LogParsedStats = { files: 0, additions: 0, deletions: 0 };\n\t\tcontent = content?.trim();\n\t\tif (!content?.length) return { files: 0, additions: 0, deletions: 0 };\n\n\t\tlet filesEnd;\n\t\tlet filesIndex = content.indexOf(' files changed');\n\t\tif (filesIndex === -1) {\n\t\t\tfilesIndex = content.indexOf(' file changed');\n\t\t\tif (filesIndex === -1) return stats;\n\n\t\t\tfilesEnd = filesIndex + ' file changed'.length;\n\t\t} else {\n\t\t\tfilesEnd = filesIndex + ' files changed'.length;\n\t\t}\n\n\t\t// Extract number before \" files changed\"\n\t\tconst filesPart = content.substring(0, filesIndex).trim();\n\t\tstats.files = parseInt(filesPart, 10) || 0;\n\n\t\t// Extract additions if present\n\t\tconst additionsIndex = content.indexOf(' insertion', filesEnd);\n\t\tif (additionsIndex !== -1) {\n\t\t\t// Look for the number before \"insertion(+)\" or \"insertions(+)\"\n\t\t\tconst spaceIndex = content.lastIndexOf(' ', additionsIndex - 1);\n\t\t\tif (spaceIndex !== -1) {\n\t\t\t\tconst additionsPart = content.substring(spaceIndex, additionsIndex).trim();\n\t\t\t\tstats.additions = parseInt(additionsPart, 10) || 0;\n\t\t\t}\n\t\t}\n\n\t\t// Extract deletions if present\n\t\tconst deletionsIndex = content.indexOf(' deletion', filesEnd);\n\t\tif (deletionsIndex !== -1) {\n\t\t\t// Look for the number before \"\"deletion(-)\" or \"deletions(-)\"\n\t\t\tconst spaceIndex = content.lastIndexOf(' ', deletionsIndex - 1);\n\t\t\tif (spaceIndex !== -1) {\n\t\t\t\tconst deletionsPart = content.substring(spaceIndex, deletionsIndex).trim();\n\t\t\t\tstats.deletions = parseInt(deletionsPart, 10) || 0;\n\t\t\t}\n\t\t}\n\n\t\treturn stats;\n\t}\n\n\tfunction* parse(data: string | Iterable<string> | undefined): Generator<LogParsedEntryWithStats<T>> {\n\t\tusing sw = maybeStopWatch('Git.LogParserWithStats.parse', { log: { onlyExit: true, level: 'debug' } });\n\n\t\tif (!data) {\n\t\t\tsw?.stop({ suffix: ` no data` });\n\t\t\treturn;\n\t\t}\n\n\t\tconst records = iterateByDelimiter(data, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntryWithStats<T>;\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor (const record of records) {\n\t\t\tif (!record.length) continue;\n\n\t\t\tcount++;\n\t\t\tentry = {} as unknown as LogParsedEntryWithStats<T>;\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\n\t\t\t\tif (fieldCount < keys.length) {\n\t\t\t\t\tentry[keys[fieldCount++]] = field.value as LogParsedEntryWithStats<T>[keyof T];\n\t\t\t\t} else if (fieldCount === keys.length) {\n\t\t\t\t\t// Slice off the first newlines between the commit data and files/summary, if any\n\t\t\t\t\tconst summary = field.value.startsWith('\\n\\n')\n\t\t\t\t\t\t? field.value.substring(2)\n\t\t\t\t\t\t: field.value.startsWith('\\n')\n\t\t\t\t\t\t\t? field.value.substring(1)\n\t\t\t\t\t\t\t: field.value;\n\t\t\t\t\tentry.stats = parseStats(summary);\n\t\t\t\t} else {\n\t\t\t\t\tdebugger;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\tasync function* parseAsync(stream: AsyncGenerator<string>): AsyncGenerator<LogParsedEntryWithStats<T>> {\n\t\tusing sw = maybeStopWatch('Git.LogParserWithStats.parseAsync', { log: { onlyExit: true, level: 'debug' } });\n\n\t\tconst records = iterateAsyncByDelimiter(stream, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntryWithStats<T>;\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor await (const record of records) {\n\t\t\tif (!record.length) continue;\n\n\t\t\tcount++;\n\t\t\tentry = {} as unknown as LogParsedEntryWithStats<T>;\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\n\t\t\t\tif (fieldCount < keys.length) {\n\t\t\t\t\tentry[keys[fieldCount++]] = field.value as LogParsedEntryWithStats<T>[keyof T];\n\t\t\t\t} else if (fieldCount === keys.length) {\n\t\t\t\t\t// Slice off the first newlines between the commit data and files/summary, if any\n\t\t\t\t\tconst summary = field.value.startsWith('\\n\\n')\n\t\t\t\t\t\t? field.value.substring(2)\n\t\t\t\t\t\t: field.value.startsWith('\\n')\n\t\t\t\t\t\t\t? field.value.substring(1)\n\t\t\t\t\t\t\t: field.value;\n\t\t\t\t\tentry.stats = parseStats(summary);\n\t\t\t\t} else {\n\t\t\t\t\tdebugger;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\treturn {\n\t\targuments: args,\n\t\tseparators: { record: recordSep, field: fieldSep },\n\t\tparse: parse,\n\t\tparseAsync: parseAsync,\n\t};\n}\n\nfunction createLogParserWithFiles<T extends Record<string, string>>(\n\tmapping: ExtractAll<T, string>,\n): LogParserWithFiles<T> {\n\tlet format = recordFormatSep;\n\tconst keys: (keyof ExtractAll<T, string>)[] = [];\n\tfor (const key in mapping) {\n\t\tkeys.push(key);\n\t\tformat += `${mapping[key]}${fieldFormatSep}`;\n\t}\n\n\tconst args = [`--format=${format}`, '--name-only'];\n\n\tfunction parseFileNames(content: string): LogParsedFile[] {\n\t\tconst files: LogParsedFile[] = [];\n\t\tif (!content?.length) return files;\n\n\t\tfor (const line of iterateByDelimiter(content, '\\n')) {\n\t\t\tconst trimmed = line.trim();\n\t\t\tif (!trimmed) continue;\n\n\t\t\tfiles.push({ path: trimmed });\n\t\t}\n\n\t\treturn files;\n\t}\n\n\tfunction* parse(data: string | Iterable<string> | undefined): Generator<LogParsedEntryWithFiles<T>> {\n\t\tusing sw = maybeStopWatch('Git.createLogParserWithFiles.parse', { log: { onlyExit: true, level: 'debug' } });\n\n\t\tif (!data) {\n\t\t\tsw?.stop({ suffix: ` no data` });\n\t\t\treturn;\n\t\t}\n\n\t\tconst records = iterateByDelimiter(data, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntryWithFiles<T>;\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor (const record of records) {\n\t\t\tif (!record.length) continue;\n\n\t\t\tcount++;\n\t\t\tentry = {} as unknown as LogParsedEntryWithFiles<T>;\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\n\t\t\t\tif (fieldCount < keys.length) {\n\t\t\t\t\tentry[keys[fieldCount++]] = field.value as LogParsedEntryWithFiles<T>[keyof T];\n\t\t\t\t} else if (fieldCount === keys.length) {\n\t\t\t\t\t// Slice off the first newlines between the commit data and files, if any\n\t\t\t\t\tconst files = field.value.startsWith('\\n\\n')\n\t\t\t\t\t\t? field.value.substring(2)\n\t\t\t\t\t\t: field.value.startsWith('\\n')\n\t\t\t\t\t\t\t? field.value.substring(1)\n\t\t\t\t\t\t\t: field.value;\n\t\t\t\t\tentry.files = parseFileNames(files);\n\t\t\t\t} else {\n\t\t\t\t\tdebugger;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\tasync function* parseAsync(stream: AsyncGenerator<string>): AsyncGenerator<LogParsedEntryWithFiles<T>> {\n\t\tusing sw = maybeStopWatch('Git.createLogParserWithFiles.parseAsync', {\n\t\t\tlog: { onlyExit: true, level: 'debug' },\n\t\t});\n\n\t\tconst records = iterateAsyncByDelimiter(stream, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntryWithFiles<T>;\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor await (const record of records) {\n\t\t\tif (!record.length) continue;\n\n\t\t\tcount++;\n\t\t\tentry = {} as unknown as LogParsedEntryWithFiles<T>;\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\n\t\t\t\tif (fieldCount < keys.length) {\n\t\t\t\t\tentry[keys[fieldCount++]] = field.value as LogParsedEntryWithFiles<T>[keyof T];\n\t\t\t\t} else if (fieldCount === keys.length) {\n\t\t\t\t\t// Slice off the first newlines between the commit data and files, if any\n\t\t\t\t\tconst files = field.value.startsWith('\\n\\n')\n\t\t\t\t\t\t? field.value.substring(2)\n\t\t\t\t\t\t: field.value.startsWith('\\n')\n\t\t\t\t\t\t\t? field.value.substring(1)\n\t\t\t\t\t\t\t: field.value;\n\t\t\t\t\tentry.files = parseFileNames(files);\n\t\t\t\t} else {\n\t\t\t\t\tdebugger;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\treturn {\n\t\targuments: args,\n\t\tseparators: { record: recordSep, field: fieldSep },\n\t\tparse: parse,\n\t\tparseAsync: parseAsync,\n\t};\n}\n"],"mappings":";;;;;;AAOA,MAAM,iBAAiB;CACtB,KAAK;CACL,QAAQ;CACR,aAAa;CACb,YAAY;CACZ,WAAW;CACX,gBAAgB;CAChB,eAAe;CACf,SAAS;CACT,MAAM;CACN,SAAS;AACV;AAGA,IAAI;AAEJ,IAAI;AAEJ,IAAI;AAOJ,SAAgB,oBACf,cACA,aAC6E;CAC7E,IAAI,aAAa;EAChB,8BAA8B,yBAAyB,cAAc;EACrE,OAAO;CACR;CAEA,IAAI,cAAc;EACjB,4BAA4B,iCAAiC,cAAc;EAC3E,OAAO;CACR;CAEA,mBAAmB,gBAAgB,cAAc;CACjD,OAAO;AACR;AAEA,MAAM,sBAAsB;CAAE,KAAK;CAAM,QAAQ;CAAO,OAAO;CAAO,MAAM;CAAO,SAAS;AAAK;AAGjG,IAAI;AAEJ,IAAI;AAEJ,SAAgB,yBAAyB,OAAyE;CACjH,IAAI,OAAO;EACV,iCAAiC,yBAAyB,mBAAmB;EAC7E,OAAO;CACR;CAEA,wBAAwB,gBAAgB,mBAAmB;CAC3D,OAAO;AACR;AAEA,MAAM,eAAe;CACpB,KAAK;CACL,QAAQ;CACR,aAAa;CACb,YAAY;CACZ,eAAe;CACf,SAAS;CACT,MAAM;CACN,SAAS;AACV;AAGA,IAAI;AAEJ,IAAI;;;;;AAMJ,SAAgB,eAAe,OAA2D;CACzF,IAAI,OAAO;EACV,IAAI,yBAAyB,MAAM;GAClC,wBAAwB,yBAAyB,YAAY;GAC7D,sBAAsB,UAAU,KAAK,iBAAiB;EACvD;EACA,OAAO;CACR;CAEA,IAAI,gBAAgB,MAAM;EACzB,eAAe,gBAAgB,YAAY;EAC3C,aAAa,UAAU,KAAK,iBAAiB;CAC9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AI,KAAK,EAAE,QAAQ,WAAW,MAAM,UAAU,CAAC;;;;;;CAChD;CAEA,OAAO;EACN,WAAW;EACX,YAAY;GAAE,QAAQ;GAAW,OAAO;EAAS;EAC1C;EACK;CACb;AACD"}
|
|
1
|
+
{"version":3,"file":"logParser.js","names":[],"sources":["../../../../git-cli/src/parsers/logParser.ts"],"sourcesContent":["import type { GitFileIndexStatus } from '@gitlens/git/models/fileStatus.js';\nimport { diffHunkRegex, parseDiffFilePaths, parseQuotedRenameOrCopyPaths } from '@gitlens/git/parsers/diffParser.js';\nimport { joinPaths, normalizePath } from '@gitlens/utils/path.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport { flattenString, iterateAsyncByDelimiter, iterateByDelimiter, unquoteCString } from '@gitlens/utils/string.js';\nimport type { ExtractAll } from '@gitlens/utils/types.js';\n\nconst commitsMapping = {\n\tsha: '%H',\n\tauthor: '%aN',\n\tauthorEmail: '%aE',\n\tauthorDate: '%at',\n\tcommitter: '%cN',\n\tcommitterEmail: '%cE',\n\tcommitterDate: '%ct',\n\tparents: '%P',\n\ttips: '%D',\n\tmessage: '%B',\n};\n\nexport type CommitsLogParser = LogParser<typeof commitsMapping>;\nlet _commitsParser: CommitsLogParser | undefined;\nexport type CommitsWithFilesLogParser = LogParserWithFilesAndStats<typeof commitsMapping>;\nlet _commitsWithFilesParser: CommitsWithFilesLogParser | undefined;\nexport type CommitsInFileRangeLogParser = LogParserWithFiles<typeof commitsMapping>;\nlet _commitsInFileRangeParser: CommitsInFileRangeLogParser | undefined;\n\nexport type ParsedCommit =\n\t| LogParsedEntry<typeof commitsMapping>\n\t| LogParsedEntryWithFiles<typeof commitsMapping>\n\t| LogParsedEntryWithFilesAndStats<typeof commitsMapping>;\n\nexport function getCommitsLogParser(\n\tincludeFiles: boolean,\n\tinFileRange?: boolean,\n): CommitsLogParser | CommitsWithFilesLogParser | CommitsInFileRangeLogParser {\n\tif (inFileRange) {\n\t\t_commitsInFileRangeParser ??= createLogParserWithPatch(commitsMapping);\n\t\treturn _commitsInFileRangeParser;\n\t}\n\n\tif (includeFiles) {\n\t\t_commitsWithFilesParser ??= createLogParserWithFilesAndStats(commitsMapping);\n\t\treturn _commitsWithFilesParser;\n\t}\n\n\t_commitsParser ??= createLogParser(commitsMapping);\n\treturn _commitsParser;\n}\n\nconst contributorsMapping = { sha: '%H', author: '%aN', email: '%aE', date: '%at', message: '%B' };\n\ntype ContributorsLogParser = LogParser<typeof contributorsMapping>;\nlet _contributorsParser: ContributorsLogParser | undefined;\ntype ContributorsWithStatsLogParser = LogParserWithStats<typeof contributorsMapping>;\nlet _contributorsWithStatsParser: ContributorsWithStatsLogParser | undefined;\n\nexport function getContributorsLogParser(stats?: boolean): ContributorsLogParser | ContributorsWithStatsLogParser {\n\tif (stats) {\n\t\t_contributorsWithStatsParser ??= createLogParserWithStats(contributorsMapping);\n\t\treturn _contributorsWithStatsParser;\n\t}\n\n\t_contributorsParser ??= createLogParser(contributorsMapping);\n\treturn _contributorsParser;\n}\n\nconst graphMapping = {\n\tsha: '%H',\n\tauthor: '%aN',\n\tauthorEmail: '%aE',\n\tauthorDate: '%at',\n\tcommitterDate: '%ct',\n\tparents: '%P',\n\ttips: '%D',\n\tmessage: '%B',\n};\n\nexport type GraphLogParser = LogParser<typeof graphMapping>;\nlet _graphParser: GraphLogParser | undefined;\ntype GraphWithStatsLogParser = LogParserWithStats<typeof graphMapping>;\nlet _graphWithStatsParser: GraphWithStatsLogParser | undefined;\n\n/**\n * Prints `tips` as full refnames (`HEAD -> refs/heads/main`, `refs/remotes/origin/main`, `tag: refs/tags/v1`), whatever\n * `log.decorate` says, since short names can't tell a local branch from a remote-tracking ref of the same name\n */\nexport function getGraphParser(stats?: boolean): GraphLogParser | GraphWithStatsLogParser {\n\tif (stats) {\n\t\tif (_graphWithStatsParser == null) {\n\t\t\t_graphWithStatsParser = createLogParserWithStats(graphMapping);\n\t\t\t_graphWithStatsParser.arguments.push('--decorate=full');\n\t\t}\n\t\treturn _graphWithStatsParser;\n\t}\n\n\tif (_graphParser == null) {\n\t\t_graphParser = createLogParser(graphMapping);\n\t\t_graphParser.arguments.push('--decorate=full');\n\t}\n\treturn _graphParser;\n}\n\ntype ShaLogParser = Parser<string>;\nlet _shaParser: ShaLogParser | undefined;\n\nexport function getShaLogParser(): ShaLogParser {\n\t_shaParser ??= createLogParserSingle('%H');\n\treturn _shaParser;\n}\n\nconst shaAndDateMapping = { sha: '%H', authorDate: '%at', committerDate: '%ct' };\nconst shaAndDateAndTipsMapping = { sha: '%H', authorDate: '%at', committerDate: '%ct', tips: '%D' };\n\ntype ShaAndDatesLogParser = LogParser<typeof shaAndDateMapping & { tips?: string }>;\nlet _shaAndDatesParser: ShaAndDatesLogParser | undefined;\ntype ShaAndDatesAndTipsLogParser = LogParser<typeof shaAndDateAndTipsMapping>;\nlet _shaAndDatesAndTipsParser: ShaAndDatesAndTipsLogParser | undefined;\n\nexport function getShaAndDatesLogParser(includeTips?: boolean): ShaAndDatesLogParser | ShaAndDatesAndTipsLogParser {\n\tif (includeTips) {\n\t\t_shaAndDatesAndTipsParser ??= createLogParser(shaAndDateAndTipsMapping);\n\t\treturn _shaAndDatesAndTipsParser;\n\t}\n\n\t_shaAndDatesParser ??= createLogParser(shaAndDateMapping);\n\treturn _shaAndDatesParser;\n}\n\ntype ShaAndDatesWithFilesLogParser = LogParserWithFiles<typeof shaAndDateMapping & { tips?: string }>;\nlet _shaAndDatesWithFilesParser: ShaAndDatesWithFilesLogParser | undefined;\n\ntype ShaAndDatesAndTipsWithFilesLogParser = LogParserWithFiles<typeof shaAndDateAndTipsMapping>;\nlet _shaAndDatesAndTipsWithFilesParser: ShaAndDatesAndTipsWithFilesLogParser | undefined;\n\nexport function getShaAndDatesWithFilesLogParser(\n\tincludeTips?: boolean,\n): ShaAndDatesWithFilesLogParser | ShaAndDatesAndTipsWithFilesLogParser {\n\tif (includeTips) {\n\t\t_shaAndDatesAndTipsWithFilesParser ??= createLogParserWithFiles(shaAndDateAndTipsMapping);\n\t\treturn _shaAndDatesAndTipsWithFilesParser;\n\t}\n\n\t_shaAndDatesWithFilesParser ??= createLogParserWithFiles(shaAndDateMapping);\n\treturn _shaAndDatesWithFilesParser;\n}\n\nconst shaMapping = { sha: '%H' };\n\ntype ShaAndFilesAndStatsLogParser = LogParserWithFilesAndStats<typeof shaMapping>;\nlet _shaAndFilesAndStatsParser: ShaAndFilesAndStatsLogParser | undefined;\n\nexport function getShaAndFilesAndStatsLogParser(): ShaAndFilesAndStatsLogParser {\n\t_shaAndFilesAndStatsParser ??= createLogParserWithFilesAndStats(shaMapping);\n\treturn _shaAndFilesAndStatsParser;\n}\n\ntype ShaAndFileRangeLogParser = LogParserWithFiles<typeof shaMapping>;\nlet _shaAndFileRangeParser: ShaAndFileRangeLogParser | undefined;\n\nexport function getShaAndFileRangeLogParser(): ShaAndFileRangeLogParser {\n\t_shaAndFileRangeParser ??= createLogParserWithPatch(shaMapping);\n\treturn _shaAndFileRangeParser;\n}\n\ntype ShaAndFileSummaryLogParser = LogParserWithFileSummary<typeof shaMapping>;\nlet _shaAndFileSummaryParser: ShaAndFileSummaryLogParser | undefined;\n\nexport function getShaAndFileSummaryLogParser(): ShaAndFileSummaryLogParser {\n\t_shaAndFileSummaryParser ??= createLogParserWithFileSummary(shaMapping);\n\treturn _shaAndFileSummaryParser;\n}\n\ntype ShaAndStatsLogParser = LogParserWithStats<typeof shaMapping>;\nlet _shaAndStatsParser: ShaAndStatsLogParser | undefined;\n\nexport function getShaAndStatsLogParser(): ShaAndStatsLogParser {\n\t_shaAndStatsParser ??= createLogParserWithStats(shaMapping);\n\treturn _shaAndStatsParser;\n}\n\nconst stashMapping = {\n\tsha: '%H',\n\tauthorDate: '%at',\n\tcommittedDate: '%ct',\n\tparents: '%P',\n\tstashName: '%gd',\n\tsummary: '%gs',\n\t// %s (commit subject) is git's authoritative `On <branch>: …` / `WIP on <branch>: …` record,\n\t// present even when the reflog message (%gs) was customized (autostash, `git stash store -m`).\n\t// Used downstream to extract `stashOnRef` reliably.\n\tcommitSubject: '%s',\n};\n\ntype StashLogParser = LogParser<typeof stashMapping>;\nlet _stashParser: StashLogParser | undefined;\ntype StashLogParserWithFiles = LogParserWithFilesAndStats<typeof stashMapping>;\nlet _stashParserWithFiles: StashLogParserWithFiles | undefined;\n\nexport type ParsedStash = LogParsedEntry<typeof stashMapping>;\nexport type ParsedStashWithFiles = LogParsedEntryWithFilesAndStats<typeof stashMapping>;\n\nexport function getStashLogParser(includeFiles?: false): StashLogParser;\nexport function getStashLogParser(includeFiles: true): StashLogParserWithFiles;\nexport function getStashLogParser(includeFiles?: boolean): StashLogParser | StashLogParserWithFiles;\nexport function getStashLogParser(includeFiles?: boolean): StashLogParser | StashLogParserWithFiles {\n\tif (includeFiles) {\n\t\t_stashParserWithFiles ??= createLogParserWithFilesAndStats(stashMapping);\n\t\treturn _stashParserWithFiles;\n\t}\n\n\t_stashParser ??= createLogParser(stashMapping);\n\treturn _stashParser;\n}\n\ntype StashFilesOnlyLogParser = LogParserWithFilesAndStats<void>;\nlet _stashFilesOnlyParser: StashFilesOnlyLogParser | undefined;\n\nexport function getStashFilesOnlyLogParser(): StashFilesOnlyLogParser {\n\t_stashFilesOnlyParser ??= createLogParserWithFilesAndStats();\n\treturn _stashFilesOnlyParser;\n}\n\n// Parser types\nexport type Parser<T> = {\n\targuments: string[];\n\tseparators: { record: string; field: string };\n\tparse: (data: string | Iterable<string> | undefined) => Generator<T> | Iterable<T>;\n\tparseAsync?: never;\n};\nexport type AsyncParser<T> = {\n\targuments: string[];\n\tseparators: { record: string; field: string };\n\tparse: (data: string | Iterable<string> | undefined) => Generator<T> | Iterable<T>;\n\tparseAsync: (stream: AsyncGenerator<string>) => AsyncGenerator<T>;\n\t/**\n\t * Like `parseAsync` but yields one ARRAY of entries per stream chunk, scanning each chunk\n\t * synchronously with plain `indexOf` (no per-field iterator machinery). Bulk consumers (the\n\t * graph walk) avoid two promise hops per record — thousands of awaited yields collapse to one\n\t * per chunk. Only the plain parser implements it; per-record `parseAsync` remains the\n\t * general-purpose path.\n\t */\n\tparseAsyncBatched?: (stream: AsyncGenerator<string>) => AsyncGenerator<T[]>;\n};\n\nexport type LogParser<T> = AsyncParser<LogParsedEntry<T>>;\ntype LogParserWithFiles<T> = AsyncParser<LogParsedEntryWithFiles<T>>;\ntype LogParserWithFilesAndStats<T> = AsyncParser<LogParsedEntryWithFilesAndStats<T>>;\ntype LogParserWithFileSummary<T> = Parser<LogParsedEntryWithFiles<T>>;\ntype LogParserWithStats<T> = AsyncParser<LogParsedEntryWithStats<T>>;\n\n// Parsed entry types\ntype LogParsedEntry<T> = { [K in keyof T]: string } & { files?: never; stats?: never };\ntype LogParsedEntryWithFiles<T> = { [K in keyof T]: string } & { files: LogParsedFile[]; stats?: never };\ntype LogParsedEntryWithFilesAndStats<T> = { [K in keyof T]: string } & {\n\tfiles: LogParsedFileWithStats[];\n\tstats: LogParsedStatsWithFilesStats;\n};\ntype LogParsedEntryWithStats<T> = { [K in keyof T]: string } & { stats: LogParsedStats };\n\n// Parsed types\nexport interface LogParsedFile {\n\tstatus?: string;\n\tpath: string;\n\toriginalPath?: string;\n\tadditions?: never;\n\tdeletions?: never;\n\trange?: LogParsedRange;\n\toriginalRange?: LogParsedRange;\n\t/** Git file mode (e.g., 100644=regular, 100755=executable, 120000=symlink, 160000=submodule) */\n\tmode?: string;\n\t/** For submodule entries (mode 160000), the commit SHA the submodule points to */\n\toid?: string;\n\t/** For submodule entries (mode 160000), the previous commit SHA */\n\tpreviousOid?: string;\n}\ntype LogParsedFileWithStats = Omit<LogParsedFile, 'additions' | 'deletions'> & {\n\tadditions: number;\n\tdeletions: number;\n};\ninterface LogParsedRange {\n\tstartLine: number;\n\tendLine: number;\n}\ninterface LogParsedStats {\n\tfiles: number;\n\tadditions: number;\n\tdeletions: number;\n}\ninterface LogParsedStatsWithFilesStats {\n\tfiles: { added: number; changed: number; deleted: number };\n\tadditions: number;\n\tdeletions: number;\n}\n\nconst recordSep = '\\x1E'; // ASCII Record Separator character\nconst recordFormatSep = '%x1E';\nconst fieldSep = '\\x1D'; // ASCII Group Separator character\nconst fieldFormatSep = '%x1D';\n\n// `push(...items)` throws a RangeError once `items` is large enough to overflow the call stack\nfunction appendAll<T>(target: T[], items: readonly T[]): void {\n\tfor (const item of items) {\n\t\ttarget.push(item);\n\t}\n}\n\n// A complete record terminates every mapped field with a field separator — a cancelled/early-closed\n// stream resolves cleanly with a truncated tail missing at least the final terminator.\nfunction isCompleteRecord(record: string, requiredFields: number): boolean {\n\tlet count = 0;\n\tlet index = -1;\n\twhile (count < requiredFields) {\n\t\tindex = record.indexOf(fieldSep, index + 1);\n\t\tif (index === -1) return false;\n\n\t\tcount++;\n\t}\n\treturn true;\n}\n\nexport function createLogParser<T extends Record<string, string>>(mapping: ExtractAll<T, string>): LogParser<T> {\n\tlet format = recordFormatSep;\n\tconst keys: (keyof ExtractAll<T, string>)[] = [];\n\tfor (const key in mapping) {\n\t\tkeys.push(key);\n\t\tformat += `${mapping[key]}${fieldFormatSep}`;\n\t}\n\n\tconst args = [`--format=${format}`];\n\n\tfunction* parse(data: string | Iterable<string> | undefined): Generator<LogParsedEntry<T>> {\n\t\tusing sw = maybeStopWatch('Git.LogParser.parse', { log: { onlyExit: true, level: 'debug' } });\n\n\t\tif (!data) {\n\t\t\tsw?.stop({ suffix: ` no data` });\n\t\t\treturn;\n\t\t}\n\n\t\tconst records = iterateByDelimiter(data, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntry<T>;\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor (const record of records) {\n\t\t\tif (!record.length) continue;\n\n\t\t\tentry = {} as unknown as LogParsedEntry<T>;\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\t\t\t\tif (fieldCount >= keys.length) continue;\n\n\t\t\t\tcount++;\n\t\t\t\tentry[keys[fieldCount++]] = field.value as T[keyof T];\n\t\t\t}\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\tasync function* parseAsync(stream: AsyncGenerator<string>): AsyncGenerator<LogParsedEntry<T>> {\n\t\tusing sw = maybeStopWatch('Git.LogParser.parseAsync', { log: { onlyExit: true, level: 'debug' } });\n\n\t\tconst records = iterateAsyncByDelimiter(stream, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntry<T>;\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor await (const record of records) {\n\t\t\tif (!record.length) continue;\n\t\t\t// Drop a truncated tail (cancelled/early-closed stream) instead of yielding undefined/partial fields.\n\t\t\tif (!isCompleteRecord(record, keys.length)) continue;\n\n\t\t\tentry = {} as unknown as LogParsedEntry<T>;\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\t\t\t\tif (fieldCount >= keys.length) continue;\n\n\t\t\t\tcount++;\n\t\t\t\tentry[keys[fieldCount++]] = field.value as T[keyof T];\n\t\t\t}\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\t// Builds one entry from a complete record with a plain `indexOf` walk. Matches `parseAsync`'s\n\t// semantics exactly: fields beyond the mapping are ignored, and every mapped field is\n\t// terminated by a field separator (the format string appends one after each field).\n\tfunction parseRecord(record: string): LogParsedEntry<T> {\n\t\t// Fields sliced out of the record become long-lived (graph rows); flatten the record so they\n\t\t// pin a record-sized copy rather than the full walk output the record was sliced from.\n\t\trecord = flattenString(record);\n\t\tconst entry = {} as unknown as LogParsedEntry<T>;\n\t\tlet start = 0;\n\t\tfor (const key of keys) {\n\t\t\tconst end = record.indexOf(fieldSep, start);\n\t\t\tif (end === -1) break;\n\n\t\t\tentry[key] = record.substring(start, end) as T[keyof T];\n\t\t\tstart = end + 1;\n\t\t}\n\t\treturn entry;\n\t}\n\n\tasync function* parseAsyncBatched(stream: AsyncGenerator<string>): AsyncGenerator<LogParsedEntry<T>[]> {\n\t\tusing sw = maybeStopWatch('Git.LogParser.parseAsyncBatched', { log: { onlyExit: true, level: 'debug' } });\n\n\t\tlet count = 0;\n\t\tlet buffer = '';\n\t\tfor await (const chunk of stream) {\n\t\t\tbuffer += chunk;\n\n\t\t\tlet batch: LogParsedEntry<T>[] | undefined;\n\t\t\tlet start = 0;\n\t\t\twhile (true) {\n\t\t\t\tconst end = buffer.indexOf(recordSep, start);\n\t\t\t\tif (end === -1) break;\n\n\t\t\t\tif (end > start) {\n\t\t\t\t\t(batch ??= []).push(parseRecord(buffer.substring(start, end)));\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\tstart = end + 1;\n\t\t\t}\n\t\t\tif (start > 0) {\n\t\t\t\tbuffer = buffer.substring(start);\n\t\t\t}\n\t\t\tif (batch != null) {\n\t\t\t\tyield batch;\n\t\t\t}\n\t\t}\n\t\t// Trailing record (the stream doesn't end with a record separator); a truncated tail from a\n\t\t// cancelled/early-closed stream is missing a field terminator and must be dropped, not parsed.\n\t\tif (buffer.length > 0 && isCompleteRecord(buffer, keys.length)) {\n\t\t\tcount++;\n\t\t\tyield [parseRecord(buffer)];\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\treturn {\n\t\targuments: args,\n\t\tseparators: { record: recordSep, field: fieldSep },\n\t\tparse: parse,\n\t\tparseAsync: parseAsync,\n\t\tparseAsyncBatched: parseAsyncBatched,\n\t};\n}\n\nfunction createLogParserWithFilesAndStats(): LogParserWithFilesAndStats<void>;\nfunction createLogParserWithFilesAndStats<T extends Record<string, string>>(\n\tmapping: ExtractAll<T, string>,\n): LogParserWithFilesAndStats<T>;\nfunction createLogParserWithFilesAndStats<T extends Record<string, string> | void>(\n\tmapping?: ExtractAll<T, string>,\n): LogParserWithFilesAndStats<T> {\n\tlet format = recordFormatSep;\n\tconst keys: (keyof ExtractAll<T, string>)[] = [];\n\tif (mapping != null) {\n\t\tfor (const key in mapping) {\n\t\t\tkeys.push(key);\n\t\t\tformat += `${mapping[key]}${fieldFormatSep}`;\n\t\t}\n\t}\n\t// Use --raw instead of --summary to get accurate mode info for ALL files (not just creates/deletes)\n\t// This allows us to reliably detect submodules (mode 160000) even for modifications\n\tconst args = [`--format=${format}`, '--numstat', '--raw'];\n\n\tfunction parseFilesAndStats(content: string): LogParsedFileWithStats[] {\n\t\tconst files: LogParsedFileWithStats[] = [];\n\t\tif (!content?.length) return files;\n\n\t\t// Map to store info from --raw lines: path -> { mode, status, originalPath, oid?, previousOid? }\n\t\t// Raw format: :<old_mode> <new_mode> <old_sha> <new_sha> <status>[score]\\t<path>[\\t<new_path>]\n\t\tconst infoMap = new Map<\n\t\t\tstring,\n\t\t\t{ mode: string; status: string; originalPath?: string; oid?: string; previousOid?: string }\n\t\t>();\n\n\t\tlet startIndex: number;\n\t\tlet endIndex: number;\n\n\t\t// Single pass: --raw lines come first, then --numstat lines\n\t\tfor (const line of iterateByDelimiter(content, '\\n')) {\n\t\t\tif (!line) continue;\n\n\t\t\tif (line.charCodeAt(0) === 58 /* ':' */) {\n\t\t\t\t// --raw format: :<old_mode> <new_mode> <old_sha> <new_sha> <status>[score]\\t<path>[\\t<new_path>]\n\t\t\t\tconst tabIndex = line.indexOf('\\t');\n\t\t\t\tif (tabIndex === -1) continue;\n\n\t\t\t\t// Parse metadata using indexOf instead of split() to avoid array allocation\n\t\t\t\t// Format after ':': <old_mode> <new_mode> <old_sha> <new_sha> <status>[score]\n\n\t\t\t\t// Skip old_mode, find new_mode\n\t\t\t\tstartIndex = line.indexOf(' ') + 1;\n\t\t\t\tif (startIndex === 0) continue;\n\n\t\t\t\tendIndex = line.indexOf(' ', startIndex);\n\t\t\t\tif (endIndex === -1) continue;\n\n\t\t\t\tconst newMode = line.substring(startIndex, endIndex);\n\n\t\t\t\t// Parse old_sha and new_sha positions\n\t\t\t\tconst oldShaStart = endIndex + 1;\n\t\t\t\tconst oldShaEnd = line.indexOf(' ', oldShaStart);\n\t\t\t\tif (oldShaEnd === -1) continue;\n\n\t\t\t\tconst newShaStart = oldShaEnd + 1;\n\t\t\t\tconst newShaEnd = line.indexOf(' ', newShaStart);\n\t\t\t\tif (newShaEnd === -1) continue;\n\n\t\t\t\t// For submodules (mode 160000), capture the commit SHAs\n\t\t\t\tlet oid: string | undefined;\n\t\t\t\tlet previousOid: string | undefined;\n\t\t\t\tif (newMode === '160000') {\n\t\t\t\t\tpreviousOid = line.substring(oldShaStart, oldShaEnd);\n\t\t\t\t\toid = line.substring(newShaStart, newShaEnd);\n\t\t\t\t}\n\n\t\t\t\t// Status is first char after the last space\n\t\t\t\tstartIndex = newShaEnd;\n\t\t\t\tconst status = line.charAt(startIndex + 1);\n\n\t\t\t\t// Parse path(s) using indexOf instead of split\n\t\t\t\tconst pathPart = line.substring(tabIndex + 1);\n\t\t\t\tlet path: string;\n\t\t\t\tlet originalPath: string | undefined;\n\n\t\t\t\t// Each field is trimmed as written, to match parseCopyOrRename, which trims an unquoted name. A\n\t\t\t\t// quoted name's whitespace is inside its quotes, so it is part of the name and kept\n\t\t\t\tconst pathTabIndex = pathPart.indexOf('\\t');\n\t\t\t\tif ((status === 'R' || status === 'C') && pathTabIndex !== -1) {\n\t\t\t\t\t// For renames/copies: old_path\\tnew_path\n\t\t\t\t\toriginalPath = unquoteCString(pathPart.substring(0, pathTabIndex).trim());\n\t\t\t\t\tpath = unquoteCString(pathPart.substring(pathTabIndex + 1).trim());\n\t\t\t\t} else {\n\t\t\t\t\tpath = unquoteCString(pathPart.trim());\n\t\t\t\t}\n\n\t\t\t\tinfoMap.set(path, {\n\t\t\t\t\tmode: newMode,\n\t\t\t\t\tstatus: status,\n\t\t\t\t\toriginalPath: originalPath,\n\t\t\t\t\toid: oid,\n\t\t\t\t\tpreviousOid: previousOid,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// --numstat format: <additions>\\t<deletions>\\t<path>\n\t\t\t\t// With renames: <additions>\\t<deletions>\\t{prefix/old => new/suffix}\n\t\t\t\tendIndex = line.indexOf('\\t');\n\t\t\t\tif (endIndex === -1) {\n\t\t\t\t\tdebugger;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst additions = line.substring(0, endIndex);\n\n\t\t\t\tstartIndex = endIndex + 1;\n\t\t\t\tendIndex = line.indexOf('\\t', startIndex);\n\t\t\t\tif (endIndex === -1) {\n\t\t\t\t\tdebugger;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst deletions = line.substring(startIndex, endIndex);\n\n\t\t\t\tlet path = line.substring(endIndex + 1);\n\t\t\t\tlet originalPath: string | undefined;\n\n\t\t\t\t// Parse rename format from numstat (e.g., \"{old => new}/path\"), which comes back trimmed as --raw's is\n\t\t\t\t({ path, originalPath } = parseCopyOrRename(path, false));\n\n\t\t\t\t// Look up --raw info for this path (keyed by the new/destination path)\n\t\t\t\tconst info = infoMap.get(path);\n\n\t\t\t\t// Use status from --raw if available; provides accurate status (A/D/M/R/C/T)\n\t\t\t\tconst status = info?.status ?? (originalPath ? 'R' : 'M');\n\n\t\t\t\t// Use originalPath from --raw if available (cleaner than numstat format)\n\t\t\t\tif (info?.originalPath) {\n\t\t\t\t\toriginalPath = info.originalPath;\n\t\t\t\t}\n\n\t\t\t\tconst file: LogParsedFileWithStats = {\n\t\t\t\t\tstatus: status,\n\t\t\t\t\tpath: path,\n\t\t\t\t\toriginalPath: originalPath,\n\t\t\t\t\tadditions: additions === '-' ? 0 : parseInt(additions, 10) || 0,\n\t\t\t\t\tdeletions: deletions === '-' ? 0 : parseInt(deletions, 10) || 0,\n\t\t\t\t\t// Store mode for consumers to derive file type (160000=submodule, 100755=executable, etc.)\n\t\t\t\t\tmode: info?.mode,\n\t\t\t\t\toid: info?.oid,\n\t\t\t\t\tpreviousOid: info?.previousOid,\n\t\t\t\t};\n\n\t\t\t\tfiles.push(file);\n\t\t\t}\n\t\t}\n\n\t\treturn files;\n\t}\n\n\tfunction* parse(data: string | Iterable<string> | undefined): Generator<LogParsedEntryWithFilesAndStats<T>> {\n\t\tusing sw = maybeStopWatch('Git.LogParserWithFilesAndStats.parse', { log: { onlyExit: true, level: 'debug' } });\n\n\t\tif (!data) {\n\t\t\tsw?.stop({ suffix: ` no data` });\n\t\t\treturn;\n\t\t}\n\n\t\tconst records = iterateByDelimiter(data, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntryWithFilesAndStats<T>;\n\t\tlet files: LogParsedFileWithStats[];\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor (const record of records) {\n\t\t\tif (!record.length) continue;\n\n\t\t\tcount++;\n\t\t\tentry = {} as unknown as LogParsedEntryWithFilesAndStats<T>;\n\t\t\tfiles = [];\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\n\t\t\t\tif (fieldCount < keys.length) {\n\t\t\t\t\tentry[keys[fieldCount++]] = field.value as LogParsedEntryWithFilesAndStats<T>[keyof T];\n\t\t\t\t} else if (fieldCount === keys.length) {\n\t\t\t\t\t// Slice off the first newlines between the commits and files/summary, if any\n\t\t\t\t\tconst summary = field.value.startsWith('\\n\\n')\n\t\t\t\t\t\t? field.value.substring(2)\n\t\t\t\t\t\t: field.value.startsWith('\\n')\n\t\t\t\t\t\t\t? field.value.substring(1)\n\t\t\t\t\t\t\t: field.value;\n\t\t\t\t\tappendAll(files, parseFilesAndStats(summary));\n\t\t\t\t} else {\n\t\t\t\t\tdebugger;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tentry.files = files;\n\t\t\tif (files.length) {\n\t\t\t\tentry.stats = { additions: 0, deletions: 0, files: { added: 0, deleted: 0, changed: 0 } };\n\n\t\t\t\tfor (const f of files) {\n\t\t\t\t\tif (f.additions || f.deletions) {\n\t\t\t\t\t\tentry.stats.additions += f.additions ?? 0;\n\t\t\t\t\t\tentry.stats.deletions += f.deletions ?? 0;\n\t\t\t\t\t\tif (f.status === 'A' || f.status === '?') {\n\t\t\t\t\t\t\tentry.stats.files.added++;\n\t\t\t\t\t\t} else if (f.status === 'D') {\n\t\t\t\t\t\t\tentry.stats.files.deleted++;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tentry.stats.files.changed++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\tasync function* parseAsync(stream: AsyncGenerator<string>): AsyncGenerator<LogParsedEntryWithFilesAndStats<T>> {\n\t\tusing sw = maybeStopWatch('Git.LogParserWithFilesAndStats.parseAsync', {\n\t\t\tlog: { onlyExit: true, level: 'debug' },\n\t\t});\n\n\t\tconst records = iterateAsyncByDelimiter(stream, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntryWithFilesAndStats<T>;\n\t\tlet files: LogParsedFileWithStats[];\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor await (const record of records) {\n\t\t\tif (!record.length) continue;\n\t\t\t// Drop a truncated tail (cancelled/early-closed stream) instead of yielding undefined/partial fields.\n\t\t\tif (!isCompleteRecord(record, keys.length)) continue;\n\n\t\t\tcount++;\n\t\t\tentry = {} as unknown as LogParsedEntryWithFilesAndStats<T>;\n\t\t\tfiles = [];\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\n\t\t\t\tif (fieldCount < keys.length) {\n\t\t\t\t\tentry[keys[fieldCount++]] = field.value as LogParsedEntryWithFilesAndStats<T>[keyof T];\n\t\t\t\t} else if (fieldCount === keys.length) {\n\t\t\t\t\t// Slice off the first newlines between the commits and files/summary, if any\n\t\t\t\t\tconst summary = field.value.startsWith('\\n\\n')\n\t\t\t\t\t\t? field.value.substring(2)\n\t\t\t\t\t\t: field.value.startsWith('\\n')\n\t\t\t\t\t\t\t? field.value.substring(1)\n\t\t\t\t\t\t\t: field.value;\n\t\t\t\t\tappendAll(files, parseFilesAndStats(summary));\n\t\t\t\t} else {\n\t\t\t\t\tdebugger;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tentry.files = files;\n\t\t\tif (files.length) {\n\t\t\t\tentry.stats = { additions: 0, deletions: 0, files: { added: 0, deleted: 0, changed: 0 } };\n\n\t\t\t\tfor (const f of files) {\n\t\t\t\t\tif (f.additions || f.deletions) {\n\t\t\t\t\t\tentry.stats.additions += f.additions ?? 0;\n\t\t\t\t\t\tentry.stats.deletions += f.deletions ?? 0;\n\t\t\t\t\t\tif (f.status === 'A' || f.status === '?') {\n\t\t\t\t\t\t\tentry.stats.files.added++;\n\t\t\t\t\t\t} else if (f.status === 'D') {\n\t\t\t\t\t\t\tentry.stats.files.deleted++;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tentry.stats.files.changed++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\treturn {\n\t\targuments: args,\n\t\tseparators: { record: recordSep, field: fieldSep },\n\t\tparse: parse,\n\t\tparseAsync: parseAsync,\n\t};\n}\n\nfunction createLogParserWithFileSummary(): LogParserWithFileSummary<void>;\nfunction createLogParserWithFileSummary<T extends Record<string, string>>(\n\tmapping: ExtractAll<T, string>,\n): LogParserWithFileSummary<T>;\nfunction createLogParserWithFileSummary<T extends Record<string, string> | void>(\n\tmapping?: ExtractAll<T, string>,\n): LogParserWithFileSummary<T> {\n\tlet format = recordFormatSep;\n\tconst keys: (keyof ExtractAll<T, string>)[] = [];\n\tif (mapping != null) {\n\t\tfor (const key in mapping) {\n\t\t\tkeys.push(key);\n\t\t\tformat += `${mapping[key]}${fieldFormatSep}`;\n\t\t}\n\t}\n\tconst args = [`--format=${format}`, '--summary'];\n\n\tfunction parseFileSummary(content: string): LogParsedFile[] {\n\t\tconst files: LogParsedFile[] = [];\n\t\tif (!content?.length) return files;\n\n\t\tlet startIndex;\n\n\t\tlet path;\n\t\tlet originalPath;\n\t\tlet status;\n\n\t\tfor (const line of iterateByDelimiter(content, '\\n')) {\n\t\t\tif (!line) continue;\n\n\t\t\tif (line.startsWith(' rename ')) {\n\t\t\t\t({ path, originalPath } = parseCopyOrRename(line.substring(8 /* move past ' rename ' */), true));\n\t\t\t\tfiles.push({ path: path, originalPath: originalPath, status: 'R' });\n\t\t\t} else if (line.startsWith(' copy ')) {\n\t\t\t\t({ path, originalPath } = parseCopyOrRename(line.substring(6 /* move past ' copy ' */), true));\n\t\t\t\tfiles.push({ path: path, originalPath: originalPath, status: 'C' });\n\t\t\t} else {\n\t\t\t\tif (line.startsWith(' create mode ')) {\n\t\t\t\t\tstatus = 'A';\n\t\t\t\t} else if (line.startsWith(' delete mode ')) {\n\t\t\t\t\tstatus = 'D';\n\t\t\t\t} else {\n\t\t\t\t\t// Ignore \" mode change \" lines\n\t\t\t\t\tif (!line.startsWith(' mode change ')) {\n\t\t\t\t\t\tdebugger;\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tstartIndex = line.indexOf(' ', 13 /* move past 'create mode <num>' or 'delete mode <num>' */);\n\t\t\t\tif (startIndex > -1) {\n\t\t\t\t\tpath = unquoteCString(line.substring(startIndex + 1));\n\t\t\t\t\tfiles.push({ path: path, status: status });\n\t\t\t\t} else {\n\t\t\t\t\tdebugger;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn files;\n\t}\n\n\tfunction* parse(data: string | Iterable<string> | undefined): Generator<LogParsedEntryWithFiles<T>> {\n\t\tusing sw = maybeStopWatch('Git.LogParserWithFileSummary.parse', { log: { onlyExit: true, level: 'debug' } });\n\n\t\tif (!data) {\n\t\t\tsw?.stop({ suffix: ` no data` });\n\t\t\treturn;\n\t\t}\n\n\t\tconst records = iterateByDelimiter(data, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntryWithFiles<T>;\n\t\tlet files: LogParsedFile[];\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor (const record of records) {\n\t\t\tif (!record.length) continue;\n\n\t\t\tcount++;\n\t\t\tentry = {} as unknown as LogParsedEntryWithFiles<T>;\n\t\t\tfiles = [];\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\n\t\t\t\tif (fieldCount < keys.length) {\n\t\t\t\t\tentry[keys[fieldCount++]] = field.value as LogParsedEntryWithFiles<T>[keyof T];\n\t\t\t\t} else if (fieldCount === keys.length) {\n\t\t\t\t\t// Slice off the first newlines between the commits and files/summary, if any\n\t\t\t\t\tconst summary = field.value.startsWith('\\n\\n')\n\t\t\t\t\t\t? field.value.substring(2)\n\t\t\t\t\t\t: field.value.startsWith('\\n')\n\t\t\t\t\t\t\t? field.value.substring(1)\n\t\t\t\t\t\t\t: field.value;\n\t\t\t\t\tappendAll(files, parseFileSummary(summary));\n\t\t\t\t} else {\n\t\t\t\t\tdebugger;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tentry.files = files;\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\treturn {\n\t\targuments: args,\n\t\tseparators: { record: recordSep, field: fieldSep },\n\t\tparse: parse,\n\t};\n}\n\n/**\n * Reads a numstat or summary name, or the two names of a rename or copy, trimmed as git wrote them: an unquoted name\n * is trimmed, while a quoted one keeps the whitespace inside its quotes\n */\nfunction parseCopyOrRename(field: string, stripPercentage: boolean): { path: string; originalPath?: string } {\n\tconst path = field.trim();\n\tif (path.includes('\"')) {\n\t\tconst quoted = parseQuotedRenameOrCopyPaths(path, stripPercentage);\n\t\tif (quoted != null) return quoted;\n\t}\n\n\tconst renameIndex = path.indexOf(' => ');\n\tif (renameIndex === -1) return { path: path };\n\n\tlet hasBraces = true;\n\n\tlet openIndex = path.indexOf('{');\n\tif (openIndex === -1) {\n\t\thasBraces = false;\n\t\topenIndex = 0;\n\t}\n\n\tlet closeIndex = path.indexOf('}', openIndex);\n\tif (closeIndex === -1) {\n\t\thasBraces = false;\n\t\tcloseIndex = path.length;\n\t}\n\n\tconst prefix = path.substring(0, openIndex);\n\tconst fromPart = path.substring(hasBraces ? openIndex + 1 : 0, renameIndex);\n\tlet toPart = path.substring(renameIndex + 4, closeIndex);\n\tlet suffix = path.substring(closeIndex + 1);\n\n\t// Check for percentage marker which always appears at the end as (xx%)\n\tif (stripPercentage) {\n\t\tif (hasBraces) {\n\t\t\tif (suffix.endsWith('%)')) {\n\t\t\t\t// Find the last open paren that starts the percentage\n\t\t\t\tconst percentPos = suffix.lastIndexOf(' (');\n\t\t\t\tif (percentPos > -1) {\n\t\t\t\t\tsuffix = suffix.substring(0, percentPos);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (toPart.endsWith('%)')) {\n\t\t\t// Find the last open paren that starts the percentage\n\t\t\tconst percentPos = toPart.lastIndexOf(' (');\n\t\t\tif (percentPos > -1) {\n\t\t\t\ttoPart = toPart.substring(0, percentPos);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tpath: normalizePath(joinPaths(prefix, toPart, suffix).trim()),\n\t\toriginalPath: normalizePath(joinPaths(prefix, fromPart, suffix).trim()),\n\t};\n}\n\nfunction createLogParserSingle(field: string): Parser<string> {\n\tconst args = ['-z', `--format=${field}`];\n\n\tfunction parse(data: string | Iterable<string> | undefined): Iterable<string> {\n\t\tusing _sw = maybeStopWatch('Git.LogParserSingle.parse', { log: { onlyExit: true, level: 'debug' } });\n\n\t\treturn data ? iterateByDelimiter(data, '\\0') : [];\n\t}\n\n\treturn { arguments: args, separators: { record: '\\0', field: '\\0' }, parse: parse };\n}\n\nfunction createLogParserWithPatch<T extends Record<string, string>>(\n\tmapping: ExtractAll<T, string>,\n): LogParserWithFiles<T> {\n\tlet format = recordFormatSep;\n\tconst keys: (keyof ExtractAll<T, string>)[] = [];\n\tfor (const key in mapping) {\n\t\tkeys.push(key);\n\t\tformat += `${mapping[key]}${fieldFormatSep}`;\n\t}\n\n\tconst args = [`--format=${format}`];\n\n\tfunction parsePatch(content: string): LogParsedFile | undefined {\n\t\tconst lines = iterateByDelimiter(content, '\\n');\n\t\tlet line = lines.next();\n\t\tif (line.done) return undefined;\n\n\t\tif (!content.startsWith('diff --git ')) return undefined;\n\n\t\tconst paths = parseDiffFilePaths(content);\n\t\tif (paths == null) return undefined;\n\n\t\twhile (!line.done && !line.value.startsWith('@@ ')) {\n\t\t\tline = lines.next();\n\t\t}\n\n\t\tconst rangeMatch = line.value.match(diffHunkRegex);\n\n\t\tlet range: LogParsedRange | undefined;\n\t\tlet originalRange: LogParsedRange | undefined;\n\t\tif (rangeMatch != null) {\n\t\t\tlet start = parseInt(rangeMatch[1], 10);\n\t\t\tlet count = rangeMatch[2] ? parseInt(rangeMatch[2], 10) : 1;\n\n\t\t\toriginalRange = start && count ? { startLine: start, endLine: start + count - 1 } : undefined;\n\n\t\t\tstart = parseInt(rangeMatch[3], 10);\n\t\t\tcount = rangeMatch[4] ? parseInt(rangeMatch[4], 10) : 1;\n\n\t\t\trange = start && count ? { startLine: start, endLine: start + count - 1 } : undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tstatus: 'M' satisfies GitFileIndexStatus,\n\t\t\tpath: paths.path,\n\t\t\toriginalPath: undefined,\n\t\t\trange: range,\n\t\t\toriginalRange: originalRange,\n\t\t};\n\t}\n\n\tfunction* parse(data: string | Iterable<string> | undefined): Generator<LogParsedEntryWithFiles<T>> {\n\t\tusing sw = maybeStopWatch('Git.LogParserWithPatch.parse', { log: { onlyExit: true, level: 'debug' } });\n\n\t\tif (!data) {\n\t\t\tsw?.stop({ suffix: ` no data` });\n\t\t\treturn;\n\t\t}\n\n\t\tconst records = iterateByDelimiter(data, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntryWithFiles<T>;\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor (const record of records) {\n\t\t\tif (!record.length) continue;\n\n\t\t\tcount++;\n\t\t\tentry = {} as unknown as LogParsedEntryWithFiles<T>;\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\n\t\t\t\tif (fieldCount < keys.length) {\n\t\t\t\t\tentry[keys[fieldCount++]] = field.value as LogParsedEntryWithFiles<T>[keyof T];\n\t\t\t\t} else if (fieldCount === keys.length) {\n\t\t\t\t\t// Slice off the first newlines between the commit data and patch, if any\n\t\t\t\t\tconst patch = field.value.startsWith('\\n\\n')\n\t\t\t\t\t\t? field.value.substring(2)\n\t\t\t\t\t\t: field.value.startsWith('\\n')\n\t\t\t\t\t\t\t? field.value.substring(1)\n\t\t\t\t\t\t\t: field.value;\n\t\t\t\t\tconst file = parsePatch(patch);\n\t\t\t\t\tentry.files = file != null ? [file] : [];\n\t\t\t\t} else {\n\t\t\t\t\tdebugger;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\tasync function* parseAsync(stream: AsyncGenerator<string>): AsyncGenerator<LogParsedEntryWithFiles<T>> {\n\t\tusing sw = maybeStopWatch('Git.LogParserWithPatch.parseAsync', { log: { onlyExit: true, level: 'debug' } });\n\n\t\tconst records = iterateAsyncByDelimiter(stream, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntryWithFiles<T>;\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor await (const record of records) {\n\t\t\tif (!record.length) continue;\n\t\t\t// Drop a truncated tail (cancelled/early-closed stream) instead of yielding undefined/partial fields.\n\t\t\tif (!isCompleteRecord(record, keys.length)) continue;\n\n\t\t\tcount++;\n\t\t\tentry = {} as unknown as LogParsedEntryWithFiles<T>;\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\n\t\t\t\tif (fieldCount < keys.length) {\n\t\t\t\t\tentry[keys[fieldCount++]] = field.value as LogParsedEntryWithFiles<T>[keyof T];\n\t\t\t\t} else if (fieldCount === keys.length) {\n\t\t\t\t\t// Slice off the first newlines between the commit data and patch, if any\n\t\t\t\t\tconst patch = field.value.startsWith('\\n\\n')\n\t\t\t\t\t\t? field.value.substring(2)\n\t\t\t\t\t\t: field.value.startsWith('\\n')\n\t\t\t\t\t\t\t? field.value.substring(1)\n\t\t\t\t\t\t\t: field.value;\n\t\t\t\t\tconst file = parsePatch(patch);\n\t\t\t\t\tentry.files = file != null ? [file] : [];\n\t\t\t\t} else {\n\t\t\t\t\tdebugger;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\treturn {\n\t\targuments: args,\n\t\tseparators: { record: recordSep, field: fieldSep },\n\t\tparse: parse,\n\t\tparseAsync: parseAsync,\n\t};\n}\n\nfunction createLogParserWithStats<T extends Record<string, string>>(\n\tmapping: ExtractAll<T, string>,\n): LogParserWithStats<T> {\n\tlet format = recordFormatSep;\n\tconst keys: (keyof ExtractAll<T, string>)[] = [];\n\tfor (const key in mapping) {\n\t\tkeys.push(key);\n\t\tformat += `${mapping[key]}${fieldFormatSep}`;\n\t}\n\n\tconst args = [`--format=${format}`, '--shortstat'];\n\n\tfunction parseStats(content: string): LogParsedStats {\n\t\tconst stats: LogParsedStats = { files: 0, additions: 0, deletions: 0 };\n\t\tcontent = content?.trim();\n\t\tif (!content?.length) return { files: 0, additions: 0, deletions: 0 };\n\n\t\tlet filesEnd;\n\t\tlet filesIndex = content.indexOf(' files changed');\n\t\tif (filesIndex === -1) {\n\t\t\tfilesIndex = content.indexOf(' file changed');\n\t\t\tif (filesIndex === -1) return stats;\n\n\t\t\tfilesEnd = filesIndex + ' file changed'.length;\n\t\t} else {\n\t\t\tfilesEnd = filesIndex + ' files changed'.length;\n\t\t}\n\n\t\t// Extract number before \" files changed\"\n\t\tconst filesPart = content.substring(0, filesIndex).trim();\n\t\tstats.files = parseInt(filesPart, 10) || 0;\n\n\t\t// Extract additions if present\n\t\tconst additionsIndex = content.indexOf(' insertion', filesEnd);\n\t\tif (additionsIndex !== -1) {\n\t\t\t// Look for the number before \"insertion(+)\" or \"insertions(+)\"\n\t\t\tconst spaceIndex = content.lastIndexOf(' ', additionsIndex - 1);\n\t\t\tif (spaceIndex !== -1) {\n\t\t\t\tconst additionsPart = content.substring(spaceIndex, additionsIndex).trim();\n\t\t\t\tstats.additions = parseInt(additionsPart, 10) || 0;\n\t\t\t}\n\t\t}\n\n\t\t// Extract deletions if present\n\t\tconst deletionsIndex = content.indexOf(' deletion', filesEnd);\n\t\tif (deletionsIndex !== -1) {\n\t\t\t// Look for the number before \"\"deletion(-)\" or \"deletions(-)\"\n\t\t\tconst spaceIndex = content.lastIndexOf(' ', deletionsIndex - 1);\n\t\t\tif (spaceIndex !== -1) {\n\t\t\t\tconst deletionsPart = content.substring(spaceIndex, deletionsIndex).trim();\n\t\t\t\tstats.deletions = parseInt(deletionsPart, 10) || 0;\n\t\t\t}\n\t\t}\n\n\t\treturn stats;\n\t}\n\n\tfunction* parse(data: string | Iterable<string> | undefined): Generator<LogParsedEntryWithStats<T>> {\n\t\tusing sw = maybeStopWatch('Git.LogParserWithStats.parse', { log: { onlyExit: true, level: 'debug' } });\n\n\t\tif (!data) {\n\t\t\tsw?.stop({ suffix: ` no data` });\n\t\t\treturn;\n\t\t}\n\n\t\tconst records = iterateByDelimiter(data, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntryWithStats<T>;\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor (const record of records) {\n\t\t\tif (!record.length) continue;\n\n\t\t\tcount++;\n\t\t\tentry = {} as unknown as LogParsedEntryWithStats<T>;\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\n\t\t\t\tif (fieldCount < keys.length) {\n\t\t\t\t\tentry[keys[fieldCount++]] = field.value as LogParsedEntryWithStats<T>[keyof T];\n\t\t\t\t} else if (fieldCount === keys.length) {\n\t\t\t\t\t// Slice off the first newlines between the commit data and files/summary, if any\n\t\t\t\t\tconst summary = field.value.startsWith('\\n\\n')\n\t\t\t\t\t\t? field.value.substring(2)\n\t\t\t\t\t\t: field.value.startsWith('\\n')\n\t\t\t\t\t\t\t? field.value.substring(1)\n\t\t\t\t\t\t\t: field.value;\n\t\t\t\t\tentry.stats = parseStats(summary);\n\t\t\t\t} else {\n\t\t\t\t\tdebugger;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\tasync function* parseAsync(stream: AsyncGenerator<string>): AsyncGenerator<LogParsedEntryWithStats<T>> {\n\t\tusing sw = maybeStopWatch('Git.LogParserWithStats.parseAsync', { log: { onlyExit: true, level: 'debug' } });\n\n\t\tconst records = iterateAsyncByDelimiter(stream, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntryWithStats<T>;\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor await (const record of records) {\n\t\t\tif (!record.length) continue;\n\n\t\t\tcount++;\n\t\t\tentry = {} as unknown as LogParsedEntryWithStats<T>;\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\n\t\t\t\tif (fieldCount < keys.length) {\n\t\t\t\t\tentry[keys[fieldCount++]] = field.value as LogParsedEntryWithStats<T>[keyof T];\n\t\t\t\t} else if (fieldCount === keys.length) {\n\t\t\t\t\t// Slice off the first newlines between the commit data and files/summary, if any\n\t\t\t\t\tconst summary = field.value.startsWith('\\n\\n')\n\t\t\t\t\t\t? field.value.substring(2)\n\t\t\t\t\t\t: field.value.startsWith('\\n')\n\t\t\t\t\t\t\t? field.value.substring(1)\n\t\t\t\t\t\t\t: field.value;\n\t\t\t\t\tentry.stats = parseStats(summary);\n\t\t\t\t} else {\n\t\t\t\t\tdebugger;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\treturn {\n\t\targuments: args,\n\t\tseparators: { record: recordSep, field: fieldSep },\n\t\tparse: parse,\n\t\tparseAsync: parseAsync,\n\t};\n}\n\nfunction createLogParserWithFiles<T extends Record<string, string>>(\n\tmapping: ExtractAll<T, string>,\n): LogParserWithFiles<T> {\n\tlet format = recordFormatSep;\n\tconst keys: (keyof ExtractAll<T, string>)[] = [];\n\tfor (const key in mapping) {\n\t\tkeys.push(key);\n\t\tformat += `${mapping[key]}${fieldFormatSep}`;\n\t}\n\n\tconst args = [`--format=${format}`, '--name-only'];\n\n\tfunction parseFileNames(content: string): LogParsedFile[] {\n\t\tconst files: LogParsedFile[] = [];\n\t\tif (!content?.length) return files;\n\n\t\tfor (const line of iterateByDelimiter(content, '\\n')) {\n\t\t\tconst trimmed = line.trim();\n\t\t\tif (!trimmed) continue;\n\n\t\t\tfiles.push({ path: unquoteCString(trimmed) });\n\t\t}\n\n\t\treturn files;\n\t}\n\n\tfunction* parse(data: string | Iterable<string> | undefined): Generator<LogParsedEntryWithFiles<T>> {\n\t\tusing sw = maybeStopWatch('Git.createLogParserWithFiles.parse', { log: { onlyExit: true, level: 'debug' } });\n\n\t\tif (!data) {\n\t\t\tsw?.stop({ suffix: ` no data` });\n\t\t\treturn;\n\t\t}\n\n\t\tconst records = iterateByDelimiter(data, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntryWithFiles<T>;\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor (const record of records) {\n\t\t\tif (!record.length) continue;\n\n\t\t\tcount++;\n\t\t\tentry = {} as unknown as LogParsedEntryWithFiles<T>;\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\n\t\t\t\tif (fieldCount < keys.length) {\n\t\t\t\t\tentry[keys[fieldCount++]] = field.value as LogParsedEntryWithFiles<T>[keyof T];\n\t\t\t\t} else if (fieldCount === keys.length) {\n\t\t\t\t\t// Slice off the first newlines between the commit data and files, if any\n\t\t\t\t\tconst files = field.value.startsWith('\\n\\n')\n\t\t\t\t\t\t? field.value.substring(2)\n\t\t\t\t\t\t: field.value.startsWith('\\n')\n\t\t\t\t\t\t\t? field.value.substring(1)\n\t\t\t\t\t\t\t: field.value;\n\t\t\t\t\tentry.files = parseFileNames(files);\n\t\t\t\t} else {\n\t\t\t\t\tdebugger;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\tasync function* parseAsync(stream: AsyncGenerator<string>): AsyncGenerator<LogParsedEntryWithFiles<T>> {\n\t\tusing sw = maybeStopWatch('Git.createLogParserWithFiles.parseAsync', {\n\t\t\tlog: { onlyExit: true, level: 'debug' },\n\t\t});\n\n\t\tconst records = iterateAsyncByDelimiter(stream, recordSep);\n\n\t\tlet count = 0;\n\t\tlet entry: LogParsedEntryWithFiles<T>;\n\t\tlet fields: IterableIterator<string>;\n\n\t\tfor await (const record of records) {\n\t\t\tif (!record.length) continue;\n\n\t\t\tcount++;\n\t\t\tentry = {} as unknown as LogParsedEntryWithFiles<T>;\n\t\t\tfields = iterateByDelimiter(record, fieldSep);\n\n\t\t\tlet fieldCount = 0;\n\t\t\tlet field;\n\t\t\twhile (true) {\n\t\t\t\tfield = fields.next();\n\t\t\t\tif (field.done) break;\n\n\t\t\t\tif (fieldCount < keys.length) {\n\t\t\t\t\tentry[keys[fieldCount++]] = field.value as LogParsedEntryWithFiles<T>[keyof T];\n\t\t\t\t} else if (fieldCount === keys.length) {\n\t\t\t\t\t// Slice off the first newlines between the commit data and files, if any\n\t\t\t\t\tconst files = field.value.startsWith('\\n\\n')\n\t\t\t\t\t\t? field.value.substring(2)\n\t\t\t\t\t\t: field.value.startsWith('\\n')\n\t\t\t\t\t\t\t? field.value.substring(1)\n\t\t\t\t\t\t\t: field.value;\n\t\t\t\t\tentry.files = parseFileNames(files);\n\t\t\t\t} else {\n\t\t\t\t\tdebugger;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tyield entry;\n\t\t}\n\n\t\tsw?.stop({ suffix: ` parsed ${count} records` });\n\t}\n\n\treturn {\n\t\targuments: args,\n\t\tseparators: { record: recordSep, field: fieldSep },\n\t\tparse: parse,\n\t\tparseAsync: parseAsync,\n\t};\n}\n"],"mappings":";;;;;;AAOA,MAAM,iBAAiB;CACtB,KAAK;CACL,QAAQ;CACR,aAAa;CACb,YAAY;CACZ,WAAW;CACX,gBAAgB;CAChB,eAAe;CACf,SAAS;CACT,MAAM;CACN,SAAS;AACV;AAGA,IAAI;AAEJ,IAAI;AAEJ,IAAI;AAOJ,SAAgB,oBACf,cACA,aAC6E;CAC7E,IAAI,aAAa;EAChB,8BAA8B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sers/statusParser.d.ts
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Parses `git status --porcelain[=v2]` output. `-z` output (every record ends with NUL, so a name is exactly as it is on
|
|
6
|
+
* disk) is told by its NUL; without `-z` git C-quotes a name holding a `"`, `\`, tab or newline, which is read as written.
|
|
7
|
+
* Without `getUri`, each file builds its uri on first read rather than during the parse
|
|
8
|
+
*/
|
|
5
9
|
export declare function parseGitStatus(data: string, repoPath: string, porcelainVersion: number, getUri?: (path: string) => Uri): GitStatus | undefined;
|
|
6
10
|
/**
|
|
7
11
|
* Folds `status --ignored=matching --untracked-files=all` records of new untracked folders into the entries that
|
|
@@ -7,6 +7,7 @@ import _usingCtx from "../../_virtual/@oxc-project+runtime/helpers/esm/usingCtx.
|
|
|
7
7
|
const aheadStatusV1Regex = /(?:ahead ([0-9]+))/;
|
|
8
8
|
const behindStatusV1Regex = /(?:behind ([0-9]+))/;
|
|
9
9
|
const quoteRegex = /"/g;
|
|
10
|
+
const renameStatusV1Regex = /[RC]/;
|
|
10
11
|
const submoduleCharCode = "S".charCodeAt(0);
|
|
11
12
|
/** Returns the index just after the `n`th space, or -1 if the line has fewer than `n` spaces. */
|
|
12
13
|
function indexAfterNthSpace(line, n) {
|
|
@@ -17,7 +18,11 @@ function indexAfterNthSpace(line, n) {
|
|
|
17
18
|
}
|
|
18
19
|
return index + 1;
|
|
19
20
|
}
|
|
20
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Parses `git status --porcelain[=v2]` output. `-z` output (every record ends with NUL, so a name is exactly as it is on
|
|
23
|
+
* disk) is told by its NUL; without `-z` git C-quotes a name holding a `"`, `\`, tab or newline, which is read as written.
|
|
24
|
+
* Without `getUri`, each file builds its uri on first read rather than during the parse
|
|
25
|
+
*/
|
|
21
26
|
function parseGitStatus(data, repoPath, porcelainVersion, getUri) {
|
|
22
27
|
try {
|
|
23
28
|
var _usingCtx$1 = _usingCtx();
|
|
@@ -29,12 +34,13 @@ function parseGitStatus(data, repoPath, porcelainVersion, getUri) {
|
|
|
29
34
|
sw?.stop({ suffix: ` no data` });
|
|
30
35
|
return;
|
|
31
36
|
}
|
|
32
|
-
const
|
|
37
|
+
const nullTerminated = data.includes("\0");
|
|
38
|
+
const lines = data.split(nullTerminated ? "\0" : "\n").filter((i) => Boolean(i));
|
|
33
39
|
if (lines.length === 0) {
|
|
34
40
|
sw?.stop({ suffix: ` parsed no files` });
|
|
35
41
|
return;
|
|
36
42
|
}
|
|
37
|
-
const status = porcelainVersion < 2 ? parseStatusV1(lines, repoPath, getUri) : parseStatusV2(lines, repoPath, getUri);
|
|
43
|
+
const status = porcelainVersion < 2 ? parseStatusV1(lines, repoPath, getUri, nullTerminated) : parseStatusV2(lines, repoPath, getUri, nullTerminated);
|
|
38
44
|
sw?.stop({ suffix: ` parsed ${status.files.length} files` });
|
|
39
45
|
return status;
|
|
40
46
|
} catch (_) {
|
|
@@ -43,7 +49,7 @@ function parseGitStatus(data, repoPath, porcelainVersion, getUri) {
|
|
|
43
49
|
_usingCtx$1.d();
|
|
44
50
|
}
|
|
45
51
|
}
|
|
46
|
-
function parseStatusV1(lines, repoPath, getUri) {
|
|
52
|
+
function parseStatusV1(lines, repoPath, getUri, nullTerminated) {
|
|
47
53
|
let branch;
|
|
48
54
|
const files = [];
|
|
49
55
|
const state = {
|
|
@@ -74,7 +80,8 @@ function parseStatusV1(lines, repoPath, getUri) {
|
|
|
74
80
|
} else {
|
|
75
81
|
const rawStatus = line.substring(0, 2);
|
|
76
82
|
const fileName = line.substring(3);
|
|
77
|
-
if (
|
|
83
|
+
if (nullTerminated && renameStatusV1Regex.test(rawStatus)) files.push(parseStatusFile(repoPath, rawStatus, fileName, getUri, lines[++position]));
|
|
84
|
+
else if (!nullTerminated && (rawStatus.startsWith("R") || rawStatus.startsWith("C"))) {
|
|
78
85
|
const [file1, file2] = fileName.replace(quoteRegex, "").split(" -> ");
|
|
79
86
|
files.push(parseStatusFile(repoPath, rawStatus, file2.trim(), getUri, file1.trim()));
|
|
80
87
|
} else files.push(parseStatusFile(repoPath, rawStatus, fileName, getUri));
|
|
@@ -86,7 +93,7 @@ function parseStatusV1(lines, repoPath, getUri) {
|
|
|
86
93
|
state
|
|
87
94
|
} : void 0);
|
|
88
95
|
}
|
|
89
|
-
function parseStatusV2(lines, repoPath, getUri) {
|
|
96
|
+
function parseStatusV2(lines, repoPath, getUri, nullTerminated) {
|
|
90
97
|
let branch;
|
|
91
98
|
const files = [];
|
|
92
99
|
let sha;
|
|
@@ -142,6 +149,10 @@ function parseStatusV2(lines, repoPath, getUri) {
|
|
|
142
149
|
previousOid: parts[6]
|
|
143
150
|
};
|
|
144
151
|
}
|
|
152
|
+
if (nullTerminated) {
|
|
153
|
+
files.push(parseStatusFile(repoPath, line.substring(2, 4), line.substring(pathStart), getUri, lines[++position], submodule));
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
145
156
|
const tab = line.indexOf(" ", pathStart);
|
|
146
157
|
files.push(parseStatusFile(repoPath, line.substring(2, 4), tab === -1 ? line.substring(pathStart) : line.substring(pathStart, tab), getUri, tab === -1 ? void 0 : line.substring(tab + 1), submodule));
|
|
147
158
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statusParser.js","names":[],"sources":["../../../../git-cli/src/parsers/statusParser.ts"],"sourcesContent":["import { GitStatus } from '@gitlens/git/models/status.js';\nimport { GitStatusFile } from '@gitlens/git/models/statusFile.js';\nimport { normalizePath } from '@gitlens/utils/path.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\n\nconst aheadStatusV1Regex = /(?:ahead ([0-9]+))/;\nconst behindStatusV1Regex = /(?:behind ([0-9]+))/;\nconst quoteRegex = /\"/g;\nconst submoduleCharCode = 'S'.charCodeAt(0);\n\n/** Returns the index just after the `n`th space, or -1 if the line has fewer than `n` spaces. */\nfunction indexAfterNthSpace(line: string, n: number): number {\n\tlet index = -1;\n\tfor (let i = 0; i < n; i++) {\n\t\tindex = line.indexOf(' ', index + 1);\n\t\tif (index === -1) return -1;\n\t}\n\n\treturn index + 1;\n}\n\n/** Without `getUri`, each file builds its uri on first read rather than during the parse */\nexport function parseGitStatus(\n\tdata: string,\n\trepoPath: string,\n\tporcelainVersion: number,\n\tgetUri?: (path: string) => Uri,\n): GitStatus | undefined {\n\tusing sw = maybeStopWatch(`Git.parseStatus(${repoPath}, v=${porcelainVersion})`, {\n\t\tlog: { onlyExit: true, level: 'debug' },\n\t});\n\tif (!data) {\n\t\tsw?.stop({ suffix: ` no data` });\n\t\treturn undefined;\n\t}\n\n\tconst lines = data.split('\\n').filter(<T>(i?: T): i is T => Boolean(i));\n\tif (lines.length === 0) {\n\t\tsw?.stop({ suffix: ` parsed no files` });\n\t\treturn undefined;\n\t}\n\n\tconst status =\n\t\tporcelainVersion < 2 ? parseStatusV1(lines, repoPath, getUri) : parseStatusV2(lines, repoPath, getUri);\n\n\tsw?.stop({ suffix: ` parsed ${status.files.length} files` });\n\n\treturn status;\n}\n\nfunction parseStatusV1(lines: string[], repoPath: string, getUri: ((path: string) => Uri) | undefined): GitStatus {\n\tlet branch: string | undefined;\n\tconst files = [];\n\tconst state = {\n\t\tahead: 0,\n\t\tbehind: 0,\n\t};\n\tlet upstream;\n\tlet missing = false;\n\n\tlet position = -1;\n\twhile (++position < lines.length) {\n\t\tconst line = lines[position];\n\t\t// Header\n\t\tif (line.startsWith('##')) {\n\t\t\tconst lineParts = line.split(' ');\n\t\t\t[branch, upstream] = lineParts[1].split('...');\n\t\t\tif (lineParts.length > 2) {\n\t\t\t\tconst upstreamStatus = lineParts.slice(2).join(' ');\n\t\t\t\tif (upstreamStatus === '[gone]') {\n\t\t\t\t\tmissing = true;\n\t\t\t\t\tstate.ahead = 0;\n\t\t\t\t\tstate.behind = 0;\n\t\t\t\t} else {\n\t\t\t\t\tconst aheadStatus = aheadStatusV1Regex.exec(upstreamStatus);\n\t\t\t\t\tstate.ahead = aheadStatus == null ? 0 : Number(aheadStatus[1]) || 0;\n\n\t\t\t\t\tconst behindStatus = behindStatusV1Regex.exec(upstreamStatus);\n\t\t\t\t\tstate.behind = behindStatus == null ? 0 : Number(behindStatus[1]) || 0;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst rawStatus = line.substring(0, 2);\n\t\t\tconst fileName = line.substring(3);\n\t\t\tif (rawStatus.startsWith('R') || rawStatus.startsWith('C')) {\n\t\t\t\tconst [file1, file2] = fileName.replace(quoteRegex, '').split(' -> ');\n\t\t\t\tfiles.push(parseStatusFile(repoPath, rawStatus, file2.trim(), getUri, file1.trim()));\n\t\t\t} else {\n\t\t\t\tfiles.push(parseStatusFile(repoPath, rawStatus, fileName, getUri));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn new GitStatus(\n\t\tnormalizePath(repoPath),\n\t\tbranch ?? '',\n\t\t'',\n\t\tfiles,\n\t\tupstream ? { name: upstream, missing: missing, state: state } : undefined,\n\t);\n}\n\nfunction parseStatusV2(lines: string[], repoPath: string, getUri: ((path: string) => Uri) | undefined): GitStatus {\n\tlet branch: string | undefined;\n\tconst files = [];\n\tlet sha: string | undefined;\n\tconst state = {\n\t\tahead: 0,\n\t\tbehind: 0,\n\t};\n\tlet missing = true;\n\tlet upstream;\n\n\tlet position = -1;\n\twhile (++position < lines.length) {\n\t\tconst line = lines[position];\n\t\t// Headers\n\t\tif (line.startsWith('#')) {\n\t\t\tconst lineParts = line.split(' ');\n\t\t\tswitch (lineParts[1]) {\n\t\t\t\tcase 'branch.oid':\n\t\t\t\t\tsha = lineParts[2];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'branch.head':\n\t\t\t\t\tbranch = lineParts[2];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'branch.upstream':\n\t\t\t\t\tupstream = lineParts[2];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'branch.ab':\n\t\t\t\t\tmissing = false;\n\t\t\t\t\tstate.ahead = Number(lineParts[2].substring(1));\n\t\t\t\t\tstate.behind = Number(lineParts[3].substring(1));\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t} else {\n\t\t\tswitch (line[0]) {\n\t\t\t\tcase '1': {\n\t\t\t\t\t// normal: 1 <XY> <sub> <mH> <mI> <mW> <hH> <hI> <path>\n\t\t\t\t\tconst pathStart = indexAfterNthSpace(line, 8);\n\t\t\t\t\tif (pathStart === -1) break;\n\n\t\t\t\t\t// <sub> starts with 'S' if submodule, 'N' if not\n\t\t\t\t\tlet submodule;\n\t\t\t\t\tif (line.charCodeAt(5) === submoduleCharCode) {\n\t\t\t\t\t\tconst parts = line.split(' ');\n\t\t\t\t\t\tsubmodule = { oid: parts[7], previousOid: parts[6] };\n\t\t\t\t\t}\n\n\t\t\t\t\tfiles.push(\n\t\t\t\t\t\tparseStatusFile(\n\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\tline.substring(2, 4),\n\t\t\t\t\t\t\tline.substring(pathStart),\n\t\t\t\t\t\t\tgetUri,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tsubmodule,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase '2': {\n\t\t\t\t\t// rename: 2 <XY> <sub> <mH> <mI> <mW> <hH> <hI> <X><score> <path>\\t<origPath>\n\t\t\t\t\tconst pathStart = indexAfterNthSpace(line, 9);\n\t\t\t\t\tif (pathStart === -1) break;\n\n\t\t\t\t\tlet submodule;\n\t\t\t\t\tif (line.charCodeAt(5) === submoduleCharCode) {\n\t\t\t\t\t\tconst parts = line.split(' ');\n\t\t\t\t\t\tsubmodule = { oid: parts[7], previousOid: parts[6] };\n\t\t\t\t\t}\n\n\t\t\t\t\tconst tab = line.indexOf('\\t', pathStart);\n\t\t\t\t\tfiles.push(\n\t\t\t\t\t\tparseStatusFile(\n\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\tline.substring(2, 4),\n\t\t\t\t\t\t\ttab === -1 ? line.substring(pathStart) : line.substring(pathStart, tab),\n\t\t\t\t\t\t\tgetUri,\n\t\t\t\t\t\t\ttab === -1 ? undefined : line.substring(tab + 1),\n\t\t\t\t\t\t\tsubmodule,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'u': {\n\t\t\t\t\t// unmerged: u <XY> <sub> <m1> <m2> <m3> <mW> <h1> <h2> <h3> <path>\n\t\t\t\t\tconst pathStart = indexAfterNthSpace(line, 10);\n\t\t\t\t\tif (pathStart === -1) break;\n\n\t\t\t\t\tlet submodule;\n\t\t\t\t\tif (line.charCodeAt(5) === submoduleCharCode) {\n\t\t\t\t\t\tconst parts = line.split(' ');\n\t\t\t\t\t\tsubmodule = { oid: parts[9], previousOid: parts[7] };\n\t\t\t\t\t}\n\n\t\t\t\t\tfiles.push(\n\t\t\t\t\t\tparseStatusFile(\n\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\tline.substring(2, 4),\n\t\t\t\t\t\t\tline.substring(pathStart),\n\t\t\t\t\t\t\tgetUri,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tsubmodule,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase '?': // untracked\n\t\t\t\t\tfiles.push(parseStatusFile(repoPath, '??', line.substring(2), getUri));\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn new GitStatus(\n\t\tnormalizePath(repoPath),\n\t\tbranch ?? '',\n\t\tsha ?? '',\n\t\tfiles,\n\t\tupstream ? { name: upstream, missing: missing, state: state } : undefined,\n\t);\n}\n\nfunction parseStatusFile(\n\trepoPath: string,\n\trawStatus: string,\n\tfileName: string,\n\tgetUri: ((path: string) => Uri) | undefined,\n\toriginalFileName?: string,\n\tsubmodule?: { readonly oid: string; readonly previousOid?: string },\n): GitStatusFile {\n\tlet x = !rawStatus.startsWith('.') ? rawStatus[0].trim() : undefined;\n\tif (x == null || x.length === 0) {\n\t\tx = undefined;\n\t}\n\n\tlet y = undefined;\n\tif (rawStatus.length > 1) {\n\t\ty = rawStatus[1] !== '.' ? rawStatus[1].trim() : undefined;\n\t\tif (y == null || y.length === 0) {\n\t\t\ty = undefined;\n\t\t}\n\t}\n\n\treturn new GitStatusFile(repoPath, x, y, fileName, getUri?.(fileName), originalFileName, submodule);\n}\n\n/**\n * Folds `status --ignored=matching --untracked-files=all` records of new untracked folders into the entries that\n * `--ignored=traditional --untracked-files=normal` reports. Inside a new untracked folder nothing is tracked, so a\n * folder holding no untracked content is wholly ignored, and is reported in place of the ignored paths beneath it.\n */\nexport function foldMatchingIgnored(records: Iterable<string>): string[] {\n\tconst dirty = new Set<string>();\n\tconst ignored: string[] = [];\n\n\tfor (const record of records) {\n\t\tif (record.length < 4) continue;\n\n\t\tif (record.startsWith('!! ')) {\n\t\t\tignored.push(record.substring(3));\n\t\t} else if (record.startsWith('?? ')) {\n\t\t\tconst path = record.substring(3);\n\t\t\tfor (let i = path.indexOf('/'); i !== -1; i = path.indexOf('/', i + 1)) {\n\t\t\t\tdirty.add(path.substring(0, i + 1));\n\t\t\t}\n\t\t}\n\t}\n\n\tconst entries = new Set<string>();\n\tfor (const path of ignored) {\n\t\tlet entry = path;\n\t\tfor (let i = path.indexOf('/'); i !== -1 && i + 1 < path.length; i = path.indexOf('/', i + 1)) {\n\t\t\tconst folder = path.substring(0, i + 1);\n\t\t\tif (!dirty.has(folder)) {\n\t\t\t\tentry = folder;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tentries.add(entry);\n\t}\n\treturn [...entries];\n}\n"],"mappings":";;;;;;AAMA,MAAM,qBAAqB;AAC3B,MAAM,sBAAsB;AAC5B,MAAM,aAAa;AACnB,MAAM,oBAAoB,IAAI,WAAW,CAAC;;AAG1C,SAAS,mBAAmB,MAAc,GAAmB;CAC5D,IAAI,QAAQ;CACZ,KAAK,IAAI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MAAM,IAAI,KAAK,UAAU,GAAG,IAAI,CAAC,CAAC;EAEpC;CACD;CAEA,MAAM,0BAAU,IAAI,IAAY;CAChC,KAAK,MAAM,QAAQ,SAAS;EAC3B,IAAI,QAAQ;EACZ,KAAK,IAAI,IAAI,KAAK,QAAQ,GAAG,GAAG,MAAM,MAAM,IAAI,IAAI,KAAK,QAAQ,IAAI,KAAK,QAAQ,KAAK,IAAI,CAAC,GAAG;GAC9F,MAAM,SAAS,KAAK,UAAU,GAAG,IAAI,CAAC;GACtC,IAAI,CAAC,MAAM,IAAI,MAAM,GAAG;IACvB,QAAQ;IACR;GACD;EACD;EACA,QAAQ,IAAI,KAAK;CAClB;CACA,OAAO,CAAC,GAAG,OAAO;AACnB"}
|
|
1
|
+
{"version":3,"file":"statusParser.js","names":[],"sources":["../../../../git-cli/src/parsers/statusParser.ts"],"sourcesContent":["import { GitStatus } from '@gitlens/git/models/status.js';\nimport { GitStatusFile } from '@gitlens/git/models/statusFile.js';\nimport { normalizePath } from '@gitlens/utils/path.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\n\nconst aheadStatusV1Regex = /(?:ahead ([0-9]+))/;\nconst behindStatusV1Regex = /(?:behind ([0-9]+))/;\nconst quoteRegex = /\"/g;\nconst renameStatusV1Regex = /[RC]/;\nconst submoduleCharCode = 'S'.charCodeAt(0);\n\n/** Returns the index just after the `n`th space, or -1 if the line has fewer than `n` spaces. */\nfunction indexAfterNthSpace(line: string, n: number): number {\n\tlet index = -1;\n\tfor (let i = 0; i < n; i++) {\n\t\tindex = line.indexOf(' ', index + 1);\n\t\tif (index === -1) return -1;\n\t}\n\n\treturn index + 1;\n}\n\n/**\n * Parses `git status --porcelain[=v2]` output. `-z` output (every record ends with NUL, so a name is exactly as it is on\n * disk) is told by its NUL; without `-z` git C-quotes a name holding a `\"`, `\\`, tab or newline, which is read as written.\n * Without `getUri`, each file builds its uri on first read rather than during the parse\n */\nexport function parseGitStatus(\n\tdata: string,\n\trepoPath: string,\n\tporcelainVersion: number,\n\tgetUri?: (path: string) => Uri,\n): GitStatus | undefined {\n\tusing sw = maybeStopWatch(`Git.parseStatus(${repoPath}, v=${porcelainVersion})`, {\n\t\tlog: { onlyExit: true, level: 'debug' },\n\t});\n\tif (!data) {\n\t\tsw?.stop({ suffix: ` no data` });\n\t\treturn undefined;\n\t}\n\n\tconst nullTerminated = data.includes('\\0');\n\tconst lines = data.split(nullTerminated ? '\\0' : '\\n').filter(<T>(i?: T): i is T => Boolean(i));\n\tif (lines.length === 0) {\n\t\tsw?.stop({ suffix: ` parsed no files` });\n\t\treturn undefined;\n\t}\n\n\tconst status =\n\t\tporcelainVersion < 2\n\t\t\t? parseStatusV1(lines, repoPath, getUri, nullTerminated)\n\t\t\t: parseStatusV2(lines, repoPath, getUri, nullTerminated);\n\n\tsw?.stop({ suffix: ` parsed ${status.files.length} files` });\n\n\treturn status;\n}\n\nfunction parseStatusV1(\n\tlines: string[],\n\trepoPath: string,\n\tgetUri: ((path: string) => Uri) | undefined,\n\tnullTerminated: boolean,\n): GitStatus {\n\tlet branch: string | undefined;\n\tconst files = [];\n\tconst state = {\n\t\tahead: 0,\n\t\tbehind: 0,\n\t};\n\tlet upstream;\n\tlet missing = false;\n\n\tlet position = -1;\n\twhile (++position < lines.length) {\n\t\tconst line = lines[position];\n\t\t// Header\n\t\tif (line.startsWith('##')) {\n\t\t\tconst lineParts = line.split(' ');\n\t\t\t[branch, upstream] = lineParts[1].split('...');\n\t\t\tif (lineParts.length > 2) {\n\t\t\t\tconst upstreamStatus = lineParts.slice(2).join(' ');\n\t\t\t\tif (upstreamStatus === '[gone]') {\n\t\t\t\t\tmissing = true;\n\t\t\t\t\tstate.ahead = 0;\n\t\t\t\t\tstate.behind = 0;\n\t\t\t\t} else {\n\t\t\t\t\tconst aheadStatus = aheadStatusV1Regex.exec(upstreamStatus);\n\t\t\t\t\tstate.ahead = aheadStatus == null ? 0 : Number(aheadStatus[1]) || 0;\n\n\t\t\t\t\tconst behindStatus = behindStatusV1Regex.exec(upstreamStatus);\n\t\t\t\t\tstate.behind = behindStatus == null ? 0 : Number(behindStatus[1]) || 0;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst rawStatus = line.substring(0, 2);\n\t\t\tconst fileName = line.substring(3);\n\t\t\tif (nullTerminated && renameStatusV1Regex.test(rawStatus)) {\n\t\t\t\t// `XY <to>` and then `<from>` as a record of its own, which git writes for a rename in the working\n\t\t\t\t// tree (` R`) as well as in the index\n\t\t\t\tfiles.push(parseStatusFile(repoPath, rawStatus, fileName, getUri, lines[++position]));\n\t\t\t} else if (!nullTerminated && (rawStatus.startsWith('R') || rawStatus.startsWith('C'))) {\n\t\t\t\tconst [file1, file2] = fileName.replace(quoteRegex, '').split(' -> ');\n\t\t\t\tfiles.push(parseStatusFile(repoPath, rawStatus, file2.trim(), getUri, file1.trim()));\n\t\t\t} else {\n\t\t\t\tfiles.push(parseStatusFile(repoPath, rawStatus, fileName, getUri));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn new GitStatus(\n\t\tnormalizePath(repoPath),\n\t\tbranch ?? '',\n\t\t'',\n\t\tfiles,\n\t\tupstream ? { name: upstream, missing: missing, state: state } : undefined,\n\t);\n}\n\nfunction parseStatusV2(\n\tlines: string[],\n\trepoPath: string,\n\tgetUri: ((path: string) => Uri) | undefined,\n\tnullTerminated: boolean,\n): GitStatus {\n\tlet branch: string | undefined;\n\tconst files = [];\n\tlet sha: string | undefined;\n\tconst state = {\n\t\tahead: 0,\n\t\tbehind: 0,\n\t};\n\tlet missing = true;\n\tlet upstream;\n\n\tlet position = -1;\n\twhile (++position < lines.length) {\n\t\tconst line = lines[position];\n\t\t// Headers\n\t\tif (line.startsWith('#')) {\n\t\t\tconst lineParts = line.split(' ');\n\t\t\tswitch (lineParts[1]) {\n\t\t\t\tcase 'branch.oid':\n\t\t\t\t\tsha = lineParts[2];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'branch.head':\n\t\t\t\t\tbranch = lineParts[2];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'branch.upstream':\n\t\t\t\t\tupstream = lineParts[2];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'branch.ab':\n\t\t\t\t\tmissing = false;\n\t\t\t\t\tstate.ahead = Number(lineParts[2].substring(1));\n\t\t\t\t\tstate.behind = Number(lineParts[3].substring(1));\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t} else {\n\t\t\tswitch (line[0]) {\n\t\t\t\tcase '1': {\n\t\t\t\t\t// normal: 1 <XY> <sub> <mH> <mI> <mW> <hH> <hI> <path>\n\t\t\t\t\tconst pathStart = indexAfterNthSpace(line, 8);\n\t\t\t\t\tif (pathStart === -1) break;\n\n\t\t\t\t\t// <sub> starts with 'S' if submodule, 'N' if not\n\t\t\t\t\tlet submodule;\n\t\t\t\t\tif (line.charCodeAt(5) === submoduleCharCode) {\n\t\t\t\t\t\tconst parts = line.split(' ');\n\t\t\t\t\t\tsubmodule = { oid: parts[7], previousOid: parts[6] };\n\t\t\t\t\t}\n\n\t\t\t\t\tfiles.push(\n\t\t\t\t\t\tparseStatusFile(\n\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\tline.substring(2, 4),\n\t\t\t\t\t\t\tline.substring(pathStart),\n\t\t\t\t\t\t\tgetUri,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tsubmodule,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase '2': {\n\t\t\t\t\t// rename: 2 <XY> <sub> <mH> <mI> <mW> <hH> <hI> <X><score> <path>\\t<origPath> (`<path>\\0<origPath>` with -z)\n\t\t\t\t\tconst pathStart = indexAfterNthSpace(line, 9);\n\t\t\t\t\tif (pathStart === -1) break;\n\n\t\t\t\t\tlet submodule;\n\t\t\t\t\tif (line.charCodeAt(5) === submoduleCharCode) {\n\t\t\t\t\t\tconst parts = line.split(' ');\n\t\t\t\t\t\tsubmodule = { oid: parts[7], previousOid: parts[6] };\n\t\t\t\t\t}\n\n\t\t\t\t\tif (nullTerminated) {\n\t\t\t\t\t\t// `<path>` and then `<origPath>` as a record of its own\n\t\t\t\t\t\tfiles.push(\n\t\t\t\t\t\t\tparseStatusFile(\n\t\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\t\tline.substring(2, 4),\n\t\t\t\t\t\t\t\tline.substring(pathStart),\n\t\t\t\t\t\t\t\tgetUri,\n\t\t\t\t\t\t\t\tlines[++position],\n\t\t\t\t\t\t\t\tsubmodule,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst tab = line.indexOf('\\t', pathStart);\n\t\t\t\t\tfiles.push(\n\t\t\t\t\t\tparseStatusFile(\n\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\tline.substring(2, 4),\n\t\t\t\t\t\t\ttab === -1 ? line.substring(pathStart) : line.substring(pathStart, tab),\n\t\t\t\t\t\t\tgetUri,\n\t\t\t\t\t\t\ttab === -1 ? undefined : line.substring(tab + 1),\n\t\t\t\t\t\t\tsubmodule,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'u': {\n\t\t\t\t\t// unmerged: u <XY> <sub> <m1> <m2> <m3> <mW> <h1> <h2> <h3> <path>\n\t\t\t\t\tconst pathStart = indexAfterNthSpace(line, 10);\n\t\t\t\t\tif (pathStart === -1) break;\n\n\t\t\t\t\tlet submodule;\n\t\t\t\t\tif (line.charCodeAt(5) === submoduleCharCode) {\n\t\t\t\t\t\tconst parts = line.split(' ');\n\t\t\t\t\t\tsubmodule = { oid: parts[9], previousOid: parts[7] };\n\t\t\t\t\t}\n\n\t\t\t\t\tfiles.push(\n\t\t\t\t\t\tparseStatusFile(\n\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\tline.substring(2, 4),\n\t\t\t\t\t\t\tline.substring(pathStart),\n\t\t\t\t\t\t\tgetUri,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tsubmodule,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase '?': // untracked\n\t\t\t\t\tfiles.push(parseStatusFile(repoPath, '??', line.substring(2), getUri));\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn new GitStatus(\n\t\tnormalizePath(repoPath),\n\t\tbranch ?? '',\n\t\tsha ?? '',\n\t\tfiles,\n\t\tupstream ? { name: upstream, missing: missing, state: state } : undefined,\n\t);\n}\n\nfunction parseStatusFile(\n\trepoPath: string,\n\trawStatus: string,\n\tfileName: string,\n\tgetUri: ((path: string) => Uri) | undefined,\n\toriginalFileName?: string,\n\tsubmodule?: { readonly oid: string; readonly previousOid?: string },\n): GitStatusFile {\n\tlet x = !rawStatus.startsWith('.') ? rawStatus[0].trim() : undefined;\n\tif (x == null || x.length === 0) {\n\t\tx = undefined;\n\t}\n\n\tlet y = undefined;\n\tif (rawStatus.length > 1) {\n\t\ty = rawStatus[1] !== '.' ? rawStatus[1].trim() : undefined;\n\t\tif (y == null || y.length === 0) {\n\t\t\ty = undefined;\n\t\t}\n\t}\n\n\treturn new GitStatusFile(repoPath, x, y, fileName, getUri?.(fileName), originalFileName, submodule);\n}\n\n/**\n * Folds `status --ignored=matching --untracked-files=all` records of new untracked folders into the entries that\n * `--ignored=traditional --untracked-files=normal` reports. Inside a new untracked folder nothing is tracked, so a\n * folder holding no untracked content is wholly ignored, and is reported in place of the ignored paths beneath it.\n */\nexport function foldMatchingIgnored(records: Iterable<string>): string[] {\n\tconst dirty = new Set<string>();\n\tconst ignored: string[] = [];\n\n\tfor (const record of records) {\n\t\tif (record.length < 4) continue;\n\n\t\tif (record.startsWith('!! ')) {\n\t\t\tignored.push(record.substring(3));\n\t\t} else if (record.startsWith('?? ')) {\n\t\t\tconst path = record.substring(3);\n\t\t\tfor (let i = path.indexOf('/'); i !== -1; i = path.indexOf('/', i + 1)) {\n\t\t\t\tdirty.add(path.substring(0, i + 1));\n\t\t\t}\n\t\t}\n\t}\n\n\tconst entries = new Set<string>();\n\tfor (const path of ignored) {\n\t\tlet entry = path;\n\t\tfor (let i = path.indexOf('/'); i !== -1 && i + 1 < path.length; i = path.indexOf('/', i + 1)) {\n\t\t\tconst folder = path.substring(0, i + 1);\n\t\t\tif (!dirty.has(folder)) {\n\t\t\t\tentry = folder;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tentries.add(entry);\n\t}\n\treturn [...entries];\n}\n"],"mappings":";;;;;;AAMA,MAAM,qBAAqB;AAC3B,MAAM,sBAAsB;AAC5B,MAAM,aAAa;AACnB,MAAM,sBAAsB;AAC5B,MAAM,oBAAoB,IAAI,WAAW,CAAC;;AAG1C,SAAS,mBAAmB,MAAc,GAAmB;CAC5D,IAAI,QAAQ;CACZ,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK;EAC3B,QAAQ,KAAK,QAAQ,KAAK,QAAQ,CAAC;EACnC,IAAI,UAAU,IAAI,OAAO;CAC1B;CAEA,OAAO,QAAQ;AAChB;;;;;;AAOA,SAAgB,eACf,MACA,UACA,kBACA,QACwB;;;EACxB,MAAM,KAAA,YAAA,EAAK,eAAe,mBAAmB,SAAS,MAAM,iBAAiB,IAAI,EAChF,KAAK;GAAE,UAAU;GAAM,OAAO;EAAQ,EACvC,CAAC,CAAA;EACD,IAAI,CAAC,MAAM;GACV,IAAI,KAAK,EAAE,QAAQ,WAAW,CAAC;GAC/B;EACD;EAEA,MAAM,iBAAiB,KAAK,SAAS,IAAI;EACzC,MAAM,QAAQ,KAAK,MAAM,iBAAiB,OAAO,IAAI,CAAC,CAAC,QAAW,MAAkB,QAAQ,CAAC,CAAC;EAC9F,IAAI,MAAM,WAAW,GAAG;GACvB,IAAI,KAAK,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AAK,QAAQ,KAAK,IAAI,CAAC,GAAG;GAC9F,MAAM,SAAS,KAAK,UAAU,GAAG,IAAI,CAAC;GACtC,IAAI,CAAC,MAAM,IAAI,MAAM,GAAG;IACvB,QAAQ;IACR;GACD;EACD;EACA,QAAQ,IAAI,KAAK;CAClB;CACA,OAAO,CAAC,GAAG,OAAO;AACnB"}
|
|
@@ -21,10 +21,12 @@ function parseGitTree(data, ref, singleEntry) {
|
|
|
21
21
|
let path;
|
|
22
22
|
let startIndex;
|
|
23
23
|
let endIndex;
|
|
24
|
-
for (
|
|
25
|
-
line = line.trim();
|
|
24
|
+
for (const line of singleEntry ? data.split("\0") : iterateByDelimiter(data, "\0")) {
|
|
26
25
|
if (!line) continue;
|
|
27
|
-
|
|
26
|
+
startIndex = line.indexOf(" ");
|
|
27
|
+
if (startIndex === -1) continue;
|
|
28
|
+
metadata = line.substring(0, startIndex);
|
|
29
|
+
path = line.substring(startIndex + 1);
|
|
28
30
|
startIndex = metadata.indexOf(" ");
|
|
29
31
|
if (startIndex === -1) continue;
|
|
30
32
|
startIndex++;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeParser.js","names":[],"sources":["../../../../git-cli/src/parsers/treeParser.ts"],"sourcesContent":["import type { GitTreeEntry, GitTreeType } from '@gitlens/git/models/tree.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport { iterateByDelimiter } from '@gitlens/utils/string.js';\n\nexport function parseGitTree(data: string | undefined, ref: string, singleEntry: boolean): GitTreeEntry[] {\n\tusing sw = maybeStopWatch(`Git.parseTree`, { log: { onlyExit: true, level: 'debug' } });\n\n\tconst trees: GitTreeEntry[] = [];\n\tif (!data) {\n\t\tsw?.stop({ suffix: ` no data` });\n\t\treturn trees;\n\t}\n\n\t// Format: <mode> <type> <oid> <size>\\t<path
|
|
1
|
+
{"version":3,"file":"treeParser.js","names":[],"sources":["../../../../git-cli/src/parsers/treeParser.ts"],"sourcesContent":["import type { GitTreeEntry, GitTreeType } from '@gitlens/git/models/tree.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport { iterateByDelimiter } from '@gitlens/utils/string.js';\n\nexport function parseGitTree(data: string | undefined, ref: string, singleEntry: boolean): GitTreeEntry[] {\n\tusing sw = maybeStopWatch(`Git.parseTree`, { log: { onlyExit: true, level: 'debug' } });\n\n\tconst trees: GitTreeEntry[] = [];\n\tif (!data) {\n\t\tsw?.stop({ suffix: ` no data` });\n\t\treturn trees;\n\t}\n\n\t// Format (`-z`, so a path is as it is on disk rather than C-quoted): <mode> <type> <oid> <size>\\t<path>\\0\n\n\tlet metadata: string;\n\tlet oid: string;\n\tlet size: number;\n\tlet type: GitTreeType;\n\tlet path: string;\n\n\tlet startIndex: number;\n\tlet endIndex: number;\n\n\t// Avoid generator if we are only parsing a single entry\n\tfor (const line of singleEntry ? data.split('\\0') : iterateByDelimiter(data, '\\0')) {\n\t\tif (!line) continue;\n\n\t\t// The first tab ends the metadata; a path can hold tabs itself\n\t\tstartIndex = line.indexOf('\\t');\n\t\tif (startIndex === -1) continue;\n\n\t\tmetadata = line.substring(0, startIndex);\n\t\tpath = line.substring(startIndex + 1);\n\n\t\t// Skip mode\n\t\tstartIndex = metadata.indexOf(' ');\n\t\tif (startIndex === -1) continue;\n\n\t\t// Parse type\n\t\tstartIndex++;\n\t\tendIndex = metadata.indexOf(' ', startIndex);\n\t\tif (endIndex === -1) continue;\n\n\t\ttype = metadata.substring(startIndex, endIndex) as GitTreeType;\n\n\t\t// Parse oid\n\t\tstartIndex = endIndex + 1;\n\t\tendIndex = metadata.indexOf(' ', startIndex);\n\t\tif (endIndex === -1) continue;\n\n\t\toid = metadata.substring(startIndex, endIndex);\n\n\t\t// Parse size\n\t\tstartIndex = endIndex + 1;\n\n\t\tsize = parseInt(metadata.substring(startIndex), 10);\n\n\t\ttrees.push({ ref: ref, oid: oid, path: path || '', size: isNaN(size) ? 0 : size, type: type || 'blob' });\n\t}\n\n\tsw?.stop({ su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|
-
import { iterateByDelimiter } from "../../utils/string.js";
|
|
1
|
+
import { iterateByDelimiter, unquoteCString } from "../../utils/string.js";
|
|
2
2
|
import { fileUri } from "../../utils/uri.js";
|
|
3
3
|
import { normalizePath } from "../../utils/path.js";
|
|
4
4
|
import { maybeStopWatch } from "../../utils/stopwatch.js";
|
|
@@ -72,46 +72,6 @@ function parseGitWorktrees(data, repoPath, branches, getWorkspaceFolder) {
|
|
|
72
72
|
_usingCtx$1.d();
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
const cEscapes = {
|
|
76
|
-
a: 7,
|
|
77
|
-
b: 8,
|
|
78
|
-
f: 12,
|
|
79
|
-
n: 10,
|
|
80
|
-
r: 13,
|
|
81
|
-
t: 9,
|
|
82
|
-
v: 11,
|
|
83
|
-
"\\": 92,
|
|
84
|
-
"\"": 34
|
|
85
|
-
};
|
|
86
|
-
/** Reverses Git's C-style quoting (`"a\nb"`, `\303\251` octal UTF-8 bytes); returns unquoted values as-is */
|
|
87
|
-
function unquoteCString(value) {
|
|
88
|
-
if (!value.startsWith("\"")) return value;
|
|
89
|
-
const end = value.length > 1 && value.endsWith("\"") ? value.length - 1 : value.length;
|
|
90
|
-
const encoder = new TextEncoder();
|
|
91
|
-
const bytes = [];
|
|
92
|
-
let i = 1;
|
|
93
|
-
while (i < end) {
|
|
94
|
-
if (value[i] !== "\\" || i + 1 >= end) {
|
|
95
|
-
const cp = String.fromCodePoint(value.codePointAt(i));
|
|
96
|
-
bytes.push(...encoder.encode(cp));
|
|
97
|
-
i += cp.length;
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
const next = value[i + 1];
|
|
101
|
-
if (next >= "0" && next <= "7") {
|
|
102
|
-
let j = i + 1;
|
|
103
|
-
while (j < i + 4 && j < end && value[j] >= "0" && value[j] <= "7") j++;
|
|
104
|
-
bytes.push(Number.parseInt(value.substring(i + 1, j), 8) & 255);
|
|
105
|
-
i = j;
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
const code = cEscapes[next];
|
|
109
|
-
if (code != null) bytes.push(code);
|
|
110
|
-
else bytes.push(...encoder.encode(next));
|
|
111
|
-
i += 2;
|
|
112
|
-
}
|
|
113
|
-
return new TextDecoder().decode(new Uint8Array(bytes));
|
|
114
|
-
}
|
|
115
75
|
//#endregion
|
|
116
76
|
export { parseGitWorktrees };
|
|
117
77
|
|