@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.
Files changed (61) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/dist/git/parsers/diffParser.d.ts +25 -0
  3. package/dist/git/parsers/diffParser.js +169 -23
  4. package/dist/git/parsers/diffParser.js.map +1 -1
  5. package/dist/git/service.d.ts +4 -1
  6. package/dist/git/service.js +6 -2
  7. package/dist/git/service.js.map +1 -1
  8. package/dist/git/watching/unwatchedCacheValidator.d.ts +26 -4
  9. package/dist/git/watching/unwatchedCacheValidator.js +110 -10
  10. package/dist/git/watching/unwatchedCacheValidator.js.map +1 -1
  11. package/dist/git-cli/exec/statWorkers.d.ts +50 -0
  12. package/dist/git-cli/exec/statWorkers.js +194 -0
  13. package/dist/git-cli/exec/statWorkers.js.map +1 -0
  14. package/dist/git-cli/parsers/blameParser.js +25 -5
  15. package/dist/git-cli/parsers/blameParser.js.map +1 -1
  16. package/dist/git-cli/parsers/logParser.js +28 -18
  17. package/dist/git-cli/parsers/logParser.js.map +1 -1
  18. package/dist/git-cli/parsers/statusParser.d.ts +5 -1
  19. package/dist/git-cli/parsers/statusParser.js +17 -6
  20. package/dist/git-cli/parsers/statusParser.js.map +1 -1
  21. package/dist/git-cli/parsers/treeParser.js +5 -3
  22. package/dist/git-cli/parsers/treeParser.js.map +1 -1
  23. package/dist/git-cli/parsers/worktreeParser.js +1 -41
  24. package/dist/git-cli/parsers/worktreeParser.js.map +1 -1
  25. package/dist/git-cli/providers/revision.js +3 -3
  26. package/dist/git-cli/providers/revision.js.map +1 -1
  27. package/dist/git-cli/providers/status.js +1 -0
  28. package/dist/git-cli/providers/status.js.map +1 -1
  29. package/dist/git-cli/service.d.ts +7 -4
  30. package/dist/git-cli/service.js +14 -17
  31. package/dist/git-cli/service.js.map +1 -1
  32. package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts +2 -0
  33. package/dist/plus/integrations/authentication/configuredIntegrationService.js +23 -1
  34. package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
  35. package/dist/plus/integrations/authentication/models.d.ts +1 -0
  36. package/dist/plus/integrations/authentication/models.js.map +1 -1
  37. package/dist/plus/integrations/authentication/observedAuthenticationProvider.js +4 -1
  38. package/dist/plus/integrations/authentication/observedAuthenticationProvider.js.map +1 -1
  39. package/dist/plus/integrations/integrationService.js +7 -1
  40. package/dist/plus/integrations/integrationService.js.map +1 -1
  41. package/dist/plus/integrations/models/integration.d.ts +1 -0
  42. package/dist/plus/integrations/models/integration.js +8 -0
  43. package/dist/plus/integrations/models/integration.js.map +1 -1
  44. package/dist/plus/integrations/models/issuesIntegration.d.ts +5 -0
  45. package/dist/plus/integrations/models/issuesIntegration.js +33 -1
  46. package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
  47. package/dist/plus/integrations/providers/jira.d.ts +3 -2
  48. package/dist/plus/integrations/providers/jira.js +36 -17
  49. package/dist/plus/integrations/providers/jira.js.map +1 -1
  50. package/dist/plus/integrations/providers/linear.d.ts +1 -0
  51. package/dist/plus/integrations/providers/linear.js +40 -17
  52. package/dist/plus/integrations/providers/linear.js.map +1 -1
  53. package/dist/plus/integrations/providers/utils/discoveryCache.d.ts +6 -3
  54. package/dist/plus/integrations/providers/utils/discoveryCache.js +12 -6
  55. package/dist/plus/integrations/providers/utils/discoveryCache.js.map +1 -1
  56. package/dist/utils/env/node/exec.js +24 -22
  57. package/dist/utils/env/node/exec.js.map +1 -1
  58. package/dist/utils/string.d.ts +15 -0
  59. package/dist/utils/string.js +61 -1
  60. package/dist/utils/string.js.map +1 -1
  61. package/package.json +1 -1
@@ -0,0 +1,194 @@
1
+ import { isNotFound } from "../../git/watching/watchGroup.js";
2
+ import { stat } from "node:fs/promises";
3
+ import { Worker } from "node:worker_threads";
4
+ //#region ../git-cli/src/exec/statWorkers.ts
5
+ /**
6
+ * Stats each path it's sent, synchronously, and answers them as one message: a thread making a batch's stats back to
7
+ * back spends far less than the round trip each asynchronous stat makes to libuv's pool. Evaluated as a script, so the
8
+ * package ships no file of its own for it. `throwIfNoEntry: false` answers `undefined` for a path that isn't there,
9
+ * as Node also does for one under a file. Reads as {@link statLocal} does
10
+ */
11
+ const statWorkerSource = `
12
+ const { statSync } = require('node:fs');
13
+ const { parentPort } = require('node:worker_threads');
14
+ parentPort.on('message', paths => {
15
+ parentPort.postMessage(
16
+ paths.map(path => {
17
+ try {
18
+ const stat = statSync(path, { throwIfNoEntry: false });
19
+ return stat == null ? 'missing' : { mtime: stat.mtimeMs, size: stat.size };
20
+ } catch (ex) {
21
+ return ex != null && (ex.code === 'ENOENT' || ex.code === 'ENOTDIR') ? 'missing' : 'unreadable';
22
+ }
23
+ }),
24
+ );
25
+ });
26
+ `;
27
+ /** How long a worker beyond the first stays idle before it's stopped */
28
+ const defaultIdleTimeoutMs = 3e4;
29
+ /** What `maxWorkers` reads as when it isn't a number, as `UnwatchedCacheValidatorOptions.maxFsThreads` does */
30
+ const defaultMaxWorkers = 2;
31
+ /** Workers at most, whatever `maxWorkers` asks for: a batch serves as well on the calling thread past it */
32
+ const maxPoolWorkers = 4;
33
+ /**
34
+ * `path`'s modification time (ms since the epoch) and size, read from the local file system; `undefined` when it isn't
35
+ * there, or is under a path that is a file. Rejects when the stat failed otherwise
36
+ */
37
+ async function statLocal(path) {
38
+ try {
39
+ const s = await stat(path);
40
+ return {
41
+ mtime: s.mtimeMs,
42
+ size: s.size
43
+ };
44
+ } catch (ex) {
45
+ if (isNotFound(ex) || ex?.code === "ENOTDIR") return void 0;
46
+ throw ex;
47
+ }
48
+ }
49
+ /**
50
+ * Worker threads that stat many paths as one call (see `UnwatchedCacheValidatorOptions.statMany`). A batch takes an
51
+ * idle running worker. When none is free, the batch is served on the calling thread, one asynchronous stat at a time,
52
+ * and, while fewer than `maxWorkers` run and none is starting, a worker is started in the background for the batches
53
+ * after it, so no read waits for a worker to start. A worker whose batch never returns (a hung mount) stays busy and
54
+ * is never handed another; one that fails or exits rejects its batch and leaves the pool, and one that does so without a
55
+ * batch rejects the next one. A busy worker keeps the process alive, as a pending file-system call does; an idle or
56
+ * starting one doesn't. One idle worker is kept; the others are stopped once idle for `idleTimeoutMs`.
57
+ */
58
+ var StatWorkerPool = class {
59
+ workers = /* @__PURE__ */ new Set();
60
+ maxWorkers;
61
+ idleTimeoutMs;
62
+ /** Why the last worker to fail without a batch failed, until a batch is rejected with it */
63
+ idleFailure;
64
+ disposed = false;
65
+ constructor(options) {
66
+ const maxWorkers = Math.floor(options.maxWorkers);
67
+ this.maxWorkers = Math.min(Number.isNaN(maxWorkers) ? defaultMaxWorkers : Math.max(1, maxWorkers), maxPoolWorkers);
68
+ this.idleTimeoutMs = options.idleTimeoutMs ?? defaultIdleTimeoutMs;
69
+ }
70
+ dispose() {
71
+ this.disposed = true;
72
+ for (const pooled of [...this.workers]) this.drop(pooled, /* @__PURE__ */ new Error("The stat worker pool was disposed"));
73
+ }
74
+ /** One reading per path, in order; rejects when a worker failed the batch, or once disposed. Never throws */
75
+ statMany(paths) {
76
+ if (this.disposed) return Promise.reject(/* @__PURE__ */ new Error("The stat worker pool was disposed"));
77
+ if (this.idleFailure != null) {
78
+ const failure = this.idleFailure;
79
+ this.idleFailure = void 0;
80
+ return Promise.reject(failure);
81
+ }
82
+ let pooled;
83
+ let starting = false;
84
+ for (const candidate of this.workers) if (!candidate.online) starting = true;
85
+ else if (candidate.batch == null) {
86
+ pooled = candidate;
87
+ break;
88
+ }
89
+ if (pooled == null) {
90
+ if (!starting && this.workers.size < this.maxWorkers) try {
91
+ this.spawn();
92
+ } catch (ex) {
93
+ return Promise.reject(ex instanceof Error ? ex : new Error(String(ex)));
94
+ }
95
+ return statOnCallingThread(paths);
96
+ }
97
+ const worker = pooled;
98
+ return new Promise((resolve, reject) => {
99
+ if (worker.idleTimer != null) {
100
+ clearTimeout(worker.idleTimer);
101
+ worker.idleTimer = void 0;
102
+ }
103
+ worker.batch = {
104
+ resolve,
105
+ reject
106
+ };
107
+ worker.worker.ref();
108
+ try {
109
+ worker.worker.postMessage(paths);
110
+ } catch (ex) {
111
+ this.drop(worker, ex instanceof Error ? ex : new Error(String(ex)));
112
+ }
113
+ });
114
+ }
115
+ /** Starts a worker that answers each batch of paths it's sent with one {@link BatchedStat} per path, in order */
116
+ createWorker() {
117
+ return new Worker(statWorkerSource, {
118
+ eval: true,
119
+ execArgv: []
120
+ });
121
+ }
122
+ spawn() {
123
+ const worker = this.createWorker();
124
+ const pooled = {
125
+ worker,
126
+ online: false,
127
+ batch: void 0,
128
+ idleTimer: void 0
129
+ };
130
+ this.workers.add(pooled);
131
+ worker.unref();
132
+ worker.on("online", () => {
133
+ if (!this.workers.has(pooled)) return;
134
+ pooled.online = true;
135
+ this.startIdleTimer(pooled);
136
+ });
137
+ worker.on("message", (readings) => {
138
+ const batch = pooled.batch;
139
+ if (batch == null) return;
140
+ pooled.batch = void 0;
141
+ worker.unref();
142
+ this.startIdleTimer(pooled);
143
+ batch.resolve(readings);
144
+ });
145
+ const fail = (reason) => {
146
+ if (pooled.batch == null && this.workers.has(pooled)) this.idleFailure = reason;
147
+ this.drop(pooled, reason);
148
+ };
149
+ worker.on("messageerror", fail);
150
+ worker.on("error", fail);
151
+ worker.on("exit", (code) => fail(/* @__PURE__ */ new Error(`The stat worker exited with code ${code}`)));
152
+ }
153
+ /** Stops an idle worker once it stayed idle for {@link idleTimeoutMs}, unless it's the only idle one */
154
+ startIdleTimer(pooled) {
155
+ const timer = setTimeout(() => {
156
+ pooled.idleTimer = void 0;
157
+ if (pooled.batch != null) return;
158
+ let idle = 0;
159
+ for (const candidate of this.workers) if (candidate.online && candidate.batch == null) idle++;
160
+ if (idle > 1) this.drop(pooled, /* @__PURE__ */ new Error("The stat worker was idle"));
161
+ }, this.idleTimeoutMs);
162
+ timer.unref();
163
+ pooled.idleTimer = timer;
164
+ }
165
+ /** Takes `pooled` out of the pool and stops it, rejecting its batch in flight with `reason` */
166
+ drop(pooled, reason) {
167
+ if (!this.workers.delete(pooled)) return;
168
+ if (pooled.idleTimer != null) {
169
+ clearTimeout(pooled.idleTimer);
170
+ pooled.idleTimer = void 0;
171
+ }
172
+ const batch = pooled.batch;
173
+ pooled.batch = void 0;
174
+ batch?.reject(reason);
175
+ pooled.worker.terminate().catch(() => {});
176
+ }
177
+ };
178
+ /**
179
+ * Reads each path with {@link statLocal}, one at a time, so the batch holds one of Node's file-system threads at a
180
+ * time, as the gate it went through counts it
181
+ */
182
+ async function statOnCallingThread(paths) {
183
+ const readings = [];
184
+ for (const path of paths) try {
185
+ readings.push(await statLocal(path) ?? "missing");
186
+ } catch {
187
+ readings.push("unreadable");
188
+ }
189
+ return readings;
190
+ }
191
+ //#endregion
192
+ export { StatWorkerPool, statLocal };
193
+
194
+ //# sourceMappingURL=statWorkers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statWorkers.js","names":[],"sources":["../../../../git-cli/src/exec/statWorkers.ts"],"sourcesContent":["import { stat } from 'node:fs/promises';\nimport { Worker } from 'node:worker_threads';\nimport type { BatchedStat } from '@gitlens/git/watching/unwatchedCacheValidator.js';\nimport { isNotFound } from '@gitlens/git/watching/watchGroup.js';\n\n/**\n * Stats each path it's sent, synchronously, and answers them as one message: a thread making a batch's stats back to\n * back spends far less than the round trip each asynchronous stat makes to libuv's pool. Evaluated as a script, so the\n * package ships no file of its own for it. `throwIfNoEntry: false` answers `undefined` for a path that isn't there,\n * as Node also does for one under a file. Reads as {@link statLocal} does\n */\nconst statWorkerSource = `\nconst { statSync } = require('node:fs');\nconst { parentPort } = require('node:worker_threads');\nparentPort.on('message', paths => {\n\tparentPort.postMessage(\n\t\tpaths.map(path => {\n\t\t\ttry {\n\t\t\t\tconst stat = statSync(path, { throwIfNoEntry: false });\n\t\t\t\treturn stat == null ? 'missing' : { mtime: stat.mtimeMs, size: stat.size };\n\t\t\t} catch (ex) {\n\t\t\t\treturn ex != null && (ex.code === 'ENOENT' || ex.code === 'ENOTDIR') ? 'missing' : 'unreadable';\n\t\t\t}\n\t\t}),\n\t);\n});\n`;\n\n/** How long a worker beyond the first stays idle before it's stopped */\nconst defaultIdleTimeoutMs = 30_000;\n/** What `maxWorkers` reads as when it isn't a number, as `UnwatchedCacheValidatorOptions.maxFsThreads` does */\nconst defaultMaxWorkers = 2;\n/** Workers at most, whatever `maxWorkers` asks for: a batch serves as well on the calling thread past it */\nconst maxPoolWorkers = 4;\n\n/**\n * `path`'s modification time (ms since the epoch) and size, read from the local file system; `undefined` when it isn't\n * there, or is under a path that is a file. Rejects when the stat failed otherwise\n */\nexport async function statLocal(path: string): Promise<{ mtime: number; size: number } | undefined> {\n\ttry {\n\t\tconst s = await stat(path);\n\t\treturn { mtime: s.mtimeMs, size: s.size };\n\t} catch (ex) {\n\t\tif (isNotFound(ex) || (ex as { code?: unknown } | undefined)?.code === 'ENOTDIR') return undefined;\n\n\t\tthrow ex;\n\t}\n}\n\ninterface PooledWorker {\n\treadonly worker: Worker;\n\t/** Whether it's running (its `online` event fired); only then is it handed a batch */\n\tonline: boolean;\n\t/** What settles the batch in flight; `undefined` while idle */\n\tbatch:\n\t\t| { readonly resolve: (readings: readonly BatchedStat[]) => void; readonly reject: (ex: Error) => void }\n\t\t| undefined;\n\tidleTimer: ReturnType<typeof setTimeout> | undefined;\n}\n\nexport interface StatWorkerPoolOptions {\n\t/**\n\t * Workers at most, each serving one batch at a time, hung and starting ones included; at most 4, and read as\n\t * `UnwatchedCacheValidatorOptions.maxFsThreads` is (2 when it isn't a number, at least 1)\n\t */\n\treadonly maxWorkers: number;\n\t/** How long a worker beyond the first stays idle before it's stopped. Default: 30 seconds */\n\treadonly idleTimeoutMs?: number;\n}\n\n/**\n * Worker threads that stat many paths as one call (see `UnwatchedCacheValidatorOptions.statMany`). A batch takes an\n * idle running worker. When none is free, the batch is served on the calling thread, one asynchronous stat at a time,\n * and, while fewer than `maxWorkers` run and none is starting, a worker is started in the background for the batches\n * after it, so no read waits for a worker to start. A worker whose batch never returns (a hung mount) stays busy and\n * is never handed another; one that fails or exits rejects its batch and leaves the pool, and one that does so without a\n * batch rejects the next one. A busy worker keeps the process alive, as a pending file-system call does; an idle or\n * starting one doesn't. One idle worker is kept; the others are stopped once idle for `idleTimeoutMs`.\n */\nexport class StatWorkerPool {\n\tprivate readonly workers = new Set<PooledWorker>();\n\tprivate readonly maxWorkers: number;\n\tprivate readonly idleTimeoutMs: number;\n\t/** Why the last worker to fail without a batch failed, until a batch is rejected with it */\n\tprivate idleFailure: Error | undefined;\n\tprivate disposed = false;\n\n\tconstructor(options: StatWorkerPoolOptions) {\n\t\tconst maxWorkers = Math.floor(options.maxWorkers);\n\t\tthis.maxWorkers = Math.min(\n\t\t\tNumber.isNaN(maxWorkers) ? defaultMaxWorkers : Math.max(1, maxWorkers),\n\t\t\tmaxPoolWorkers,\n\t\t);\n\t\tthis.idleTimeoutMs = options.idleTimeoutMs ?? defaultIdleTimeoutMs;\n\t}\n\n\tdispose(): void {\n\t\tthis.disposed = true;\n\t\tfor (const pooled of [...this.workers]) {\n\t\t\tthis.drop(pooled, new Error('The stat worker pool was disposed'));\n\t\t}\n\t}\n\n\t/** One reading per path, in order; rejects when a worker failed the batch, or once disposed. Never throws */\n\tstatMany(paths: readonly string[]): Promise<readonly BatchedStat[]> {\n\t\tif (this.disposed) return Promise.reject(new Error('The stat worker pool was disposed'));\n\n\t\t// Rejected rather than served on the calling thread, so a worker that can't run isn't started again for each batch\n\t\tif (this.idleFailure != null) {\n\t\t\tconst failure = this.idleFailure;\n\t\t\tthis.idleFailure = undefined;\n\t\t\treturn Promise.reject(failure);\n\t\t}\n\n\t\tlet pooled: PooledWorker | undefined;\n\t\tlet starting = false;\n\t\tfor (const candidate of this.workers) {\n\t\t\tif (!candidate.online) {\n\t\t\t\tstarting = true;\n\t\t\t} else if (candidate.batch == null) {\n\t\t\t\tpooled = candidate;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (pooled == null) {\n\t\t\tif (!starting && this.workers.size < this.maxWorkers) {\n\t\t\t\ttry {\n\t\t\t\t\tthis.spawn();\n\t\t\t\t} catch (ex) {\n\t\t\t\t\treturn Promise.reject(ex instanceof Error ? ex : new Error(String(ex)));\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn statOnCallingThread(paths);\n\t\t}\n\n\t\tconst worker = pooled;\n\t\treturn new Promise<readonly BatchedStat[]>((resolve, reject) => {\n\t\t\tif (worker.idleTimer != null) {\n\t\t\t\tclearTimeout(worker.idleTimer);\n\t\t\t\tworker.idleTimer = undefined;\n\t\t\t}\n\t\t\t// Claimed before anything is awaited, so a call meanwhile takes another worker\n\t\t\tworker.batch = { resolve: resolve, reject: reject };\n\t\t\tworker.worker.ref();\n\t\t\ttry {\n\t\t\t\tworker.worker.postMessage(paths);\n\t\t\t} catch (ex) {\n\t\t\t\tthis.drop(worker, ex instanceof Error ? ex : new Error(String(ex)));\n\t\t\t}\n\t\t});\n\t}\n\n\t/** Starts a worker that answers each batch of paths it's sent with one {@link BatchedStat} per path, in order */\n\tprotected createWorker(): Worker {\n\t\t// No `execArgv` of the host's (a loader, an inspector), which only slows a worker down that needs none of it\n\t\treturn new Worker(statWorkerSource, { eval: true, execArgv: [] });\n\t}\n\n\tprivate spawn(): void {\n\t\tconst worker = this.createWorker();\n\t\tconst pooled: PooledWorker = { worker: worker, online: false, batch: undefined, idleTimer: undefined };\n\t\tthis.workers.add(pooled);\n\t\tworker.unref();\n\n\t\tworker.on('online', () => {\n\t\t\tif (!this.workers.has(pooled)) return;\n\n\t\t\tpooled.online = true;\n\t\t\tthis.startIdleTimer(pooled);\n\t\t});\n\t\tworker.on('message', (readings: readonly BatchedStat[]) => {\n\t\t\tconst batch = pooled.batch;\n\t\t\tif (batch == null) return;\n\n\t\t\tpooled.batch = undefined;\n\t\t\tworker.unref();\n\t\t\tthis.startIdleTimer(pooled);\n\t\t\tbatch.resolve(readings);\n\t\t});\n\t\tconst fail = (reason: Error): void => {\n\t\t\tif (pooled.batch == null && this.workers.has(pooled)) {\n\t\t\t\tthis.idleFailure = reason;\n\t\t\t}\n\t\t\tthis.drop(pooled, reason);\n\t\t};\n\t\tworker.on('messageerror', fail);\n\t\tworker.on('error', fail);\n\t\tworker.on('exit', code => fail(new Error(`The stat worker exited with code ${code}`)));\n\t}\n\n\t/** Stops an idle worker once it stayed idle for {@link idleTimeoutMs}, unless it's the only idle one */\n\tprivate startIdleTimer(pooled: PooledWorker): void {\n\t\tconst timer = setTimeout(() => {\n\t\t\tpooled.idleTimer = undefined;\n\t\t\tif (pooled.batch != null) return;\n\n\t\t\tlet idle = 0;\n\t\t\tfor (const candidate of this.workers) {\n\t\t\t\tif (candidate.online && candidate.batch == null) {\n\t\t\t\t\tidle++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (idle > 1) {\n\t\t\t\tthis.drop(pooled, new Error('The stat worker was idle'));\n\t\t\t}\n\t\t}, this.idleTimeoutMs);\n\t\ttimer.unref();\n\t\tpooled.idleTimer = timer;\n\t}\n\n\t/** Takes `pooled` out of the pool and stops it, rejecting its batch in flight with `reason` */\n\tprivate drop(pooled: PooledWorker, reason: Error): void {\n\t\tif (!this.workers.delete(pooled)) return;\n\n\t\tif (pooled.idleTimer != null) {\n\t\t\tclearTimeout(pooled.idleTimer);\n\t\t\tpooled.idleTimer = undefined;\n\t\t}\n\t\tconst batch = pooled.batch;\n\t\tpooled.batch = undefined;\n\t\tbatch?.reject(reason);\n\t\tvoid pooled.worker.terminate().catch(() => {});\n\t}\n}\n\n/**\n * Reads each path with {@link statLocal}, one at a time, so the batch holds one of Node's file-system threads at a\n * time, as the gate it went through counts it\n */\nasync function statOnCallingThread(paths: readonly string[]): Promise<readonly BatchedStat[]> {\n\tconst readings: BatchedStat[] = [];\n\tfor (const path of paths) {\n\t\ttry {\n\t\t\treadings.push((await statLocal(path)) ?? 'missing');\n\t\t} catch {\n\t\t\treadings.push('unreadable');\n\t\t}\n\t}\n\treturn readings;\n}\n"],"mappings":";;;;;;;;;;AAWA,MAA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,OAAO,GAAG,gBAAgB,IAAI;EAC9B,OAAO,GAAG,SAAS,IAAI;EACvB,OAAO,GAAG,SAAQ,SAAQ,qBAAK,IAAI,MAAM,oCAAoC,MAAM,CAAC,CAAC;CACtF;;CAGA,eAAuB,QAA4B;EAClD,MAAM,QAAQ,iBAAiB;GAC9B,OAAO,YAAY,KAAA;GACnB,IAAI,OAAO,SAAS,MAAM;GAE1B,IAAI,OAAO;GACX,KAAK,MAAM,aAAa,KAAK,SAC5B,IAAI,UAAU,UAAU,UAAU,SAAS,MAC1C;GAGF,IAAI,OAAO,GACV,KAAK,KAAK,wBAAQ,IAAI,MAAM,0BAA0B,CAAC;EAEzD,GAAG,KAAK,aAAa;EACrB,MAAM,MAAM;EACZ,OAAO,YAAY;CACpB;;CAGA,KAAa,QAAsB,QAAqB;EACvD,IAAI,CAAC,KAAK,QAAQ,OAAO,MAAM,GAAG;EAElC,IAAI,OAAO,aAAa,MAAM;GAC7B,aAAa,OAAO,SAAS;GAC7B,OAAO,YAAY,KAAA;EACpB;EACA,MAAM,QAAQ,OAAO;EACrB,OAAO,QAAQ,KAAA;EACf,OAAO,OAAO,MAAM;EACpB,OAAY,OAAO,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC;CAC9C;AACD;;;;;AAMA,eAAe,oBAAoB,OAA2D;CAC7F,MAAM,WAA0B,CAAC;CACjC,KAAK,MAAM,QAAQ,OAClB,IAAI;EACH,SAAS,KAAM,MAAM,UAAU,IAAI,KAAM,SAAS;CACnD,QAAQ;EACP,SAAS,KAAK,YAAY;CAC3B;CAED,OAAO;AACR"}
@@ -1,4 +1,4 @@
1
- import { iterateAsyncByDelimiter, iterateByDelimiter } from "../../utils/string.js";
1
+ import { iterateAsyncByDelimiter, iterateByDelimiter, unquoteCString } from "../../utils/string.js";
2
2
  import { fileUri, joinUriPath } from "../../utils/uri.js";
3
3
  import { normalizePath } from "../../utils/path.js";
4
4
  import { uncommitted } from "../../git/models/revision.js";
@@ -9,6 +9,22 @@ import { GitFileChange } from "../../git/models/fileChange.js";
9
9
  import { GitCommit, GitCommitIdentity } from "../../git/models/commit.js";
10
10
  import { isUserMatch } from "../../git/utils/user.utils.js";
11
11
  //#region ../git-cli/src/parsers/blameParser.ts
12
+ /**
13
+ * Decodes one kind of blame file name, remembering the last: git repeats the file name (and the one it was renamed from)
14
+ * in every chunk, so a name it quoted would otherwise be decoded again each time
15
+ */
16
+ function createPathUnquoter() {
17
+ let lastRaw;
18
+ let lastPath = "";
19
+ return (raw) => {
20
+ if (raw.charCodeAt(0) !== 34) return raw;
21
+ if (raw !== lastRaw) {
22
+ lastRaw = raw;
23
+ lastPath = unquoteCString(raw);
24
+ }
25
+ return lastPath;
26
+ };
27
+ }
12
28
  function parseGitBlame(repoPath, data, currentUser, modifiedTime) {
13
29
  try {
14
30
  var _usingCtx$1 = _usingCtx();
@@ -26,6 +42,8 @@ function parseGitBlame(repoPath, data, currentUser, modifiedTime) {
26
42
  let cachedPathUri;
27
43
  let cachedPreviousPath;
28
44
  let cachedPreviousPathUri;
45
+ const unquotePath = createPathUnquoter();
46
+ const unquotePreviousPath = createPathUnquoter();
29
47
  const authors = /* @__PURE__ */ new Map();
30
48
  const commits = /* @__PURE__ */ new Map();
31
49
  const lines = [];
@@ -68,7 +86,7 @@ function parseGitBlame(repoPath, data, currentUser, modifiedTime) {
68
86
  } else if (keyLen === 12) entry.committerTimeZone = line.substring(valueStart);
69
87
  break;
70
88
  case 102: {
71
- entry.path = line.substring(valueStart);
89
+ entry.path = unquotePath(line.substring(valueStart));
72
90
  const entryPath = entry.path;
73
91
  const isUncommittedEntry = entry.sha === uncommitted;
74
92
  let commit = commits.get(entry.sha);
@@ -146,7 +164,7 @@ function parseGitBlame(repoPath, data, currentUser, modifiedTime) {
146
164
  const shaEnd = value.indexOf(" ");
147
165
  if (shaEnd !== -1) {
148
166
  entry.previousSha = value.substring(0, shaEnd);
149
- entry.previousPath = value.substring(shaEnd + 1);
167
+ entry.previousPath = unquotePreviousPath(value.substring(shaEnd + 1));
150
168
  }
151
169
  break;
152
170
  }
@@ -172,6 +190,8 @@ function parseGitBlame(repoPath, data, currentUser, modifiedTime) {
172
190
  * as its `filename` terminator line is encountered.
173
191
  */
174
192
  async function* parseGitBlameAsync(stream) {
193
+ const unquotePath = createPathUnquoter();
194
+ const unquotePreviousPath = createPathUnquoter();
175
195
  let entry;
176
196
  for await (const line of iterateAsyncByDelimiter(stream, "\n")) {
177
197
  const spaceIdx = line.indexOf(" ");
@@ -211,7 +231,7 @@ async function* parseGitBlameAsync(stream) {
211
231
  } else if (keyLen === 12) entry.committerTimeZone = line.substring(valueStart);
212
232
  break;
213
233
  case 102:
214
- entry.path = line.substring(valueStart);
234
+ entry.path = unquotePath(line.substring(valueStart));
215
235
  yield entry;
216
236
  entry = void 0;
217
237
  break;
@@ -223,7 +243,7 @@ async function* parseGitBlameAsync(stream) {
223
243
  const shaEnd = value.indexOf(" ");
224
244
  if (shaEnd !== -1) {
225
245
  entry.previousSha = value.substring(0, shaEnd);
226
- entry.previousPath = value.substring(shaEnd + 1);
246
+ entry.previousPath = unquotePreviousPath(value.substring(shaEnd + 1));
227
247
  }
228
248
  break;
229
249
  }
@@ -1 +1 @@
1
- {"version":3,"file":"blameParser.js","names":[],"sources":["../../../../git-cli/src/parsers/blameParser.ts"],"sourcesContent":["import type { GitBlame, GitBlameAuthor } from '@gitlens/git/models/blame.js';\nimport type { GitCommitLine } from '@gitlens/git/models/commit.js';\nimport { GitCommit, GitCommitIdentity } from '@gitlens/git/models/commit.js';\nimport { GitFileChange } from '@gitlens/git/models/fileChange.js';\nimport { GitFileIndexStatus } from '@gitlens/git/models/fileStatus.js';\nimport { uncommitted } from '@gitlens/git/models/revision.js';\nimport type { GitUser } from '@gitlens/git/models/user.js';\nimport { isUserMatch } from '@gitlens/git/utils/user.utils.js';\nimport { normalizePath } from '@gitlens/utils/path.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport { iterateAsyncByDelimiter, iterateByDelimiter } from '@gitlens/utils/string.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { fileUri, joinUriPath } from '@gitlens/utils/uri.js';\n\nexport interface BlameEntry {\n\tsha: string;\n\tline: number;\n\toriginalLine: number;\n\tlineCount: number;\n\n\tauthor?: string;\n\tauthorTime?: number;\n\tauthorTimeZone?: string;\n\tauthorEmail?: string;\n\n\tcommitter?: string;\n\tcommitterTime?: number;\n\tcommitterTimeZone?: string;\n\tcommitterEmail?: string;\n\n\tpreviousSha?: string;\n\tpreviousPath?: string;\n\n\tpath?: string;\n\tsummary?: string;\n\n\tauthorCurrent?: boolean;\n\tcommitterCurrent?: boolean;\n}\n\nexport function parseGitBlame(\n\trepoPath: string,\n\tdata: string | undefined,\n\tcurrentUser: GitUser | undefined,\n\tmodifiedTime?: number,\n): GitBlame | undefined {\n\tusing sw = maybeStopWatch(`Git.parseBlame(${repoPath})`, { log: { onlyExit: true, level: 'debug' } });\n\tif (!data) {\n\t\tsw?.stop({ suffix: ` no data` });\n\t\treturn undefined;\n\t}\n\n\t// Pre-compute constants once\n\tconst normalizedRepoPath = normalizePath(repoPath);\n\tconst repoUri = fileUri(normalizedRepoPath);\n\n\t// Path normalization + URI cache (single-file blame = 1 cache entry)\n\tlet cachedPath: string | undefined;\n\tlet cachedPathUri: Uri | undefined;\n\tlet cachedPreviousPath: string | undefined;\n\tlet cachedPreviousPathUri: Uri | undefined;\n\n\tconst authors = new Map<string, GitBlameAuthor>();\n\tconst commits = new Map<string, GitCommit>();\n\tconst lines: GitCommitLine[] = [];\n\n\tlet entry: BlameEntry | undefined;\n\n\tfor (const line of iterateByDelimiter(data, '\\n')) {\n\t\tconst spaceIdx = line.indexOf(' ');\n\t\tif (spaceIdx === -1) continue;\n\n\t\tif (entry == null) {\n\t\t\t// Header line: <sha> <originalLine> <currentLine> <lineCount>\n\t\t\tconst sha = line.substring(0, spaceIdx);\n\n\t\t\tlet s = spaceIdx + 1;\n\t\t\tlet e = line.indexOf(' ', s);\n\t\t\tconst originalLine = parseInt(line.substring(s, e), 10);\n\n\t\t\ts = e + 1;\n\t\t\te = line.indexOf(' ', s);\n\t\t\tconst lineno = parseInt(line.substring(s, e), 10);\n\n\t\t\ts = e + 1;\n\t\t\tconst lineCount = parseInt(line.substring(s), 10);\n\n\t\t\tentry = { sha: sha, originalLine: originalLine, line: lineno, lineCount: lineCount };\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Dispatch on first character + key length to avoid creating key substrings\n\t\tconst keyLen = spaceIdx;\n\t\tconst valueStart = spaceIdx + 1;\n\n\t\tswitch (line.charCodeAt(0)) {\n\t\t\tcase 0x61 /* a — author* */:\n\t\t\t\tif (keyLen === 6 /* \"author\" */) {\n\t\t\t\t\tentry.author = line.substring(valueStart);\n\t\t\t\t} else if (keyLen === 11 /* \"author-mail\" | \"author-time\" */) {\n\t\t\t\t\t// Disambiguate at pos 7: 'm' (mail) vs 't' (time)\n\t\t\t\t\tif (line.charCodeAt(7) === 0x6d /* m */) {\n\t\t\t\t\t\tentry.authorEmail = parseEmail(line.substring(valueStart));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tentry.authorTime = parseInt(line.substring(valueStart), 10) * 1000;\n\t\t\t\t\t}\n\t\t\t\t} else if (keyLen === 9 /* \"author-tz\" */) {\n\t\t\t\t\tentry.authorTimeZone = line.substring(valueStart);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 0x63 /* c — committer* */:\n\t\t\t\tif (keyLen === 9 /* \"committer\" */) {\n\t\t\t\t\tentry.committer = line.substring(valueStart);\n\t\t\t\t} else if (keyLen === 14 /* \"committer-mail\" | \"committer-time\" */) {\n\t\t\t\t\t// Disambiguate at pos 10: 'm' (mail) vs 't' (time)\n\t\t\t\t\tif (line.charCodeAt(10) === 0x6d /* m */) {\n\t\t\t\t\t\tentry.committerEmail = parseEmail(line.substring(valueStart));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tentry.committerTime = parseInt(line.substring(valueStart), 10) * 1000;\n\t\t\t\t\t}\n\t\t\t\t} else if (keyLen === 12 /* \"committer-tz\" */) {\n\t\t\t\t\tentry.committerTimeZone = line.substring(valueStart);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 0x66 /* f — filename */: {\n\t\t\t\t// Don't trim — spaces in filenames are valid\n\t\t\t\tentry.path = line.substring(valueStart);\n\n\t\t\t\t// Assemble model immediately — no intermediate storage\n\t\t\t\tconst entryPath = entry.path;\n\t\t\t\tconst isUncommittedEntry = entry.sha === uncommitted;\n\n\t\t\t\tlet commit = commits.get(entry.sha);\n\t\t\t\tif (commit == null) {\n\t\t\t\t\tif (isUncommittedEntry) {\n\t\t\t\t\t\tentry.author = currentUser?.name ?? '';\n\t\t\t\t\t\tentry.authorCurrent = true;\n\t\t\t\t\t\tentry.authorEmail = currentUser?.email;\n\t\t\t\t\t\tentry.authorTime = modifiedTime ?? entry.authorTime ?? 0;\n\t\t\t\t\t\tentry.committer = entry.author;\n\t\t\t\t\t\tentry.committerEmail = entry.authorEmail;\n\t\t\t\t\t\tentry.committerTime = entry.authorTime;\n\t\t\t\t\t\tentry.committerCurrent = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (isUserMatch(currentUser, entry.author, entry.authorEmail)) {\n\t\t\t\t\t\t\tentry.authorCurrent = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (isUserMatch(currentUser, entry.committer, entry.committerEmail)) {\n\t\t\t\t\t\t\tentry.committerCurrent = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tlet author = authors.get(entry.author!);\n\t\t\t\t\tif (author == null) {\n\t\t\t\t\t\tauthor = { name: entry.author!, lineCount: 0, current: entry.authorCurrent };\n\t\t\t\t\t\tauthors.set(entry.author!, author);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Cache path normalization + URI\n\t\t\t\t\tif (entryPath !== cachedPath) {\n\t\t\t\t\t\tcachedPath = entryPath;\n\t\t\t\t\t\tcachedPathUri = joinUriPath(repoUri, normalizePath(entryPath));\n\t\t\t\t\t}\n\n\t\t\t\t\tlet previousPath: string | undefined;\n\t\t\t\t\tlet previousPathUri: Uri | undefined;\n\t\t\t\t\tif (entry.previousPath != null && entry.previousPath !== entryPath) {\n\t\t\t\t\t\tpreviousPath = entry.previousPath;\n\t\t\t\t\t\tif (previousPath !== cachedPreviousPath) {\n\t\t\t\t\t\t\tcachedPreviousPath = previousPath;\n\t\t\t\t\t\t\tcachedPreviousPathUri = joinUriPath(repoUri, normalizePath(previousPath));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpreviousPathUri = cachedPreviousPathUri;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst file = new GitFileChange(\n\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\tentryPath,\n\t\t\t\t\t\tGitFileIndexStatus.Modified,\n\t\t\t\t\t\tcachedPathUri!,\n\t\t\t\t\t\tpreviousPath,\n\t\t\t\t\t\tpreviousPathUri,\n\t\t\t\t\t\tentry.previousSha,\n\t\t\t\t\t);\n\n\t\t\t\t\tcommit = new GitCommit(\n\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\tentry.sha,\n\t\t\t\t\t\tnew GitCommitIdentity(\n\t\t\t\t\t\t\tentry.author!,\n\t\t\t\t\t\t\tentry.authorEmail,\n\t\t\t\t\t\t\tnew Date(entry.authorTime!),\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tentry.authorCurrent,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tnew GitCommitIdentity(\n\t\t\t\t\t\t\tentry.committer!,\n\t\t\t\t\t\t\tentry.committerEmail,\n\t\t\t\t\t\t\tnew Date(entry.committerTime!),\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tentry.committerCurrent,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tentry.summary ?? '',\n\t\t\t\t\t\t[],\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfiles: undefined,\n\t\t\t\t\t\t\tfiltered: {\n\t\t\t\t\t\t\t\tfiles: [file],\n\t\t\t\t\t\t\t\tpathspec: entryPath,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t[],\n\t\t\t\t\t);\n\n\t\t\t\t\tcommits.set(entry.sha, commit);\n\t\t\t\t}\n\n\t\t\t\t// Accumulate author line counts incrementally\n\t\t\t\tconst authorName = commit.author.name;\n\t\t\t\tif (authorName) {\n\t\t\t\t\tconst author = authors.get(authorName);\n\t\t\t\t\tif (author != null) {\n\t\t\t\t\t\tauthor.lineCount += entry.lineCount;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Build line mappings\n\t\t\t\tconst previousSha = entry.previousSha ?? commit.file?.previousSha;\n\t\t\t\tfor (let i = 0, count = entry.lineCount; i < count; i++) {\n\t\t\t\t\tconst l: GitCommitLine = {\n\t\t\t\t\t\tsha: entry.sha,\n\t\t\t\t\t\tpreviousSha: previousSha,\n\t\t\t\t\t\toriginalLine: entry.originalLine + i,\n\t\t\t\t\t\tline: entry.line + i,\n\t\t\t\t\t};\n\n\t\t\t\t\tcommit.lines.push(l);\n\t\t\t\t\tlines[l.line - 1] = l;\n\t\t\t\t}\n\n\t\t\t\tentry = undefined;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 0x73 /* s — summary */:\n\t\t\t\tentry.summary = line.substring(valueStart);\n\t\t\t\tbreak;\n\n\t\t\tcase 0x70 /* p — previous */: {\n\t\t\t\tconst value = line.substring(valueStart);\n\t\t\t\tconst shaEnd = value.indexOf(' ');\n\t\t\t\tif (shaEnd !== -1) {\n\t\t\t\t\tentry.previousSha = value.substring(0, shaEnd);\n\t\t\t\t\tentry.previousPath = value.substring(shaEnd + 1);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst sortedAuthors = new Map([...authors.entries()].sort((a, b) => b[1].lineCount - a[1].lineCount));\n\n\tsw?.stop({ suffix: ` parsed ${lines.length} lines, ${commits.size} commits` });\n\n\treturn {\n\t\trepoPath: repoPath,\n\t\tauthors: sortedAuthors,\n\t\tcommits: commits,\n\t\tlines: lines,\n\t};\n}\n\n/**\n * Async generator that yields `BlameEntry` objects as they are parsed from\n * a streaming `git blame --incremental` output. Each entry is yielded as soon\n * as its `filename` terminator line is encountered.\n */\nexport async function* parseGitBlameAsync(stream: AsyncIterable<string>): AsyncGenerator<BlameEntry> {\n\tlet entry: BlameEntry | undefined;\n\n\tfor await (const line of iterateAsyncByDelimiter(stream, '\\n')) {\n\t\tconst spaceIdx = line.indexOf(' ');\n\t\tif (spaceIdx === -1) continue;\n\n\t\tif (entry == null) {\n\t\t\tconst sha = line.substring(0, spaceIdx);\n\n\t\t\tlet s = spaceIdx + 1;\n\t\t\tlet e = line.indexOf(' ', s);\n\t\t\tconst originalLine = parseInt(line.substring(s, e), 10);\n\n\t\t\ts = e + 1;\n\t\t\te = line.indexOf(' ', s);\n\t\t\tconst lineno = parseInt(line.substring(s, e), 10);\n\n\t\t\ts = e + 1;\n\t\t\tconst lineCount = parseInt(line.substring(s), 10);\n\n\t\t\tentry = { sha: sha, originalLine: originalLine, line: lineno, lineCount: lineCount };\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst keyLen = spaceIdx;\n\t\tconst valueStart = spaceIdx + 1;\n\n\t\t// Dispatch on first character + key length to avoid creating key substrings\n\t\tswitch (line.charCodeAt(0)) {\n\t\t\tcase 0x61 /* a — author* */:\n\t\t\t\tif (keyLen === 6 /* \"author\" */) {\n\t\t\t\t\tentry.author = line.substring(valueStart);\n\t\t\t\t} else if (keyLen === 11 /* \"author-mail\" | \"author-time\" */) {\n\t\t\t\t\t// Disambiguate at pos 7: 'm' (mail) vs 't' (time)\n\t\t\t\t\tif (line.charCodeAt(7) === 0x6d /* m */) {\n\t\t\t\t\t\tentry.authorEmail = parseEmail(line.substring(valueStart));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tentry.authorTime = parseInt(line.substring(valueStart), 10) * 1000;\n\t\t\t\t\t}\n\t\t\t\t} else if (keyLen === 9 /* \"author-tz\" */) {\n\t\t\t\t\tentry.authorTimeZone = line.substring(valueStart);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 0x63 /* c — committer* */:\n\t\t\t\tif (keyLen === 9 /* \"committer\" */) {\n\t\t\t\t\tentry.committer = line.substring(valueStart);\n\t\t\t\t} else if (keyLen === 14 /* \"committer-mail\" | \"committer-time\" */) {\n\t\t\t\t\t// Disambiguate at pos 10: 'm' (mail) vs 't' (time)\n\t\t\t\t\tif (line.charCodeAt(10) === 0x6d /* m */) {\n\t\t\t\t\t\tentry.committerEmail = parseEmail(line.substring(valueStart));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tentry.committerTime = parseInt(line.substring(valueStart), 10) * 1000;\n\t\t\t\t\t}\n\t\t\t\t} else if (keyLen === 12 /* \"committer-tz\" */) {\n\t\t\t\t\tentry.committerTimeZone = line.substring(valueStart);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 0x66 /* f — filename */:\n\t\t\t\tentry.path = line.substring(valueStart);\n\t\t\t\tyield entry;\n\n\t\t\t\tentry = undefined;\n\t\t\t\tbreak;\n\n\t\t\tcase 0x73 /* s — summary */:\n\t\t\t\tentry.summary = line.substring(valueStart);\n\t\t\t\tbreak;\n\n\t\t\tcase 0x70 /* p — previous */: {\n\t\t\t\tconst value = line.substring(valueStart);\n\t\t\t\tconst shaEnd = value.indexOf(' ');\n\t\t\t\tif (shaEnd !== -1) {\n\t\t\t\t\tentry.previousSha = value.substring(0, shaEnd);\n\t\t\t\t\tentry.previousPath = value.substring(shaEnd + 1);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/** Extracts email from a value like `<user@example.com>` */\nfunction parseEmail(raw: string): string {\n\tconst lt = raw.indexOf('<');\n\tif (lt >= 0) {\n\t\tconst gt =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QAAQ,KAAK,KAAK,CAAC;EAClC,OAAO,KAAK,KAAK,IAAI,UAAU,KAAK,GAAG,EAAE,IAAI,IAAI,UAAU,KAAK,CAAC;CAClE;CACA,OAAO;AACR"}
1
+ {"version":3,"file":"blameParser.js","names":[],"sources":["../../../../git-cli/src/parsers/blameParser.ts"],"sourcesContent":["import type { GitBlame, GitBlameAuthor } from '@gitlens/git/models/blame.js';\nimport type { GitCommitLine } from '@gitlens/git/models/commit.js';\nimport { GitCommit, GitCommitIdentity } from '@gitlens/git/models/commit.js';\nimport { GitFileChange } from '@gitlens/git/models/fileChange.js';\nimport { GitFileIndexStatus } from '@gitlens/git/models/fileStatus.js';\nimport { uncommitted } from '@gitlens/git/models/revision.js';\nimport type { GitUser } from '@gitlens/git/models/user.js';\nimport { isUserMatch } from '@gitlens/git/utils/user.utils.js';\nimport { normalizePath } from '@gitlens/utils/path.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport { iterateAsyncByDelimiter, iterateByDelimiter, unquoteCString } from '@gitlens/utils/string.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { fileUri, joinUriPath } from '@gitlens/utils/uri.js';\n\nexport interface BlameEntry {\n\tsha: string;\n\tline: number;\n\toriginalLine: number;\n\tlineCount: number;\n\n\tauthor?: string;\n\tauthorTime?: number;\n\tauthorTimeZone?: string;\n\tauthorEmail?: string;\n\n\tcommitter?: string;\n\tcommitterTime?: number;\n\tcommitterTimeZone?: string;\n\tcommitterEmail?: string;\n\n\tpreviousSha?: string;\n\tpreviousPath?: string;\n\n\tpath?: string;\n\tsummary?: string;\n\n\tauthorCurrent?: boolean;\n\tcommitterCurrent?: boolean;\n}\n\n/**\n * Decodes one kind of blame file name, remembering the last: git repeats the file name (and the one it was renamed from)\n * in every chunk, so a name it quoted would otherwise be decoded again each time\n */\nfunction createPathUnquoter(): (raw: string) => string {\n\tlet lastRaw: string | undefined;\n\tlet lastPath = '';\n\treturn raw => {\n\t\tif (raw.charCodeAt(0) !== 0x22 /* \" */) return raw;\n\n\t\tif (raw !== lastRaw) {\n\t\t\tlastRaw = raw;\n\t\t\tlastPath = unquoteCString(raw);\n\t\t}\n\t\treturn lastPath;\n\t};\n}\n\nexport function parseGitBlame(\n\trepoPath: string,\n\tdata: string | undefined,\n\tcurrentUser: GitUser | undefined,\n\tmodifiedTime?: number,\n): GitBlame | undefined {\n\tusing sw = maybeStopWatch(`Git.parseBlame(${repoPath})`, { log: { onlyExit: true, level: 'debug' } });\n\tif (!data) {\n\t\tsw?.stop({ suffix: ` no data` });\n\t\treturn undefined;\n\t}\n\n\t// Pre-compute constants once\n\tconst normalizedRepoPath = normalizePath(repoPath);\n\tconst repoUri = fileUri(normalizedRepoPath);\n\n\t// Path normalization + URI cache (single-file blame = 1 cache entry)\n\tlet cachedPath: string | undefined;\n\tlet cachedPathUri: Uri | undefined;\n\tlet cachedPreviousPath: string | undefined;\n\tlet cachedPreviousPathUri: Uri | undefined;\n\n\tconst unquotePath = createPathUnquoter();\n\tconst unquotePreviousPath = createPathUnquoter();\n\tconst authors = new Map<string, GitBlameAuthor>();\n\tconst commits = new Map<string, GitCommit>();\n\tconst lines: GitCommitLine[] = [];\n\n\tlet entry: BlameEntry | undefined;\n\n\tfor (const line of iterateByDelimiter(data, '\\n')) {\n\t\tconst spaceIdx = line.indexOf(' ');\n\t\tif (spaceIdx === -1) continue;\n\n\t\tif (entry == null) {\n\t\t\t// Header line: <sha> <originalLine> <currentLine> <lineCount>\n\t\t\tconst sha = line.substring(0, spaceIdx);\n\n\t\t\tlet s = spaceIdx + 1;\n\t\t\tlet e = line.indexOf(' ', s);\n\t\t\tconst originalLine = parseInt(line.substring(s, e), 10);\n\n\t\t\ts = e + 1;\n\t\t\te = line.indexOf(' ', s);\n\t\t\tconst lineno = parseInt(line.substring(s, e), 10);\n\n\t\t\ts = e + 1;\n\t\t\tconst lineCount = parseInt(line.substring(s), 10);\n\n\t\t\tentry = { sha: sha, originalLine: originalLine, line: lineno, lineCount: lineCount };\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Dispatch on first character + key length to avoid creating key substrings\n\t\tconst keyLen = spaceIdx;\n\t\tconst valueStart = spaceIdx + 1;\n\n\t\tswitch (line.charCodeAt(0)) {\n\t\t\tcase 0x61 /* a — author* */:\n\t\t\t\tif (keyLen === 6 /* \"author\" */) {\n\t\t\t\t\tentry.author = line.substring(valueStart);\n\t\t\t\t} else if (keyLen === 11 /* \"author-mail\" | \"author-time\" */) {\n\t\t\t\t\t// Disambiguate at pos 7: 'm' (mail) vs 't' (time)\n\t\t\t\t\tif (line.charCodeAt(7) === 0x6d /* m */) {\n\t\t\t\t\t\tentry.authorEmail = parseEmail(line.substring(valueStart));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tentry.authorTime = parseInt(line.substring(valueStart), 10) * 1000;\n\t\t\t\t\t}\n\t\t\t\t} else if (keyLen === 9 /* \"author-tz\" */) {\n\t\t\t\t\tentry.authorTimeZone = line.substring(valueStart);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 0x63 /* c — committer* */:\n\t\t\t\tif (keyLen === 9 /* \"committer\" */) {\n\t\t\t\t\tentry.committer = line.substring(valueStart);\n\t\t\t\t} else if (keyLen === 14 /* \"committer-mail\" | \"committer-time\" */) {\n\t\t\t\t\t// Disambiguate at pos 10: 'm' (mail) vs 't' (time)\n\t\t\t\t\tif (line.charCodeAt(10) === 0x6d /* m */) {\n\t\t\t\t\t\tentry.committerEmail = parseEmail(line.substring(valueStart));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tentry.committerTime = parseInt(line.substring(valueStart), 10) * 1000;\n\t\t\t\t\t}\n\t\t\t\t} else if (keyLen === 12 /* \"committer-tz\" */) {\n\t\t\t\t\tentry.committerTimeZone = line.substring(valueStart);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 0x66 /* f — filename */: {\n\t\t\t\t// Don't trim — spaces in filenames are valid\n\t\t\t\tentry.path = unquotePath(line.substring(valueStart));\n\n\t\t\t\t// Assemble model immediately — no intermediate storage\n\t\t\t\tconst entryPath = entry.path;\n\t\t\t\tconst isUncommittedEntry = entry.sha === uncommitted;\n\n\t\t\t\tlet commit = commits.get(entry.sha);\n\t\t\t\tif (commit == null) {\n\t\t\t\t\tif (isUncommittedEntry) {\n\t\t\t\t\t\tentry.author = currentUser?.name ?? '';\n\t\t\t\t\t\tentry.authorCurrent = true;\n\t\t\t\t\t\tentry.authorEmail = currentUser?.email;\n\t\t\t\t\t\tentry.authorTime = modifiedTime ?? entry.authorTime ?? 0;\n\t\t\t\t\t\tentry.committer = entry.author;\n\t\t\t\t\t\tentry.committerEmail = entry.authorEmail;\n\t\t\t\t\t\tentry.committerTime = entry.authorTime;\n\t\t\t\t\t\tentry.committerCurrent = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (isUserMatch(currentUser, entry.author, entry.authorEmail)) {\n\t\t\t\t\t\t\tentry.authorCurrent = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (isUserMatch(currentUser, entry.committer, entry.committerEmail)) {\n\t\t\t\t\t\t\tentry.committerCurrent = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tlet author = authors.get(entry.author!);\n\t\t\t\t\tif (author == null) {\n\t\t\t\t\t\tauthor = { name: entry.author!, lineCount: 0, current: entry.authorCurrent };\n\t\t\t\t\t\tauthors.set(entry.author!, author);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Cache path normalization + URI\n\t\t\t\t\tif (entryPath !== cachedPath) {\n\t\t\t\t\t\tcachedPath = entryPath;\n\t\t\t\t\t\tcachedPathUri = joinUriPath(repoUri, normalizePath(entryPath));\n\t\t\t\t\t}\n\n\t\t\t\t\tlet previousPath: string | undefined;\n\t\t\t\t\tlet previousPathUri: Uri | undefined;\n\t\t\t\t\tif (entry.previousPath != null && entry.previousPath !== entryPath) {\n\t\t\t\t\t\tpreviousPath = entry.previousPath;\n\t\t\t\t\t\tif (previousPath !== cachedPreviousPath) {\n\t\t\t\t\t\t\tcachedPreviousPath = previousPath;\n\t\t\t\t\t\t\tcachedPreviousPathUri = joinUriPath(repoUri, normalizePath(previousPath));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpreviousPathUri = cachedPreviousPathUri;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst file = new GitFileChange(\n\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\tentryPath,\n\t\t\t\t\t\tGitFileIndexStatus.Modified,\n\t\t\t\t\t\tcachedPathUri!,\n\t\t\t\t\t\tpreviousPath,\n\t\t\t\t\t\tpreviousPathUri,\n\t\t\t\t\t\tentry.previousSha,\n\t\t\t\t\t);\n\n\t\t\t\t\tcommit = new GitCommit(\n\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\tentry.sha,\n\t\t\t\t\t\tnew GitCommitIdentity(\n\t\t\t\t\t\t\tentry.author!,\n\t\t\t\t\t\t\tentry.authorEmail,\n\t\t\t\t\t\t\tnew Date(entry.authorTime!),\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tentry.authorCurrent,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tnew GitCommitIdentity(\n\t\t\t\t\t\t\tentry.committer!,\n\t\t\t\t\t\t\tentry.committerEmail,\n\t\t\t\t\t\t\tnew Date(entry.committerTime!),\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tentry.committerCurrent,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tentry.summary ?? '',\n\t\t\t\t\t\t[],\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfiles: undefined,\n\t\t\t\t\t\t\tfiltered: {\n\t\t\t\t\t\t\t\tfiles: [file],\n\t\t\t\t\t\t\t\tpathspec: entryPath,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t[],\n\t\t\t\t\t);\n\n\t\t\t\t\tcommits.set(entry.sha, commit);\n\t\t\t\t}\n\n\t\t\t\t// Accumulate author line counts incrementally\n\t\t\t\tconst authorName = commit.author.name;\n\t\t\t\tif (authorName) {\n\t\t\t\t\tconst author = authors.get(authorName);\n\t\t\t\t\tif (author != null) {\n\t\t\t\t\t\tauthor.lineCount += entry.lineCount;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Build line mappings\n\t\t\t\tconst previousSha = entry.previousSha ?? commit.file?.previousSha;\n\t\t\t\tfor (let i = 0, count = entry.lineCount; i < count; i++) {\n\t\t\t\t\tconst l: GitCommitLine = {\n\t\t\t\t\t\tsha: entry.sha,\n\t\t\t\t\t\tpreviousSha: previousSha,\n\t\t\t\t\t\toriginalLine: entry.originalLine + i,\n\t\t\t\t\t\tline: entry.line + i,\n\t\t\t\t\t};\n\n\t\t\t\t\tcommit.lines.push(l);\n\t\t\t\t\tlines[l.line - 1] = l;\n\t\t\t\t}\n\n\t\t\t\tentry = undefined;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 0x73 /* s — summary */:\n\t\t\t\tentry.summary = line.substring(valueStart);\n\t\t\t\tbreak;\n\n\t\t\tcase 0x70 /* p — previous */: {\n\t\t\t\tconst value = line.substring(valueStart);\n\t\t\t\tconst shaEnd = value.indexOf(' ');\n\t\t\t\tif (shaEnd !== -1) {\n\t\t\t\t\tentry.previousSha = value.substring(0, shaEnd);\n\t\t\t\t\tentry.previousPath = unquotePreviousPath(value.substring(shaEnd + 1));\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst sortedAuthors = new Map([...authors.entries()].sort((a, b) => b[1].lineCount - a[1].lineCount));\n\n\tsw?.stop({ suffix: ` parsed ${lines.length} lines, ${commits.size} commits` });\n\n\treturn {\n\t\trepoPath: repoPath,\n\t\tauthors: sortedAuthors,\n\t\tcommits: commits,\n\t\tlines: lines,\n\t};\n}\n\n/**\n * Async generator that yields `BlameEntry` objects as they are parsed from\n * a streaming `git blame --incremental` output. Each entry is yielded as soon\n * as its `filename` terminator line is encountered.\n */\nexport async function* parseGitBlameAsync(stream: AsyncIterable<string>): AsyncGenerator<BlameEntry> {\n\tconst unquotePath = createPathUnquoter();\n\tconst unquotePreviousPath = createPathUnquoter();\n\tlet entry: BlameEntry | undefined;\n\n\tfor await (const line of iterateAsyncByDelimiter(stream, '\\n')) {\n\t\tconst spaceIdx = line.indexOf(' ');\n\t\tif (spaceIdx === -1) continue;\n\n\t\tif (entry == null) {\n\t\t\tconst sha = line.substring(0, spaceIdx);\n\n\t\t\tlet s = spaceIdx + 1;\n\t\t\tlet e = line.indexOf(' ', s);\n\t\t\tconst originalLine = parseInt(line.substring(s, e), 10);\n\n\t\t\ts = e + 1;\n\t\t\te = line.indexOf(' ', s);\n\t\t\tconst lineno = parseInt(line.substring(s, e), 10);\n\n\t\t\ts = e + 1;\n\t\t\tconst lineCount = parseInt(line.substring(s), 10);\n\n\t\t\tentry = { sha: sha, originalLine: originalLine, line: lineno, lineCount: lineCount };\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst keyLen = spaceIdx;\n\t\tconst valueStart = spaceIdx + 1;\n\n\t\t// Dispatch on first character + key length to avoid creating key substrings\n\t\tswitch (line.charCodeAt(0)) {\n\t\t\tcase 0x61 /* a — author* */:\n\t\t\t\tif (keyLen === 6 /* \"author\" */) {\n\t\t\t\t\tentry.author = line.substring(valueStart);\n\t\t\t\t} else if (keyLen === 11 /* \"author-mail\" | \"author-time\" */) {\n\t\t\t\t\t// Disambiguate at pos 7: 'm' (mail) vs 't' (time)\n\t\t\t\t\tif (line.charCodeAt(7) === 0x6d /* m */) {\n\t\t\t\t\t\tentry.authorEmail = parseEmail(line.substring(valueStart));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tentry.authorTime = parseInt(line.substring(valueStart), 10) * 1000;\n\t\t\t\t\t}\n\t\t\t\t} else if (keyLen === 9 /* \"author-tz\" */) {\n\t\t\t\t\tentry.authorTimeZone = line.substring(valueStart);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 0x63 /* c — committer* */:\n\t\t\t\tif (keyLen === 9 /* \"committer\" */) {\n\t\t\t\t\tentry.committer = line.substring(valueStart);\n\t\t\t\t} else if (keyLen === 14 /* \"committer-mail\" | \"committer-time\" */) {\n\t\t\t\t\t// Disambiguate at pos 10: 'm' (mail) vs 't' (time)\n\t\t\t\t\tif (line.charCodeAt(10) === 0x6d /* m */) {\n\t\t\t\t\t\tentry.committerEmail = parseEmail(line.substring(valueStart));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tentry.committerTime = parseInt(line.substring(valueStart), 10) * 1000;\n\t\t\t\t\t}\n\t\t\t\t} else if (keyLen === 12 /* \"committer-tz\" */) {\n\t\t\t\t\tentry.committerTimeZone = line.substring(valueStart);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 0x66 /* f — filename */:\n\t\t\t\tentry.path = unquotePath(line.substring(valueStart));\n\t\t\t\tyield entry;\n\n\t\t\t\tentry = undefined;\n\t\t\t\tbreak;\n\n\t\t\tcase 0x73 /* s — summary */:\n\t\t\t\tentry.summary = line.substring(valueStart);\n\t\t\t\tbreak;\n\n\t\t\tcase 0x70 /* p — previous */: {\n\t\t\t\tconst value = line.substring(valueStart);\n\t\t\t\tconst shaEnd = value.indexOf(' ');\n\t\t\t\tif (shaEnd !== -1) {\n\t\t\t\t\tentry.previousSha = value.substring(0, shaEnd);\n\t\t\t\t\tentry.previousPath = unquotePreviousPath(value.substring(shaEnd + 1));\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/** Extracts email from a value like `<user@example.com>` */\nfunction parseEmail(raw: string): string {\n\tconst lt = raw.indexOf('<');\n\tif (lt >= 0) {\n\t\tconst gt = raw.indexOf('>', lt + 1);\n\t\treturn gt > lt ? raw.substring(lt + 1, gt) : raw.substring(lt + 1);\n\t}\n\treturn raw;\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4CA,SA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;KAClB,MAAM,cAAc,MAAM,UAAU,GAAG,MAAM;KAC7C,MAAM,eAAe,oBAAoB,MAAM,UAAU,SAAS,CAAC,CAAC;IACrE;IACA;GACD;EACD;CACD;AACD;;AAGA,SAAS,WAAW,KAAqB;CACxC,MAAM,KAAK,IAAI,QAAQ,GAAG;CAC1B,IAAI,MAAM,GAAG;EACZ,MAAM,KAAK,IAAI,QAAQ,KAAK,KAAK,CAAC;EAClC,OAAO,KAAK,KAAK,IAAI,UAAU,KAAK,GAAG,EAAE,IAAI,IAAI,UAAU,KAAK,CAAC;CAClE;CACA,OAAO;AACR"}
@@ -1,8 +1,8 @@
1
- import { flattenString, iterateAsyncByDelimiter, iterateByDelimiter } from "../../utils/string.js";
1
+ import { flattenString, iterateAsyncByDelimiter, iterateByDelimiter, unquoteCString } from "../../utils/string.js";
2
2
  import { joinPaths, normalizePath } from "../../utils/path.js";
3
3
  import { maybeStopWatch } from "../../utils/stopwatch.js";
4
4
  import _usingCtx from "../../_virtual/@oxc-project+runtime/helpers/esm/usingCtx.js";
5
- import { diffHunkRegex, diffRegex } from "../../git/parsers/diffParser.js";
5
+ import { diffHunkRegex, parseDiffFilePaths, parseQuotedRenameOrCopyPaths } from "../../git/parsers/diffParser.js";
6
6
  //#region ../git-cli/src/parsers/logParser.ts
7
7
  const commitsMapping = {
8
8
  sha: "%H",
@@ -361,13 +361,13 @@ function createLogParserWithFilesAndStats(mapping) {
361
361
  let originalPath;
362
362
  const pathTabIndex = pathPart.indexOf(" ");
363
363
  if ((status === "R" || status === "C") && pathTabIndex !== -1) {
364
- originalPath = pathPart.substring(0, pathTabIndex);
365
- path = pathPart.substring(pathTabIndex + 1);
366
- } else path = pathPart;
367
- infoMap.set(path.trim(), {
364
+ originalPath = unquoteCString(pathPart.substring(0, pathTabIndex).trim());
365
+ path = unquoteCString(pathPart.substring(pathTabIndex + 1).trim());
366
+ } else path = unquoteCString(pathPart.trim());
367
+ infoMap.set(path, {
368
368
  mode: newMode,
369
369
  status,
370
- originalPath: originalPath?.trim(),
370
+ originalPath,
371
371
  oid,
372
372
  previousOid
373
373
  });
@@ -388,13 +388,13 @@ function createLogParserWithFilesAndStats(mapping) {
388
388
  let path = line.substring(endIndex + 1);
389
389
  let originalPath;
390
390
  ({path, originalPath} = parseCopyOrRename(path, false));
391
- const info = infoMap.get(path.trim());
391
+ const info = infoMap.get(path);
392
392
  const status = info?.status ?? (originalPath ? "R" : "M");
393
393
  if (info?.originalPath) originalPath = info.originalPath;
394
394
  const file = {
395
395
  status,
396
- path: path.trim(),
397
- originalPath: originalPath?.trim(),
396
+ path,
397
+ originalPath,
398
398
  additions: additions === "-" ? 0 : parseInt(additions, 10) || 0,
399
399
  deletions: deletions === "-" ? 0 : parseInt(deletions, 10) || 0,
400
400
  mode: info?.mode,
@@ -575,7 +575,7 @@ function createLogParserWithFileSummary(mapping) {
575
575
  }
576
576
  startIndex = line.indexOf(" ", 13);
577
577
  if (startIndex > -1) {
578
- path = line.substring(startIndex + 1);
578
+ path = unquoteCString(line.substring(startIndex + 1));
579
579
  files.push({
580
580
  path,
581
581
  status
@@ -637,7 +637,16 @@ function createLogParserWithFileSummary(mapping) {
637
637
  parse
638
638
  };
639
639
  }
640
- function parseCopyOrRename(path, stripPercentage) {
640
+ /**
641
+ * Reads a numstat or summary name, or the two names of a rename or copy, trimmed as git wrote them: an unquoted name
642
+ * is trimmed, while a quoted one keeps the whitespace inside its quotes
643
+ */
644
+ function parseCopyOrRename(field, stripPercentage) {
645
+ const path = field.trim();
646
+ if (path.includes("\"")) {
647
+ const quoted = parseQuotedRenameOrCopyPaths(path, stripPercentage);
648
+ if (quoted != null) return quoted;
649
+ }
641
650
  const renameIndex = path.indexOf(" => ");
642
651
  if (renameIndex === -1) return { path };
643
652
  let hasBraces = true;
@@ -708,8 +717,9 @@ function createLogParserWithPatch(mapping) {
708
717
  const lines = iterateByDelimiter(content, "\n");
709
718
  let line = lines.next();
710
719
  if (line.done) return void 0;
711
- const fileMatch = diffRegex.exec(line.value);
712
- if (fileMatch == null) return void 0;
720
+ if (!content.startsWith("diff --git ")) return void 0;
721
+ const paths = parseDiffFilePaths(content);
722
+ if (paths == null) return void 0;
713
723
  while (!line.done && !line.value.startsWith("@@ ")) line = lines.next();
714
724
  const rangeMatch = line.value.match(diffHunkRegex);
715
725
  let range;
@@ -729,9 +739,9 @@ function createLogParserWithPatch(mapping) {
729
739
  } : void 0;
730
740
  }
731
741
  return {
732
- status: fileMatch[1] === "rename" ? "R" : "M",
733
- path: fileMatch[2],
734
- originalPath: fileMatch[1] === "rename" ? fileMatch[3] : void 0,
742
+ status: "M",
743
+ path: paths.path,
744
+ originalPath: void 0,
735
745
  range,
736
746
  originalRange
737
747
  };
@@ -970,7 +980,7 @@ function createLogParserWithFiles(mapping) {
970
980
  for (const line of iterateByDelimiter(content, "\n")) {
971
981
  const trimmed = line.trim();
972
982
  if (!trimmed) continue;
973
- files.push({ path: trimmed });
983
+ files.push({ path: unquoteCString(trimmed) });
974
984
  }
975
985
  return files;
976
986
  }