@gitkraken/core-gitlens 0.38.2 → 0.38.4
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 +24 -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/providers/diff.d.ts +10 -0
- package/dist/git/providers/revision.d.ts +8 -1
- 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/diff.d.ts +2 -0
- package/dist/git-cli/providers/diff.js +10 -7
- package/dist/git-cli/providers/diff.js.map +1 -1
- package/dist/git-cli/providers/revision.d.ts +3 -1
- package/dist/git-cli/providers/revision.js +10 -5
- 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/plus/git-github/providers/github/revision.d.ts +3 -1
- package/dist/plus/git-github/providers/github/revision.js +1 -1
- package/dist/plus/git-github/providers/github/revision.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/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
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,27 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.38.4] - 2026-11-15
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Adds `paths` to `diff.getDiff` and `diff.getParsedDiff`: limits the diff to those repo-relative paths, matched literally and exactly as given (a name with glob characters matches only itself, and a backslash is a file-name character rather than a separator), batched to fit the command line, with each batch's output joined in order. A host that already holds exact names, such as the ones `diff.getDiffStatus` returns, can now read the hunks of a file whose name holds a backslash on Linux or macOS, where `uris` rewrote it to a different path and found nothing. An empty list resolves `undefined` without running git, `paths` wins over `uris`, and a rename whose two sides fall in different batches reads as a delete and an add (git, git-cli)
|
|
14
|
+
- Adds `literalPath` to the options of `revision.getRevisionContent`: reads `path` as a repo-relative path exactly as given, with no splitting or separator rewriting, so a host can read the bytes of a file whose name holds a backslash on Linux or macOS, at a commit or from the index. Without it a `\` is still read as a separator (git, git-cli, git-github)
|
|
15
|
+
|
|
16
|
+
## [0.38.3] - 2026-11-15
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Fixes `diff.getParsedDiff` (and `filterDiffFiles`) misreading the paths of some files. A path holding ` b/` (`Plan b/notes.md`) was split at the wrong place, so the file came back under a shorter path and as a rename of a longer one, and a path git C-quotes (one holding a `"`, `\`, tab or newline) kept its quotes and escapes, with the `a/` or `b/` prefix inside them. The paths now come from the `+++`, `---`, `rename` and `copy` lines, and the `diff --git` line only for a section with none of them, split where its two halves match, so a file is named exactly as `git diff --numstat -z` names it (git)
|
|
21
|
+
- Fixes `status.getStatus` returning an untracked, modified or renamed file whose name git C-quotes (`"u-quo\"te.txt"`) under its quoted form, so the name matched no file on disk. The status is now read with `-z`, which git never quotes (git-cli)
|
|
22
|
+
- Fixes `revision.getTreeForRevision` and `revision.getTreeEntryForRevision` returning the entry of a path git C-quotes under its quoted form, and splitting a path holding a tab at it. The tree is now read with `-z` (git-cli)
|
|
23
|
+
- Fixes `diff.getPreviousComparisonUrisForRange` not finding the file in the log of a line range when its path holds ` b/` or git C-quotes it, which read that file's paths from the same split (git-cli)
|
|
24
|
+
- Fixes the file lists read from `git log` (the files of `commits.getLog` and `commits.getCommit` commits and of `stash.getStash` and `stash.getStashCommitFiles` stashes, the file names of the graph's rows, and the lookups that follow a file through its history, such as `diff.getPreviousComparisonUris`) naming a file git C-quotes (one holding a `"`, `\`, tab or newline) by its quoted form, so the name matched no file on disk. Each name is now unquoted as git writes it, including a rename in which git quoted one side or both, which it writes as `old => new` rather than the compact `prefix/{old => new}`. A name holding a newline can still split a record (git-cli)
|
|
25
|
+
- Fixes `blame.getBlame` (and the streamed blame) naming a file git C-quotes, and the path it was renamed from, by their quoted forms (git-cli)
|
|
26
|
+
- Fixes `diff.getDiffStatus` leaving a created, deleted, copied or type-changed file at status `M` or `R` when git quotes its name in the `--summary` lines it reads statuses from (git)
|
|
27
|
+
- Fixes `diff.getDiffFiles` throwing for a created or deleted file whose name holds a tab, listing a created or deleted file whose name holds a `\` twice, and naming a renamed one with its `\` turned into `/` (git)
|
|
28
|
+
- Reclaims Jira Cloud and Linear discovery data for retired credentials during later cache writes, while preserving active-account last-known autolinks and rejecting delayed reads from retired sessions (integrations)
|
|
29
|
+
|
|
9
30
|
## [0.38.2] - 2026-11-14
|
|
10
31
|
|
|
11
32
|
### Added
|
|
@@ -1306,7 +1327,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|
|
1306
1327
|
|
|
1307
1328
|
- Initial release. Bundles `@gitlens/utils`, `@gitlens/git`, `@gitlens/git-cli`, `@gitlens/ai`, and `@gitlens/git-github` into a single core npm package with subpath exports.
|
|
1308
1329
|
|
|
1309
|
-
[unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.38.
|
|
1330
|
+
[unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.38.4...HEAD
|
|
1331
|
+
[0.38.4]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.38.3...gitkraken:releases/core/v0.38.4
|
|
1332
|
+
[0.38.3]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.38.2...gitkraken:releases/core/v0.38.3
|
|
1310
1333
|
[0.38.2]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.38.1...gitkraken:releases/core/v0.38.2
|
|
1311
1334
|
[0.38.1]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.38.0...gitkraken:releases/core/v0.38.1
|
|
1312
1335
|
[0.38.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.37.1...gitkraken:releases/core/v0.38.0
|
|
@@ -4,6 +4,27 @@ import { GitFile } from "../models/file.js";
|
|
|
4
4
|
//#region ../git/src/parsers/diffParser.d.ts
|
|
5
5
|
export declare const diffRegex: RegExp;
|
|
6
6
|
export declare const diffHunkRegex: RegExp;
|
|
7
|
+
/**
|
|
8
|
+
* Reads the paths of a file's diff section, which starts at its `diff --git` line, from the lines git writes before the
|
|
9
|
+
* first hunk. The `diff --git` line alone can't be split reliably (a path can hold ` b/`, and git quotes a path with a
|
|
10
|
+
* `"`, `\`, tab or newline), so it is the last resort: the paths come from `+++`, `---` and the `rename`/`copy` lines.
|
|
11
|
+
* A path comes out as `git diff --numstat -z` names it.
|
|
12
|
+
* @returns `originalPath` is `path` for a file that wasn't renamed or copied
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseDiffFilePaths(section: string): {
|
|
15
|
+
path: string;
|
|
16
|
+
originalPath: string;
|
|
17
|
+
} | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Reads a `--numstat` or `--summary` rename or copy in which git quoted a name. Git then drops the compact
|
|
20
|
+
* `prefix/{old => new}/suffix` form for `old => new`, each side quoted on its own only when it needs it; a name git
|
|
21
|
+
* didn't quote holds no `"`. A lone quoted name, as in a numstat line that isn't a rename, comes back as `path` alone.
|
|
22
|
+
* Names come back as git names them, so a `\` in one stays (git quotes every name holding one)
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseQuotedRenameOrCopyPaths(text: string, stripPercentage: boolean): {
|
|
25
|
+
path: string;
|
|
26
|
+
originalPath?: string;
|
|
27
|
+
} | undefined;
|
|
7
28
|
export declare function parseGitDiff(data: string, includeRawContent?: boolean): ParsedGitDiff;
|
|
8
29
|
/**
|
|
9
30
|
* Filters a diff string, keeping only files whose paths are returned by the predicate.
|
|
@@ -46,6 +67,10 @@ export declare function parseGitFileDiff(data: string, includeRawContent?: boole
|
|
|
46
67
|
* octal digits differ) are promoted to `T`.
|
|
47
68
|
*/
|
|
48
69
|
export declare function parseGitDiffNumStatFiles(data: string, repoPath: string): GitFile[] | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Parses the output of `git apply --numstat --summary -z`. Unlike `git diff`, `git apply` writes the names of its
|
|
72
|
+
* summary lines as they are, never C-quoted, so they are read as written
|
|
73
|
+
*/
|
|
49
74
|
export declare function parseGitApplyFiles(data: string, repoPath: string): GitFileChange[];
|
|
50
75
|
export declare function parseGitDiffShortStat(data: string): GitDiffShortStat | undefined;
|
|
51
76
|
//#endregion
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readCQuotedString, unquoteCString } from "../../utils/string.js";
|
|
1
2
|
import { fileUri, joinUriPath } from "../../utils/uri.js";
|
|
2
3
|
import { normalizePath } from "../../utils/path.js";
|
|
3
4
|
import { GitFileIndexStatus } from "../models/fileStatus.js";
|
|
@@ -15,6 +16,135 @@ const similarityRegex = /similarity index (\d+)%/;
|
|
|
15
16
|
const diffGitSplitRegex = /^diff --git /m;
|
|
16
17
|
const diffGitLookaheadRegex = /^(?=diff --git )/m;
|
|
17
18
|
const diffSummaryRegex = /(rename|copy) (.*?)\{?([^{]+?)\s+=>\s+([^}]+)\}?(.*?)(?: \(\d+%\))|(create|delete) mode \d+ (.+)|mode change (\d+) => (\d+) (.+)/;
|
|
19
|
+
/**
|
|
20
|
+
* Reads the path a header line names after its fixed lead-in, without the `a/` or `b/` prefix expected of it. A quoted
|
|
21
|
+
* name carries the prefix inside its quotes. Git ends an unquoted `---` or `+++` name that holds a space with a tab,
|
|
22
|
+
* which a name can't hold itself
|
|
23
|
+
*/
|
|
24
|
+
function readHeaderPath(rest, prefix) {
|
|
25
|
+
if (rest.startsWith("\"")) {
|
|
26
|
+
const quoted = readCQuotedString(rest, 0);
|
|
27
|
+
if (quoted == null || !quoted.value.startsWith(prefix)) return void 0;
|
|
28
|
+
return quoted.value.substring(prefix.length);
|
|
29
|
+
}
|
|
30
|
+
if (!rest.startsWith(prefix)) return void 0;
|
|
31
|
+
return rest.endsWith(" ") ? rest.substring(prefix.length, rest.length - 1) : rest.substring(prefix.length);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The new-side path of a `diff --git` line (without its lead-in) when no other line names it, so both halves are the
|
|
35
|
+
* same path: split where they match, since a path can hold ` b/` itself
|
|
36
|
+
*/
|
|
37
|
+
function readGitLinePath(rest) {
|
|
38
|
+
if (rest.startsWith("\"")) {
|
|
39
|
+
const quoted = readCQuotedString(rest, 0);
|
|
40
|
+
if (quoted == null || rest[quoted.end] !== " ") return void 0;
|
|
41
|
+
return readHeaderPath(rest.substring(quoted.end + 1), "b/");
|
|
42
|
+
}
|
|
43
|
+
const length = rest.length - 5;
|
|
44
|
+
if (length < 0 || length % 2 !== 0 || !rest.startsWith("a/")) return void 0;
|
|
45
|
+
const half = length / 2;
|
|
46
|
+
const path = rest.substring(2, 2 + half);
|
|
47
|
+
return rest.startsWith(" b/", 2 + half) && rest.endsWith(path) ? path : void 0;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Reads the paths of a file's diff section, which starts at its `diff --git` line, from the lines git writes before the
|
|
51
|
+
* first hunk. The `diff --git` line alone can't be split reliably (a path can hold ` b/`, and git quotes a path with a
|
|
52
|
+
* `"`, `\`, tab or newline), so it is the last resort: the paths come from `+++`, `---` and the `rename`/`copy` lines.
|
|
53
|
+
* A path comes out as `git diff --numstat -z` names it.
|
|
54
|
+
* @returns `originalPath` is `path` for a file that wasn't renamed or copied
|
|
55
|
+
*/
|
|
56
|
+
function parseDiffFilePaths(section) {
|
|
57
|
+
let gitLine;
|
|
58
|
+
let newName;
|
|
59
|
+
let oldName;
|
|
60
|
+
let renamedTo;
|
|
61
|
+
let renamedFrom;
|
|
62
|
+
for (let start = 0; start < section.length;) {
|
|
63
|
+
let end = section.indexOf("\n", start);
|
|
64
|
+
if (end === -1) end = section.length;
|
|
65
|
+
const lineStart = start;
|
|
66
|
+
start = end + 1;
|
|
67
|
+
switch (section.charCodeAt(lineStart)) {
|
|
68
|
+
case 43:
|
|
69
|
+
if (section.startsWith("+++ ", lineStart)) {
|
|
70
|
+
const rest = section.substring(lineStart + 4, end);
|
|
71
|
+
if (rest !== "/dev/null") newName = readHeaderPath(rest, "b/");
|
|
72
|
+
}
|
|
73
|
+
break;
|
|
74
|
+
case 45:
|
|
75
|
+
if (section.startsWith("--- ", lineStart)) {
|
|
76
|
+
const rest = section.substring(lineStart + 4, end);
|
|
77
|
+
if (rest !== "/dev/null") oldName = readHeaderPath(rest, "a/");
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
case 114:
|
|
81
|
+
if (section.startsWith("rename to ", lineStart)) renamedTo = readHeaderPath(section.substring(lineStart + 10, end), "");
|
|
82
|
+
else if (section.startsWith("rename from ", lineStart)) renamedFrom = readHeaderPath(section.substring(lineStart + 12, end), "");
|
|
83
|
+
break;
|
|
84
|
+
case 99:
|
|
85
|
+
if (section.startsWith("copy to ", lineStart)) renamedTo = readHeaderPath(section.substring(lineStart + 8, end), "");
|
|
86
|
+
else if (section.startsWith("copy from ", lineStart)) renamedFrom = readHeaderPath(section.substring(lineStart + 10, end), "");
|
|
87
|
+
break;
|
|
88
|
+
case 100:
|
|
89
|
+
if (section.startsWith("diff --git ", lineStart)) gitLine ??= section.substring(lineStart + 11, end);
|
|
90
|
+
break;
|
|
91
|
+
case 64:
|
|
92
|
+
if (section.startsWith("@@ ", lineStart)) start = section.length;
|
|
93
|
+
break;
|
|
94
|
+
case 71: if (end - lineStart === 16 && section.startsWith("GIT binary patch", lineStart)) start = section.length;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const path = newName ?? renamedTo ?? oldName ?? (gitLine != null ? readGitLinePath(gitLine) : void 0);
|
|
98
|
+
if (path != null) return {
|
|
99
|
+
path,
|
|
100
|
+
originalPath: renamedFrom ?? oldName ?? path
|
|
101
|
+
};
|
|
102
|
+
const match = gitLine != null ? diffRegex.exec(`diff --git ${gitLine}`) : null;
|
|
103
|
+
return match != null ? {
|
|
104
|
+
path: match[2],
|
|
105
|
+
originalPath: match[1]
|
|
106
|
+
} : void 0;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Reads a `--numstat` or `--summary` rename or copy in which git quoted a name. Git then drops the compact
|
|
110
|
+
* `prefix/{old => new}/suffix` form for `old => new`, each side quoted on its own only when it needs it; a name git
|
|
111
|
+
* didn't quote holds no `"`. A lone quoted name, as in a numstat line that isn't a rename, comes back as `path` alone.
|
|
112
|
+
* Names come back as git names them, so a `\` in one stays (git quotes every name holding one)
|
|
113
|
+
*/
|
|
114
|
+
function parseQuotedRenameOrCopyPaths(text, stripPercentage) {
|
|
115
|
+
let from;
|
|
116
|
+
let toStart;
|
|
117
|
+
if (text.startsWith("\"")) {
|
|
118
|
+
const quoted = readCQuotedString(text, 0);
|
|
119
|
+
if (quoted == null) return void 0;
|
|
120
|
+
if (quoted.end === text.length) return { path: quoted.value };
|
|
121
|
+
if (!text.startsWith(" => ", quoted.end)) return void 0;
|
|
122
|
+
from = quoted.value;
|
|
123
|
+
toStart = quoted.end + 4;
|
|
124
|
+
} else {
|
|
125
|
+
const index = text.indexOf(" => \"");
|
|
126
|
+
if (index === -1) return void 0;
|
|
127
|
+
from = text.substring(0, index).trim();
|
|
128
|
+
toStart = index + 4;
|
|
129
|
+
}
|
|
130
|
+
let to;
|
|
131
|
+
if (text[toStart] === "\"") {
|
|
132
|
+
const quoted = readCQuotedString(text, toStart);
|
|
133
|
+
if (quoted == null) return void 0;
|
|
134
|
+
to = quoted.value;
|
|
135
|
+
} else {
|
|
136
|
+
to = text.substring(toStart);
|
|
137
|
+
if (stripPercentage && to.endsWith("%)")) {
|
|
138
|
+
const percentPos = to.lastIndexOf(" (");
|
|
139
|
+
if (percentPos > -1) to = to.substring(0, percentPos);
|
|
140
|
+
}
|
|
141
|
+
to = to.trim();
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
path: to,
|
|
145
|
+
originalPath: from
|
|
146
|
+
};
|
|
147
|
+
}
|
|
18
148
|
function parseFileStatusAndMetadata(content, originalPath, path, hasHunks) {
|
|
19
149
|
const matches = content.match(diffStatusRegex);
|
|
20
150
|
let isBinary = false;
|
|
@@ -87,22 +217,19 @@ function parseGitDiff(data, includeRawContent = false) {
|
|
|
87
217
|
return parsed;
|
|
88
218
|
}
|
|
89
219
|
for (const file of files) {
|
|
90
|
-
const [line] = file.split("\n", 1);
|
|
91
|
-
const match = diffRegex.exec(`diff --git ${line}`);
|
|
92
|
-
if (match == null) continue;
|
|
93
|
-
const [, originalPath, path] = match;
|
|
94
220
|
const hunkStartIndex = file.indexOf("\n@@ -");
|
|
95
221
|
const hasHunks = hunkStartIndex !== -1;
|
|
222
|
+
const header = `diff --git ${hasHunks ? file.substring(0, hunkStartIndex) : file}`;
|
|
223
|
+
const paths = parseDiffFilePaths(header);
|
|
224
|
+
if (paths == null) continue;
|
|
225
|
+
const { path, originalPath } = paths;
|
|
96
226
|
const { status, metadata } = parseFileStatusAndMetadata(file, originalPath, path, hasHunks);
|
|
97
|
-
let header;
|
|
98
227
|
let rawContent;
|
|
99
228
|
let hunks;
|
|
100
229
|
if (!hasHunks) {
|
|
101
|
-
header = `diff --git ${file}`;
|
|
102
230
|
rawContent = includeRawContent ? file : void 0;
|
|
103
231
|
hunks = [];
|
|
104
232
|
} else {
|
|
105
|
-
header = `diff --git ${file.substring(0, hunkStartIndex)}`;
|
|
106
233
|
const content = file.substring(hunkStartIndex + 1);
|
|
107
234
|
rawContent = includeRawContent ? content : void 0;
|
|
108
235
|
hunks = parseGitFileDiff(content, includeRawContent)?.hunks ?? [];
|
|
@@ -135,12 +262,10 @@ async function filterDiffFiles(diff, getIncludedPaths) {
|
|
|
135
262
|
if (!diff) return diff;
|
|
136
263
|
const chunks = diff.split(diffGitLookaheadRegex).filter(Boolean);
|
|
137
264
|
if (!chunks.length) return diff;
|
|
138
|
-
const filesWithChunks = chunks.map((chunk) => {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
};
|
|
143
|
-
});
|
|
265
|
+
const filesWithChunks = chunks.map((chunk) => ({
|
|
266
|
+
path: parseDiffFilePaths(chunk)?.path ?? "",
|
|
267
|
+
chunk
|
|
268
|
+
}));
|
|
144
269
|
const allPaths = filesWithChunks.map((f) => f.path);
|
|
145
270
|
const includedPaths = await getIncludedPaths(allPaths);
|
|
146
271
|
if (includedPaths.length === allPaths.length) return diff;
|
|
@@ -356,18 +481,26 @@ function parseGitDiffNumStatFiles(data, repoPath) {
|
|
|
356
481
|
if (summary) for (let line of summary.split("\n")) {
|
|
357
482
|
line = line.trim();
|
|
358
483
|
if (!line) continue;
|
|
484
|
+
if (line.startsWith("copy ") && line.includes("\"")) {
|
|
485
|
+
const copied = parseQuotedRenameOrCopyPaths(line.substring(5), true);
|
|
486
|
+
if (copied != null) {
|
|
487
|
+
const file = files.get(normalizePath(copied.path));
|
|
488
|
+
if (file != null) file.status = "C";
|
|
489
|
+
continue;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
359
492
|
const match = diffSummaryRegex.exec(line);
|
|
360
493
|
if (match == null) continue;
|
|
361
494
|
const [, renameOrCopy, renameRoot, , renameNewLeaf, renameSuffix, createOrDelete, createOrDeletePath, oldMode, newMode, modeChangePath] = match;
|
|
362
495
|
if (createOrDelete != null) {
|
|
363
|
-
const file = files.get(normalizePath(createOrDeletePath));
|
|
496
|
+
const file = files.get(normalizePath(unquoteCString(createOrDeletePath)));
|
|
364
497
|
if (file != null) file.status = createOrDelete === "create" ? "A" : "D";
|
|
365
498
|
} else if (renameOrCopy === "copy") {
|
|
366
499
|
const file = files.get(normalizePath(renameRoot + renameNewLeaf + renameSuffix));
|
|
367
500
|
if (file != null) file.status = "C";
|
|
368
501
|
} else if (modeChangePath != null) {
|
|
369
502
|
if (oldMode.substring(0, 2) !== newMode.substring(0, 2)) {
|
|
370
|
-
const file = files.get(normalizePath(modeChangePath));
|
|
503
|
+
const file = files.get(normalizePath(unquoteCString(modeChangePath)));
|
|
371
504
|
if (file != null) file.status = "T";
|
|
372
505
|
}
|
|
373
506
|
}
|
|
@@ -380,6 +513,10 @@ function parseGitDiffNumStatFiles(data, repoPath) {
|
|
|
380
513
|
_usingCtx4.d();
|
|
381
514
|
}
|
|
382
515
|
}
|
|
516
|
+
/**
|
|
517
|
+
* Parses the output of `git apply --numstat --summary -z`. Unlike `git diff`, `git apply` writes the names of its
|
|
518
|
+
* summary lines as they are, never C-quoted, so they are read as written
|
|
519
|
+
*/
|
|
383
520
|
function parseGitApplyFiles(data, repoPath) {
|
|
384
521
|
try {
|
|
385
522
|
var _usingCtx5 = _usingCtx();
|
|
@@ -399,7 +536,12 @@ function parseGitApplyFiles(data, repoPath) {
|
|
|
399
536
|
for (let line of lines) {
|
|
400
537
|
line = line.trim();
|
|
401
538
|
if (!line) continue;
|
|
402
|
-
const
|
|
539
|
+
const tab1 = line.indexOf(" ");
|
|
540
|
+
const tab2 = tab1 === -1 ? -1 : line.indexOf(" ", tab1 + 1);
|
|
541
|
+
if (tab2 === -1) continue;
|
|
542
|
+
const insertions = line.substring(0, tab1);
|
|
543
|
+
const deletions = line.substring(tab1 + 1, tab2);
|
|
544
|
+
const path = line.substring(tab2 + 1);
|
|
403
545
|
files.set(normalizePath(path), new GitFileChange(repoPath, path, "M", getUri(path), void 0, void 0, void 0, {
|
|
404
546
|
changes: 0,
|
|
405
547
|
additions: parseInt(insertions, 10),
|
|
@@ -413,13 +555,17 @@ function parseGitApplyFiles(data, repoPath) {
|
|
|
413
555
|
if (match == null) continue;
|
|
414
556
|
const [, renameOrCopy, renameRoot, renameOriginalLeaf, renameNewLeaf, renameSuffix, createOrDelete, createOrDeletePath] = match;
|
|
415
557
|
if (renameOrCopy != null) {
|
|
416
|
-
const newPath =
|
|
417
|
-
const originalPath =
|
|
418
|
-
const
|
|
419
|
-
|
|
558
|
+
const newPath = renameRoot + renameNewLeaf + renameSuffix;
|
|
559
|
+
const originalPath = renameRoot + renameOriginalLeaf + renameSuffix;
|
|
560
|
+
const key = normalizePath(newPath);
|
|
561
|
+
const file = files.get(key);
|
|
562
|
+
if (file == null) continue;
|
|
563
|
+
files.set(key, new GitFileChange(repoPath, file.path, renameOrCopy === "copy" ? "C" : "R", getUri(file.path), originalPath, getUri(originalPath), void 0, file.stats));
|
|
420
564
|
} else if (createOrDelete != null) {
|
|
421
|
-
const
|
|
422
|
-
|
|
565
|
+
const key = normalizePath(createOrDeletePath);
|
|
566
|
+
const file = files.get(key);
|
|
567
|
+
if (file == null) continue;
|
|
568
|
+
files.set(key, new GitFileChange(repoPath, file.path, createOrDelete === "create" ? "A" : "D", getUri(file.path), void 0, void 0, void 0, file.stats));
|
|
423
569
|
}
|
|
424
570
|
}
|
|
425
571
|
sw?.stop({ suffix: ` parsed ${files.size} files` });
|
|
@@ -458,6 +604,6 @@ function parseGitDiffShortStat(data) {
|
|
|
458
604
|
}
|
|
459
605
|
}
|
|
460
606
|
//#endregion
|
|
461
|
-
export { countDiffInsertionsAndDeletions, countDiffLines, diffHunkRegex, diffRegex, filterDiffFiles, parseGitApplyFiles, parseGitDiff, parseGitDiffNumStatFiles, parseGitDiffShortStat, parseGitFileDiff };
|
|
607
|
+
export { countDiffInsertionsAndDeletions, countDiffLines, diffHunkRegex, diffRegex, filterDiffFiles, parseDiffFilePaths, parseGitApplyFiles, parseGitDiff, parseGitDiffNumStatFiles, parseGitDiffShortStat, parseGitFileDiff, parseQuotedRenameOrCopyPaths };
|
|
462
608
|
|
|
463
609
|
//# sourceMappingURL=diffParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diffParser.js","names":[],"sources":["../../../../git/src/parsers/diffParser.ts"],"sourcesContent":["import { normalizePath } from '@gitlens/utils/path.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport { fileUri, joinUriPath } from '@gitlens/utils/uri.js';\nimport type {\n\tGitDiffShortStat,\n\tParsedGitDiff,\n\tParsedGitDiffFile,\n\tParsedGitDiffFileMetadata,\n\tParsedGitDiffHunk,\n\tParsedGitDiffHunkLine,\n\tParsedGitDiffHunks,\n} from '../models/diff.js';\nimport type { GitFile } from '../models/file.js';\nimport { GitFileChange } from '../models/fileChange.js';\nimport type { GitFileStatus } from '../models/fileStatus.js';\nimport { GitFileIndexStatus } from '../models/fileStatus.js';\n\nexport const diffRegex = /^diff --git a\\/(.*) b\\/(.*)$/;\nexport const diffHunkRegex = /^@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@/;\n\nconst diffStatusRegex =\n\t/^(?:(new file mode)|(deleted file mode)|(rename (?:from|to))|(copy (?:from|to))|(old mode|new mode)|(@@ -)|(Binary files .+ differ))/m;\nconst shortStatDiffRegex = /(\\d+)\\s+files? changed(?:,\\s+(\\d+)\\s+insertions?\\(\\+\\))?(?:,\\s+(\\d+)\\s+deletions?\\(-\\))?/;\nconst oldModeRegex = /old mode (\\d+)/;\nconst newModeRegex = /new mode (\\d+)/;\nconst similarityRegex = /similarity index (\\d+)%/;\nconst diffGitSplitRegex = /^diff --git /m;\nconst diffGitLookaheadRegex = /^(?=diff --git )/m;\n// Matches summary lines from `git diff --summary` and `git apply --summary`:\n// ` rename [prefix/]{old => new}[/suffix] (XX%)` or ` rename old => new (XX%)`\n// ` copy [prefix/]{old => new}[/suffix] (XX%)` or ` copy old => new (XX%)`\n// ` create|delete mode XXXXXX path`\n// ` mode change XXXXXX => YYYYYY path`\n// The rename/copy alternative captures four parts so compact mid-form paths like\n// `a/b/{c => d}/e.txt` reconstruct correctly: prefix + oldLeaf + suffix and prefix + newLeaf + suffix.\n// `[^}]+` on the new-leaf forces greedy-with-backtracking so the leaf anchors at `}` in compact forms\n// and at ` (XX%)` otherwise — lazy `(.+?)` would push content into the suffix group.\nconst diffSummaryRegex =\n\t/(rename|copy) (.*?)\\{?([^{]+?)\\s+=>\\s+([^}]+)\\}?(.*?)(?: \\(\\d+%\\))|(create|delete) mode \\d+ (.+)|mode change (\\d+) => (\\d+) (.+)/;\n\ninterface ParsedGitDiffFileResult {\n\tstatus: GitFileStatus;\n\tmetadata: ParsedGitDiffFileMetadata;\n}\n\nfunction parseFileStatusAndMetadata(\n\tcontent: string,\n\toriginalPath: string,\n\tpath: string,\n\thasHunks: boolean,\n): ParsedGitDiffFileResult {\n\t// Use a single regex to find all relevant patterns at once\n\tconst matches = content.match(diffStatusRegex);\n\n\t// Initialize metadata\n\tlet isBinary = false;\n\tlet modeChanged = false;\n\tlet oldMode: string | undefined;\n\tlet newMode: string | undefined;\n\tlet similarity: number | undefined;\n\tlet status: GitFileStatus;\n\n\tif (matches) {\n\t\tconst [, newFile, deletedFile, rename, copy, modeChange, _hunks, binary] = matches;\n\n\t\t// Extract metadata from matches\n\t\tisBinary = Boolean(binary);\n\t\tmodeChanged = Boolean(modeChange);\n\n\t\t// Determine status based on found patterns (priority order)\n\t\tif (newFile) {\n\t\t\tstatus = GitFileIndexStatus.Added;\n\t\t} else if (deletedFile) {\n\t\t\tstatus = GitFileIndexStatus.Deleted;\n\t\t} else if (rename) {\n\t\t\tstatus = GitFileIndexStatus.Renamed;\n\t\t} else if (copy) {\n\t\t\tstatus = GitFileIndexStatus.Copied;\n\t\t} else if (binary) {\n\t\t\tstatus = path !== originalPath ? GitFileIndexStatus.Renamed : GitFileIndexStatus.Modified;\n\t\t} else if (modeChange && !hasHunks) {\n\t\t\tstatus = GitFileIndexStatus.TypeChanged;\n\t\t} else {\n\t\t\t// Default logic based on path comparison\n\t\t\tstatus = path !== originalPath ? GitFileIndexStatus.Renamed : GitFileIndexStatus.Modified;\n\t\t}\n\t} else {\n\t\t// Default logic based on path comparison\n\t\tstatus = path !== originalPath ? GitFileIndexStatus.Renamed : GitFileIndexStatus.Modified;\n\t}\n\n\t// Extract mode information if we detected a mode change\n\tif (modeChanged) {\n\t\tconst oldModeMatch = content.match(oldModeRegex);\n\t\tconst newModeMatch = content.match(newModeRegex);\n\t\tif (oldModeMatch) {\n\t\t\toldMode = oldModeMatch[1];\n\t\t}\n\t\tif (newModeMatch) {\n\t\t\tnewMode = newModeMatch[1];\n\t\t}\n\t}\n\n\t// Extract similarity for renames/copies\n\tif (status === GitFileIndexStatus.Renamed || status === GitFileIndexStatus.Copied) {\n\t\tconst similarityMatch = content.match(similarityRegex);\n\t\tif (similarityMatch) {\n\t\t\tsimilarity = parseInt(similarityMatch[1], 10);\n\t\t}\n\t}\n\n\tconst metadata: ParsedGitDiffFileMetadata = {\n\t\tbinary: isBinary,\n\t\tmodeChanged: modeChanged ? { oldMode: oldMode!, newMode: newMode! } : false,\n\t\trenamedOrCopied:\n\t\t\tstatus === GitFileIndexStatus.Renamed || status === GitFileIndexStatus.Copied\n\t\t\t\t? { similarity: similarity }\n\t\t\t\t: false,\n\t};\n\n\treturn { status: status, metadata: metadata };\n}\n\nfunction parseHunkHeaderPart(headerPart: string) {\n\tconst [startS, countS] = headerPart.split(',');\n\tconst start = Number(startS);\n\tconst count = Number(countS) || 1;\n\treturn { count: count, position: { start: start, end: start + count - 1 } };\n}\n\nexport function parseGitDiff(data: string, includeRawContent = false): ParsedGitDiff {\n\tusing sw = maybeStopWatch('Git.parseDiffFiles', { log: { onlyExit: true, level: 'debug' } });\n\n\tconst parsed: ParsedGitDiff = { files: [], rawContent: includeRawContent ? data : undefined };\n\n\t// Split the diff data into file chunks\n\tconst files = data.split(diffGitSplitRegex).filter(Boolean);\n\tif (!files.length) {\n\t\tsw?.stop({ suffix: ` parsed no files` });\n\t\treturn parsed;\n\t}\n\n\tfor (const file of files) {\n\t\tconst [line] = file.split('\\n', 1);\n\n\t\tconst match = diffRegex.exec(`diff --git ${line}`);\n\t\tif (match == null) continue;\n\n\t\tconst [, originalPath, path] = match;\n\n\t\t// Check for hunks and parse file status and metadata in a single pass\n\t\tconst hunkStartIndex = file.indexOf('\\n@@ -');\n\t\tconst hasHunks = hunkStartIndex !== -1;\n\t\tconst { status, metadata } = parseFileStatusAndMetadata(file, originalPath, path, hasHunks);\n\n\t\tlet header: string;\n\t\tlet rawContent: string | undefined;\n\t\tlet hunks: ParsedGitDiffHunk[];\n\n\t\tif (!hasHunks) {\n\t\t\t// No hunks - file without content changes (renames, mode changes, etc.)\n\t\t\theader = `diff --git ${file}`;\n\t\t\trawContent = includeRawContent ? file : undefined;\n\t\t\thunks = [];\n\t\t} else {\n\t\t\t// Has hunks - extract header and content efficiently\n\t\t\theader = `diff --git ${file.substring(0, hunkStartIndex)}`;\n\t\t\tconst content = file.substring(hunkStartIndex + 1);\n\t\t\trawContent = includeRawContent ? content : undefined;\n\t\t\thunks = parseGitFileDiff(content, includeRawContent)?.hunks ?? [];\n\t\t}\n\n\t\tparsed.files.push({\n\t\t\tpath: path,\n\t\t\toriginalPath: path === originalPath ? undefined : originalPath,\n\t\t\tstatus: status,\n\t\t\theader: header,\n\t\t\trawContent: rawContent,\n\t\t\thunks: hunks,\n\t\t\tmetadata: metadata,\n\t\t});\n\t}\n\n\tsw?.stop({ suffix: ` parsed ${parsed.files.length} files` });\n\n\treturn parsed;\n}\n\n/**\n * Filters a diff string, keeping only files whose paths are returned by the predicate.\n * @param diff The raw diff string\n * @param getIncludedPaths Predicate that receives all file paths and returns the paths to include\n * @returns Filtered diff with only included files, or the original diff if no files were excluded\n */\nexport async function filterDiffFiles(\n\tdiff: string,\n\tgetIncludedPaths: (paths: string[]) => string[] | Promise<string[]>,\n): Promise<string> {\n\tif (!diff) return diff;\n\n\t// Split into file chunks at \"diff --git\" boundaries (lookahead keeps the delimiter)\n\tconst chunks = diff.split(diffGitLookaheadRegex).filter(Boolean);\n\tif (!chunks.length) return diff;\n\n\t// Extract path from each chunk's header line\n\tconst filesWithChunks = chunks.map(chunk => {\n\t\tconst match = diffRegex.exec(chunk.split('\\n', 1)[0]);\n\t\treturn { path: match?.[2] ?? '', chunk: chunk };\n\t});\n\n\tconst allPaths = filesWithChunks.map(f => f.path);\n\tconst includedPaths = await getIncludedPaths(allPaths);\n\n\tif (includedPaths.length === allPaths.length) return diff;\n\n\treturn filesWithChunks\n\t\t.filter(f => includedPaths.includes(f.path))\n\t\t.map(f => f.chunk)\n\t\t.join('');\n}\n\n/**\n * Counts the added and removed lines of a parsed diff file, matching what `git diff --numstat`\n * reports for it. Binary files and files without content changes (pure renames, mode changes)\n * count as 0/0.\n */\nexport function countDiffInsertionsAndDeletions(file: ParsedGitDiffFile): { insertions: number; deletions: number } {\n\tlet insertions = 0;\n\tlet deletions = 0;\n\tfor (const hunk of file.hunks) {\n\t\t// Counted off the hunk's raw content rather than its header counts (which include unchanged\n\t\t// context) or `hunk.lines` (which merges a removed/added pair into one `changed` entry and\n\t\t// lets a following context line overwrite the tail of an asymmetric block). Scanned in place\n\t\t// rather than split into lines: splitting a multi-megabyte diff allocates a string per line\n\t\t// for a single pass that only ever looks at each line's first character.\n\t\tconst { content } = hunk;\n\t\tfor (let start = 0; start < content.length;) {\n\t\t\tconst marker = content[start];\n\t\t\tif (marker === '+') {\n\t\t\t\tinsertions++;\n\t\t\t} else if (marker === '-') {\n\t\t\t\tdeletions++;\n\t\t\t}\n\n\t\t\tconst end = content.indexOf('\\n', start);\n\t\t\tif (end === -1) break;\n\n\t\t\tstart = end + 1;\n\t\t}\n\t}\n\treturn { insertions: insertions, deletions: deletions };\n}\n\n/** Counts the approximate number of changed lines in a diff file — the size of both sides of its\n * hunks, unchanged context included. Suitable for relative sizing, not for reporting a line count\n * to the user; use {@link countDiffInsertionsAndDeletions} for that. */\nexport function countDiffLines(file: ParsedGitDiffFile): number {\n\tlet count = 0;\n\tfor (const hunk of file.hunks) {\n\t\tcount += hunk.current.count + hunk.previous.count;\n\t}\n\treturn count;\n}\n\nexport function parseGitFileDiff(data: string, includeRawContent = false): ParsedGitDiffHunks | undefined {\n\tusing sw = maybeStopWatch('Git.parseFileDiff', { log: { onlyExit: true, level: 'debug' } });\n\tif (!data) {\n\t\tsw?.stop({ suffix: ` no data` });\n\t\treturn undefined;\n\t}\n\n\tconst hunks: ParsedGitDiffHunk[] = [];\n\n\tconst lines = data.split('\\n');\n\n\t// Skip header — match standard hunk headers only (`@@ ... @@`), NOT combined-diff headers (`@@@ ... @@@`)\n\tlet i = -1;\n\twhile (++i < lines.length) {\n\t\tif (lines[i].startsWith('@@ ')) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// Parse hunks\n\tlet line;\n\twhile (i < lines.length) {\n\t\tline = lines[i];\n\t\tif (!line.startsWith('@@ ')) {\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst header = line;\n\t\tconst [previousHeaderPart, currentHeaderPart] = header.split('@@')[1].trim().split(' ');\n\n\t\tconst current = parseHunkHeaderPart(currentHeaderPart.slice(1));\n\t\tconst previous = parseHunkHeaderPart(previousHeaderPart.slice(1));\n\n\t\tconst hunkLines = new Map<number, ParsedGitDiffHunkLine>();\n\t\tlet fileLineNumber = current.position.start;\n\n\t\tline = lines[++i];\n\t\tconst contentStartLine = i;\n\n\t\t// Parse hunks lines\n\t\twhile (i < lines.length && !line.startsWith('@@ ')) {\n\t\t\tswitch (line[0]) {\n\t\t\t\t// deleted\n\t\t\t\tcase '-': {\n\t\t\t\t\tlet deletedLineNumber = fileLineNumber;\n\t\t\t\t\twhile (line?.startsWith('-')) {\n\t\t\t\t\t\thunkLines.set(deletedLineNumber++, {\n\t\t\t\t\t\t\tcurrent: undefined,\n\t\t\t\t\t\t\tprevious: line.slice(1),\n\t\t\t\t\t\t\tstate: 'removed',\n\t\t\t\t\t\t});\n\t\t\t\t\t\tline = lines[++i];\n\t\t\t\t\t}\n\n\t\t\t\t\tif (line?.startsWith('+')) {\n\t\t\t\t\t\tlet addedLineNumber = fileLineNumber;\n\t\t\t\t\t\twhile (line?.startsWith('+')) {\n\t\t\t\t\t\t\tconst hunkLine = hunkLines.get(addedLineNumber);\n\t\t\t\t\t\t\tif (hunkLine != null) {\n\t\t\t\t\t\t\t\thunkLine.current = line.slice(1);\n\t\t\t\t\t\t\t\thunkLine.state = 'changed';\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\thunkLines.set(addedLineNumber, {\n\t\t\t\t\t\t\t\t\tcurrent: line.slice(1),\n\t\t\t\t\t\t\t\t\tprevious: undefined,\n\t\t\t\t\t\t\t\t\tstate: 'added',\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taddedLineNumber++;\n\t\t\t\t\t\t\tline = lines[++i];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfileLineNumber = addedLineNumber;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfileLineNumber = deletedLineNumber;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// added\n\t\t\t\tcase '+':\n\t\t\t\t\thunkLines.set(fileLineNumber++, {\n\t\t\t\t\t\tcurrent: line.slice(1),\n\t\t\t\t\t\tprevious: undefined,\n\t\t\t\t\t\tstate: 'added',\n\t\t\t\t\t});\n\n\t\t\t\t\tline = lines[++i];\n\t\t\t\t\tbreak;\n\n\t\t\t\t// unchanged (context)\n\t\t\t\tcase ' ':\n\t\t\t\t\thunkLines.set(fileLineNumber++, {\n\t\t\t\t\t\tcurrent: line.slice(1),\n\t\t\t\t\t\tprevious: line.slice(1),\n\t\t\t\t\t\tstate: 'unchanged',\n\t\t\t\t\t});\n\n\t\t\t\t\tline = lines[++i];\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tline = lines[++i];\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst hunk: ParsedGitDiffHunk = {\n\t\t\theader: header,\n\t\t\tcontent: lines.slice(contentStartLine, i).join('\\n'),\n\t\t\tcurrent: current,\n\t\t\tprevious: previous,\n\t\t\tlines: hunkLines,\n\t\t};\n\n\t\thunks.push(hunk);\n\t}\n\n\tsw?.stop({ suffix: ` parsed ${hunks.length} hunks` });\n\n\treturn {\n\t\trawContent: includeRawContent ? data : undefined,\n\t\thunks: hunks,\n\t};\n}\n\n/**\n * Parses the output of `git diff --numstat --summary -z`.\n *\n * Numstat records are null-separated:\n * `additions\\tdeletions\\tpath\\0`\n * Renames and copies have an empty path followed by two additional null-separated fields:\n * `additions\\tdeletions\\t\\0oldPath\\0newPath\\0`\n * The summary section (if any) follows the final null byte as newline-separated lines:\n * ` create mode 100644 path`\n * ` delete mode 100644 path`\n * ` rename old => new (100%)`\n * ` copy old => new (85%)`\n * ` mode change 100644 => 120000 path`\n *\n * Numstat alone cannot distinguish: rename vs. copy, or modified vs. type-changed.\n * The summary pass refines those statuses: copies are promoted to `C`, and mode changes\n * that cross the file-type boundary (regular file ↔ symlink ↔ gitlink, i.e. the high two\n * octal digits differ) are promoted to `T`.\n */\nexport function parseGitDiffNumStatFiles(data: string, repoPath: string): GitFile[] | undefined {\n\tusing sw = maybeStopWatch('Git.parseDiffNumStatFiles', { log: { onlyExit: true, level: 'debug' } });\n\tif (!data) {\n\t\tsw?.stop({ suffix: ` no data` });\n\t\treturn undefined;\n\t}\n\n\tconst files = new Map<string, GitFile>();\n\n\t// Numstat records are \\0-terminated; the summary (if any) lives after the final \\0 as \\n-separated lines.\n\t// Slice explicitly rather than popping the last split element, so numstat and summary never get conflated.\n\tconst lastNullIndex = data.lastIndexOf('\\0');\n\tconst numstatData = lastNullIndex === -1 ? data : data.substring(0, lastNullIndex);\n\tconst summary = lastNullIndex === -1 ? '' : data.substring(lastNullIndex + 1);\n\n\tconst fields = numstatData.split('\\0');\n\n\tlet i = 0;\n\twhile (i < fields.length) {\n\t\tconst field = fields[i];\n\t\tif (!field) {\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst tabIndex1 = field.indexOf('\\t');\n\t\tif (tabIndex1 === -1) {\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst tabIndex2 = field.indexOf('\\t', tabIndex1 + 1);\n\t\tif (tabIndex2 === -1) {\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst insertionsStr = field.substring(0, tabIndex1);\n\t\tconst deletionsStr = field.substring(tabIndex1 + 1, tabIndex2);\n\t\tlet path = field.substring(tabIndex2 + 1);\n\n\t\tlet originalPath: string | undefined;\n\t\tif (path === '') {\n\t\t\t// Rename or copy: next two fields are oldPath and newPath (summary pass distinguishes R vs C)\n\t\t\tif (i + 2 >= fields.length) break;\n\n\t\t\toriginalPath = fields[++i];\n\t\t\tpath = fields[++i];\n\t\t}\n\n\t\t// Binary files report `-` instead of a line count; preserve the explicit check for clarity\n\t\tconst additions = insertionsStr === '-' ? 0 : parseInt(insertionsStr, 10) || 0;\n\t\tconst deletions = deletionsStr === '-' ? 0 : parseInt(deletionsStr, 10) || 0;\n\n\t\tconst normalizedPath = normalizePath(path);\n\t\tfiles.set(normalizedPath, {\n\t\t\trepoPath: repoPath,\n\t\t\tpath: path,\n\t\t\toriginalPath: originalPath,\n\t\t\tstatus: originalPath ? 'R' : 'M',\n\t\t\tstats: { additions: additions, deletions: deletions, changes: additions + deletions },\n\t\t});\n\n\t\ti++;\n\t}\n\n\t// Refine statuses from the summary section:\n\t// create → A, delete → D, copy → C (renames already default to R from numstat),\n\t// mode change across file-type boundaries → T\n\tif (summary) {\n\t\tfor (let line of summary.split('\\n')) {\n\t\t\tline = line.trim();\n\t\t\tif (!line) continue;\n\n\t\t\tconst match = diffSummaryRegex.exec(line);\n\t\t\tif (match == null) continue;\n\n\t\t\t// Positional destructure matches diffSummaryRegex's 9 capture groups.\n\t\t\t// Group 3 (original-leaf) is unused here — numstat already provides authoritative rename paths.\n\t\t\tconst [\n\t\t\t\t,\n\t\t\t\trenameOrCopy,\n\t\t\t\trenameRoot,\n\t\t\t\t,\n\t\t\t\trenameNewLeaf,\n\t\t\t\trenameSuffix,\n\t\t\t\tcreateOrDelete,\n\t\t\t\tcreateOrDeletePath,\n\t\t\t\toldMode,\n\t\t\t\tnewMode,\n\t\t\t\tmodeChangePath,\n\t\t\t] = match;\n\n\t\t\tif (createOrDelete != null) {\n\t\t\t\tconst file = files.get(normalizePath(createOrDeletePath));\n\t\t\t\tif (file != null) {\n\t\t\t\t\tfile.status = createOrDelete === 'create' ? 'A' : 'D';\n\t\t\t\t}\n\t\t\t} else if (renameOrCopy === 'copy') {\n\t\t\t\t// Numstat defaulted to R; promote to C. Reconstruct the full new-side path by\n\t\t\t\t// concatenating prefix + new-leaf + suffix, covering all compact and non-compact forms.\n\t\t\t\tconst file = files.get(normalizePath(renameRoot + renameNewLeaf + renameSuffix));\n\t\t\t\tif (file != null) {\n\t\t\t\t\tfile.status = 'C';\n\t\t\t\t}\n\t\t\t} else if (modeChangePath != null) {\n\t\t\t\t// File-type boundary: 100xxx = regular file, 120000 = symlink, 160000 = gitlink.\n\t\t\t\t// Promote to T only when the high two octal digits differ (ignore permission-only changes).\n\t\t\t\tif (oldMode.substring(0, 2) !== newMode.substring(0, 2)) {\n\t\t\t\t\tconst file = files.get(normalizePath(modeChangePath));\n\t\t\t\t\tif (file != null) {\n\t\t\t\t\t\tfile.status = 'T';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Renames are already handled by the numstat section with -z\n\t\t}\n\t}\n\n\tsw?.stop({ suffix: ` parsed ${files.size} files` });\n\n\treturn files.size > 0 ? [...files.values()] : undefined;\n}\n\nexport function parseGitApplyFiles(data: string, repoPath: string): GitFileChange[] {\n\tusing sw = maybeStopWatch('Git.parseApplyFiles', { log: { onlyExit: true, level: 'debug' } });\n\tif (!data) {\n\t\tsw?.stop({ suffix: ` no data` });\n\t\treturn [];\n\t}\n\n\tconst repoUri = fileUri(normalizePath(repoPath));\n\tconst getUri = (p: string) => joinUriPath(repoUri, normalizePath(p));\n\tconst files = new Map<string, GitFileChange>();\n\n\tconst lines = data.split('\\0');\n\t// remove the summary (last) line to parse later\n\tconst summary = lines.pop();\n\n\tfor (let line of lines) {\n\t\tline = line.trim();\n\t\tif (!line) continue;\n\n\t\tconst [insertions, deletions, path] = line.split('\\t');\n\t\tfiles.set(\n\t\t\tnormalizePath(path),\n\t\t\tnew GitFileChange(repoPath, path, 'M', getUri(path), undefined, undefined, undefined, {\n\t\t\t\tchanges: 0,\n\t\t\t\tadditions: parseInt(insertions, 10),\n\t\t\t\tdeletions: parseInt(deletions, 10),\n\t\t\t}),\n\t\t);\n\t}\n\n\tfor (let line of summary!.split('\\n')) {\n\t\tline = line.trim();\n\t\tif (!line) continue;\n\n\t\tconst match = diffSummaryRegex.exec(line);\n\t\tif (match == null) continue;\n\n\t\t// Positional destructure matches diffSummaryRegex's 9 capture groups.\n\t\t// mode-change groups (8–10) are unused here — git apply's summary does not emit them in practice.\n\t\tconst [\n\t\t\t,\n\t\t\trenameOrCopy,\n\t\t\trenameRoot,\n\t\t\trenameOriginalLeaf,\n\t\t\trenameNewLeaf,\n\t\t\trenameSuffix,\n\t\t\tcreateOrDelete,\n\t\t\tcreateOrDeletePath,\n\t\t] = match;\n\n\t\tif (renameOrCopy != null) {\n\t\t\t// Reconstruct both sides: prefix + leaf + suffix, handling all compact and non-compact forms.\n\t\t\tconst newPath = normalizePath(renameRoot + renameNewLeaf + renameSuffix);\n\t\t\tconst originalPath = normalizePath(renameRoot + renameOriginalLeaf + renameSuffix);\n\n\t\t\tconst file = files.get(newPath)!;\n\t\t\tfiles.set(\n\t\t\t\tnewPath,\n\t\t\t\tnew GitFileChange(\n\t\t\t\t\trepoPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t\trenameOrCopy === 'copy' ? 'C' : 'R',\n\t\t\t\t\tgetUri(newPath),\n\t\t\t\t\toriginalPath,\n\t\t\t\t\tgetUri(originalPath),\n\t\t\t\t\tundefined,\n\t\t\t\t\tfile.stats,\n\t\t\t\t),\n\t\t\t);\n\t\t} else if (createOrDelete != null) {\n\t\t\tconst file = files.get(normalizePath(createOrDeletePath))!;\n\t\t\tfiles.set(\n\t\t\t\tcreateOrDeletePath,\n\t\t\t\tnew GitFileChange(\n\t\t\t\t\trepoPath,\n\t\t\t\t\tfile.path,\n\t\t\t\t\tcreateOrDelete === 'create' ? 'A' : 'D',\n\t\t\t\t\tgetUri(file.path),\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t\tfile.stats,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tsw?.stop({ suffix: ` parsed ${files.size} files` });\n\n\treturn [...files.values()];\n}\n\nexport function parseGitDiffShortStat(data: string): GitDiffShortStat | undefined {\n\tusing sw = maybeStopWatch('Git.parseDiffShortStat', { log: { onlyExit: true, level: 'debug' } });\n\tif (!data) {\n\t\tsw?.stop({ suffix: ` no data` });\n\t\treturn undefined;\n\t}\n\n\tconst match = shortStatDiffRegex.exec(data);\n\tif (match == null) return undefined;\n\n\tconst [, files, insertions, deletions] = match;\n\n\tconst diffShortStat: GitDiffShortStat = {\n\t\tfiles: files == null ? 0 : parseInt(files, 10),\n\t\tadditions: insertions == null ? 0 : parseInt(insertions, 10),\n\t\tdeletions: deletions == null ? 0 : parseInt(deletions, 10),\n\t};\n\n\tsw?.stop({\n\t\tsuffix: ` parsed ${diffShortStat.files} files, +${diffShortStat.additions} -${diffShortStat.deletions}`,\n\t});\n\n\treturn diffShortStat;\n}\n"],"mappings":";;;;;;;AAiBA,MAAa,YAAY;AACzB,MAAa,gBAAgB;AAE7B,MAAM,kBACL;AACD,MAAM,qBAAqB;AAC3B,MAAM,eAAe;AACrB,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,oBAAoB;AAC1B,MAAM,wBAAwB;AAU9B,MAAM,mBACL;AAOD,SAAS,2BACR,SACA,cACA,MACA,UAC0B;CAE1B,MAAM,UAAU,QAAQ,MAAM,eAAe;CAG7C,IAAI,WAAW;CACf,IAAI,cAAc;CAClB,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CAEJ,IAAI,SAAS;EACZ,MAAM,GAAG,SAAS,aAAa,QAAQ,MAAM,YAAY,QAAQ,UAAU;EAG3E,WAAW,QAAQ,MAAM;EACzB,cAAc,QAAQ,UAAU;EAGhC,IAAI,SACH,SAAS,mBAAmB;OACtB,IAAI,aACV,SAAS,mBAAmB;OACtB,IAAI,Q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AAW,cAAc,MAAM,WAAW,cAAc,UAAU,IAAI,cAAc,YAC7F,CAAC;EAED,OAAO;;;;;;AACR"}
|
|
1
|
+
{"version":3,"file":"diffParser.js","names":[],"sources":["../../../../git/src/parsers/diffParser.ts"],"sourcesContent":["import { normalizePath } from '@gitlens/utils/path.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport { readCQuotedString, unquoteCString } from '@gitlens/utils/string.js';\nimport { fileUri, joinUriPath } from '@gitlens/utils/uri.js';\nimport type {\n\tGitDiffShortStat,\n\tParsedGitDiff,\n\tParsedGitDiffFile,\n\tParsedGitDiffFileMetadata,\n\tParsedGitDiffHunk,\n\tParsedGitDiffHunkLine,\n\tParsedGitDiffHunks,\n} from '../models/diff.js';\nimport type { GitFile } from '../models/file.js';\nimport { GitFileChange } from '../models/fileChange.js';\nimport type { GitFileStatus } from '../models/fileStatus.js';\nimport { GitFileIndexStatus } from '../models/fileStatus.js';\n\nexport const diffRegex = /^diff --git a\\/(.*) b\\/(.*)$/;\nexport const diffHunkRegex = /^@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@/;\n\nconst diffStatusRegex =\n\t/^(?:(new file mode)|(deleted file mode)|(rename (?:from|to))|(copy (?:from|to))|(old mode|new mode)|(@@ -)|(Binary files .+ differ))/m;\nconst shortStatDiffRegex = /(\\d+)\\s+files? changed(?:,\\s+(\\d+)\\s+insertions?\\(\\+\\))?(?:,\\s+(\\d+)\\s+deletions?\\(-\\))?/;\nconst oldModeRegex = /old mode (\\d+)/;\nconst newModeRegex = /new mode (\\d+)/;\nconst similarityRegex = /similarity index (\\d+)%/;\nconst diffGitSplitRegex = /^diff --git /m;\nconst diffGitLookaheadRegex = /^(?=diff --git )/m;\n// Matches summary lines from `git diff --summary` and `git apply --summary`:\n// ` rename [prefix/]{old => new}[/suffix] (XX%)` or ` rename old => new (XX%)`\n// ` copy [prefix/]{old => new}[/suffix] (XX%)` or ` copy old => new (XX%)`\n// ` create|delete mode XXXXXX path`\n// ` mode change XXXXXX => YYYYYY path`\n// The rename/copy alternative captures four parts so compact mid-form paths like\n// `a/b/{c => d}/e.txt` reconstruct correctly: prefix + oldLeaf + suffix and prefix + newLeaf + suffix.\n// `[^}]+` on the new-leaf forces greedy-with-backtracking so the leaf anchors at `}` in compact forms\n// and at ` (XX%)` otherwise — lazy `(.+?)` would push content into the suffix group.\nconst diffSummaryRegex =\n\t/(rename|copy) (.*?)\\{?([^{]+?)\\s+=>\\s+([^}]+)\\}?(.*?)(?: \\(\\d+%\\))|(create|delete) mode \\d+ (.+)|mode change (\\d+) => (\\d+) (.+)/;\n\n/**\n * Reads the path a header line names after its fixed lead-in, without the `a/` or `b/` prefix expected of it. A quoted\n * name carries the prefix inside its quotes. Git ends an unquoted `---` or `+++` name that holds a space with a tab,\n * which a name can't hold itself\n */\nfunction readHeaderPath(rest: string, prefix: string): string | undefined {\n\tif (rest.startsWith('\"')) {\n\t\tconst quoted = readCQuotedString(rest, 0);\n\t\tif (quoted == null || !quoted.value.startsWith(prefix)) return undefined;\n\n\t\treturn quoted.value.substring(prefix.length);\n\t}\n\n\tif (!rest.startsWith(prefix)) return undefined;\n\n\treturn rest.endsWith('\\t') ? rest.substring(prefix.length, rest.length - 1) : rest.substring(prefix.length);\n}\n\n/**\n * The new-side path of a `diff --git` line (without its lead-in) when no other line names it, so both halves are the\n * same path: split where they match, since a path can hold ` b/` itself\n */\nfunction readGitLinePath(rest: string): string | undefined {\n\tif (rest.startsWith('\"')) {\n\t\tconst quoted = readCQuotedString(rest, 0);\n\t\tif (quoted == null || rest[quoted.end] !== ' ') return undefined;\n\n\t\treturn readHeaderPath(rest.substring(quoted.end + 1), 'b/');\n\t}\n\n\t// `a/<path> b/<path>`\n\tconst length = rest.length - 5;\n\tif (length < 0 || length % 2 !== 0 || !rest.startsWith('a/')) return undefined;\n\n\tconst half = length / 2;\n\tconst path = rest.substring(2, 2 + half);\n\treturn rest.startsWith(' b/', 2 + half) && rest.endsWith(path) ? path : undefined;\n}\n\n/**\n * Reads the paths of a file's diff section, which starts at its `diff --git` line, from the lines git writes before the\n * first hunk. The `diff --git` line alone can't be split reliably (a path can hold ` b/`, and git quotes a path with a\n * `\"`, `\\`, tab or newline), so it is the last resort: the paths come from `+++`, `---` and the `rename`/`copy` lines.\n * A path comes out as `git diff --numstat -z` names it.\n * @returns `originalPath` is `path` for a file that wasn't renamed or copied\n */\nexport function parseDiffFilePaths(section: string): { path: string; originalPath: string } | undefined {\n\tlet gitLine: string | undefined;\n\tlet newName: string | undefined;\n\tlet oldName: string | undefined;\n\tlet renamedTo: string | undefined;\n\tlet renamedFrom: string | undefined;\n\n\tfor (let start = 0; start < section.length;) {\n\t\tlet end = section.indexOf('\\n', start);\n\t\tif (end === -1) {\n\t\t\tend = section.length;\n\t\t}\n\t\tconst lineStart = start;\n\t\tstart = end + 1;\n\n\t\tswitch (section.charCodeAt(lineStart)) {\n\t\t\tcase 0x2b /* + */:\n\t\t\t\tif (section.startsWith('+++ ', lineStart)) {\n\t\t\t\t\tconst rest = section.substring(lineStart + 4, end);\n\t\t\t\t\tif (rest !== '/dev/null') {\n\t\t\t\t\t\tnewName = readHeaderPath(rest, 'b/');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 0x2d /* - */:\n\t\t\t\tif (section.startsWith('--- ', lineStart)) {\n\t\t\t\t\tconst rest = section.substring(lineStart + 4, end);\n\t\t\t\t\tif (rest !== '/dev/null') {\n\t\t\t\t\t\toldName = readHeaderPath(rest, 'a/');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 0x72 /* r */:\n\t\t\t\tif (section.startsWith('rename to ', lineStart)) {\n\t\t\t\t\trenamedTo = readHeaderPath(section.substring(lineStart + 10, end), '');\n\t\t\t\t} else if (section.startsWith('rename from ', lineStart)) {\n\t\t\t\t\trenamedFrom = readHeaderPath(section.substring(lineStart + 12, end), '');\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 0x63 /* c */:\n\t\t\t\tif (section.startsWith('copy to ', lineStart)) {\n\t\t\t\t\trenamedTo = readHeaderPath(section.substring(lineStart + 8, end), '');\n\t\t\t\t} else if (section.startsWith('copy from ', lineStart)) {\n\t\t\t\t\trenamedFrom = readHeaderPath(section.substring(lineStart + 10, end), '');\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 0x64 /* d */:\n\t\t\t\tif (section.startsWith('diff --git ', lineStart)) {\n\t\t\t\t\tgitLine ??= section.substring(lineStart + 11, end);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 0x40 /* @ */:\n\t\t\t\tif (section.startsWith('@@ ', lineStart)) {\n\t\t\t\t\tstart = section.length;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 0x47 /* G */:\n\t\t\t\tif (end - lineStart === 16 && section.startsWith('GIT binary patch', lineStart)) {\n\t\t\t\t\tstart = section.length;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tconst path = newName ?? renamedTo ?? oldName ?? (gitLine != null ? readGitLinePath(gitLine) : undefined);\n\tif (path != null) return { path: path, originalPath: renamedFrom ?? oldName ?? path };\n\n\t// Nothing but a `diff --git` line to go on, which a rename may have, so split it as it always was\n\tconst match = gitLine != null ? diffRegex.exec(`diff --git ${gitLine}`) : null;\n\treturn match != null ? { path: match[2], originalPath: match[1] } : undefined;\n}\n\n/**\n * Reads a `--numstat` or `--summary` rename or copy in which git quoted a name. Git then drops the compact\n * `prefix/{old => new}/suffix` form for `old => new`, each side quoted on its own only when it needs it; a name git\n * didn't quote holds no `\"`. A lone quoted name, as in a numstat line that isn't a rename, comes back as `path` alone.\n * Names come back as git names them, so a `\\` in one stays (git quotes every name holding one)\n */\nexport function parseQuotedRenameOrCopyPaths(\n\ttext: string,\n\tstripPercentage: boolean,\n): { path: string; originalPath?: string } | undefined {\n\tlet from: string;\n\tlet toStart: number;\n\tif (text.startsWith('\"')) {\n\t\tconst quoted = readCQuotedString(text, 0);\n\t\tif (quoted == null) return undefined;\n\n\t\t// Just one quoted name, as in a numstat line that isn't a rename\n\t\tif (quoted.end === text.length) return { path: quoted.value };\n\t\tif (!text.startsWith(' => ', quoted.end)) return undefined;\n\n\t\tfrom = quoted.value;\n\t\ttoStart = quoted.end + 4;\n\t} else {\n\t\tconst index = text.indexOf(' => \"');\n\t\tif (index === -1) return undefined;\n\n\t\tfrom = text.substring(0, index).trim();\n\t\ttoStart = index + 4;\n\t}\n\n\tlet to: string;\n\tif (text[toStart] === '\"') {\n\t\tconst quoted = readCQuotedString(text, toStart);\n\t\tif (quoted == null) return undefined;\n\n\t\tto = quoted.value;\n\t} else {\n\t\tto = text.substring(toStart);\n\t\tif (stripPercentage && to.endsWith('%)')) {\n\t\t\tconst percentPos = to.lastIndexOf(' (');\n\t\t\tif (percentPos > -1) {\n\t\t\t\tto = to.substring(0, percentPos);\n\t\t\t}\n\t\t}\n\t\tto = to.trim();\n\t}\n\n\treturn { path: to, originalPath: from };\n}\n\ninterface ParsedGitDiffFileResult {\n\tstatus: GitFileStatus;\n\tmetadata: ParsedGitDiffFileMetadata;\n}\n\nfunction parseFileStatusAndMetadata(\n\tcontent: string,\n\toriginalPath: string,\n\tpath: string,\n\thasHunks: boolean,\n): ParsedGitDiffFileResult {\n\t// Use a single regex to find all relevant patterns at once\n\tconst matches = content.match(diffStatusRegex);\n\n\t// Initialize metadata\n\tlet isBinary = false;\n\tlet modeChanged = false;\n\tlet oldMode: string | undefined;\n\tlet newMode: string | undefined;\n\tlet similarity: number | undefined;\n\tlet status: GitFileStatus;\n\n\tif (matches) {\n\t\tconst [, newFile, deletedFile, rename, copy, modeChange, _hunks, binary] = matches;\n\n\t\t// Extract metadata from matches\n\t\tisBinary = Boolean(binary);\n\t\tmodeChanged = Boolean(modeChange);\n\n\t\t// Determine status based on found patterns (priority order)\n\t\tif (newFile) {\n\t\t\tstatus = GitFileIndexStatus.Added;\n\t\t} else if (deletedFile) {\n\t\t\tstatus = GitFileIndexStatus.Deleted;\n\t\t} else if (rename) {\n\t\t\tstatus = GitFileIndexStatus.Renamed;\n\t\t} else if (copy) {\n\t\t\tstatus = GitFileIndexStatus.Copied;\n\t\t} else if (binary) {\n\t\t\tstatus = path !== originalPath ? GitFileIndexStatus.Renamed : GitFileIndexStatus.Modified;\n\t\t} else if (modeChange && !hasHunks) {\n\t\t\tstatus = GitFileIndexStatus.TypeChanged;\n\t\t} else {\n\t\t\t// Default logic based on path comparison\n\t\t\tstatus = path !== originalPath ? GitFileIndexStatus.Renamed : GitFileIndexStatus.Modified;\n\t\t}\n\t} else {\n\t\t// Default logic based on path comparison\n\t\tstatus = path !== originalPath ? GitFileIndexStatus.Renamed : GitFileIndexStatus.Modified;\n\t}\n\n\t// Extract mode information if we detected a mode change\n\tif (modeChanged) {\n\t\tconst oldModeMatch = content.match(oldModeRegex);\n\t\tconst newModeMatch = content.match(newModeRegex);\n\t\tif (oldModeMatch) {\n\t\t\toldMode = oldModeMatch[1];\n\t\t}\n\t\tif (newModeMatch) {\n\t\t\tnewMode = newModeMatch[1];\n\t\t}\n\t}\n\n\t// Extract similarity for renames/copies\n\tif (status === GitFileIndexStatus.Renamed || status === GitFileIndexStatus.Copied) {\n\t\tconst similarityMatch = content.match(similarityRegex);\n\t\tif (similarityMatch) {\n\t\t\tsimilarity = parseInt(similarityMatch[1], 10);\n\t\t}\n\t}\n\n\tconst metadata: ParsedGitDiffFileMetadata = {\n\t\tbinary: isBinary,\n\t\tmodeChanged: modeChanged ? { oldMode: oldMode!, newMode: newMode! } : false,\n\t\trenamedOrCopied:\n\t\t\tstatus === GitFileIndexStatus.Renamed || status === GitFileIndexStatus.Copied\n\t\t\t\t? { similarity: similarity }\n\t\t\t\t: false,\n\t};\n\n\treturn { status: status, metadata: metadata };\n}\n\nfunction parseHunkHeaderPart(headerPart: string) {\n\tconst [startS, countS] = headerPart.split(',');\n\tconst start = Number(startS);\n\tconst count = Number(countS) || 1;\n\treturn { count: count, position: { start: start, end: start + count - 1 } };\n}\n\nexport function parseGitDiff(data: string, includeRawContent = false): ParsedGitDiff {\n\tusing sw = maybeStopWatch('Git.parseDiffFiles', { log: { onlyExit: true, level: 'debug' } });\n\n\tconst parsed: ParsedGitDiff = { files: [], rawContent: includeRawContent ? data : undefined };\n\n\t// Split the diff data into file chunks\n\tconst files = data.split(diffGitSplitRegex).filter(Boolean);\n\tif (!files.length) {\n\t\tsw?.stop({ suffix: ` parsed no files` });\n\t\treturn parsed;\n\t}\n\n\tfor (const file of files) {\n\t\t// Check for hunks and parse file status and metadata in a single pass\n\t\tconst hunkStartIndex = file.indexOf('\\n@@ -');\n\t\tconst hasHunks = hunkStartIndex !== -1;\n\n\t\tconst header = `diff --git ${hasHunks ? file.substring(0, hunkStartIndex) : file}`;\n\n\t\tconst paths = parseDiffFilePaths(header);\n\t\tif (paths == null) continue;\n\n\t\tconst { path, originalPath } = paths;\n\t\tconst { status, metadata } = parseFileStatusAndMetadata(file, originalPath, path, hasHunks);\n\n\t\tlet rawContent: string | undefined;\n\t\tlet hunks: ParsedGitDiffHunk[];\n\n\t\tif (!hasHunks) {\n\t\t\t// No hunks - file without content changes (renames, mode changes, etc.)\n\t\t\trawContent = includeRawContent ? file : undefined;\n\t\t\thunks = [];\n\t\t} else {\n\t\t\t// Has hunks - extract content efficiently\n\t\t\tconst content = file.substring(hunkStartIndex + 1);\n\t\t\trawContent = includeRawContent ? content : undefined;\n\t\t\thunks = parseGitFileDiff(content, includeRawContent)?.hunks ?? [];\n\t\t}\n\n\t\tparsed.files.push({\n\t\t\tpath: path,\n\t\t\toriginalPath: path === originalPath ? undefined : originalPath,\n\t\t\tstatus: status,\n\t\t\theader: header,\n\t\t\trawContent: rawContent,\n\t\t\thunks: hunks,\n\t\t\tmetadata: metadata,\n\t\t});\n\t}\n\n\tsw?.stop({ suffix: ` parsed ${parsed.files.length} files` });\n\n\treturn parsed;\n}\n\n/**\n * Filters a diff string, keeping only files whose paths are returned by the predicate.\n * @param diff The raw diff string\n * @param getIncludedPaths Predicate that receives all file paths and returns the paths to include\n * @returns Filtered diff with only included files, or the original diff if no files were excluded\n */\nexport async function filterDiffFiles(\n\tdiff: string,\n\tgetIncludedPaths: (paths: string[]) => string[] | Promise<string[]>,\n): Promise<string> {\n\tif (!diff) return diff;\n\n\t// Split into file chunks at \"diff --git\" boundaries (lookahead keeps the delimiter)\n\tconst chunks = diff.split(diffGitLookaheadRegex).filter(Boolean);\n\tif (!chunks.length) return diff;\n\n\t// Extract path from each chunk's header line\n\tconst filesWithChunks = chunks.map(chunk => ({ path: parseDiffFilePaths(chunk)?.path ?? '', chunk: chunk }));\n\n\tconst allPaths = filesWithChunks.map(f => f.path);\n\tconst includedPaths = await getIncludedPaths(allPaths);\n\n\tif (includedPaths.length === allPaths.length) return diff;\n\n\treturn filesWithChunks\n\t\t.filter(f => includedPaths.includes(f.path))\n\t\t.map(f => f.chunk)\n\t\t.join('');\n}\n\n/**\n * Counts the added and removed lines of a parsed diff file, matching what `git diff --numstat`\n * reports for it. Binary files and files without content changes (pure renames, mode changes)\n * count as 0/0.\n */\nexport function countDiffInsertionsAndDeletions(file: ParsedGitDiffFile): { insertions: number; deletions: number } {\n\tlet insertions = 0;\n\tlet deletions = 0;\n\tfor (const hunk of file.hunks) {\n\t\t// Counted off the hunk's raw content rather than its header counts (which include unchanged\n\t\t// context) or `hunk.lines` (which merges a removed/added pair into one `changed` entry and\n\t\t// lets a following context line overwrite the tail of an asymmetric block). Scanned in place\n\t\t// rather than split into lines: splitting a multi-megabyte diff allocates a string per line\n\t\t// for a single pass that only ever looks at each line's first character.\n\t\tconst { content } = hunk;\n\t\tfor (let start = 0; start < content.length;) {\n\t\t\tconst marker = content[start];\n\t\t\tif (marker === '+') {\n\t\t\t\tinsertions++;\n\t\t\t} else if (marker === '-') {\n\t\t\t\tdeletions++;\n\t\t\t}\n\n\t\t\tconst end = content.indexOf('\\n', start);\n\t\t\tif (end === -1) break;\n\n\t\t\tstart = end + 1;\n\t\t}\n\t}\n\treturn { insertions: insertions, deletions: deletions };\n}\n\n/** Counts the approximate number of changed lines in a diff file — the size of both sides of its\n * hunks, unchanged context included. Suitable for relative sizing, not for reporting a line count\n * to the user; use {@link countDiffInsertionsAndDeletions} for that. */\nexport function countDiffLines(file: ParsedGitDiffFile): number {\n\tlet count = 0;\n\tfor (const hunk of file.hunks) {\n\t\tcount += hunk.current.count + hunk.previous.count;\n\t}\n\treturn count;\n}\n\nexport function parseGitFileDiff(data: string, includeRawContent = false): ParsedGitDiffHunks | undefined {\n\tusing sw = maybeStopWatch('Git.parseFileDiff', { log: { onlyExit: true, level: 'debug' } });\n\tif (!data) {\n\t\tsw?.stop({ suffix: ` no data` });\n\t\treturn undefined;\n\t}\n\n\tconst hunks: ParsedGitDiffHunk[] = [];\n\n\tconst lines = data.split('\\n');\n\n\t// Skip header — match standard hunk headers only (`@@ ... @@`), NOT combined-diff headers (`@@@ ... @@@`)\n\tlet i = -1;\n\twhile (++i < lines.length) {\n\t\tif (lines[i].startsWith('@@ ')) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// Parse hunks\n\tlet line;\n\twhile (i < lines.length) {\n\t\tline = lines[i];\n\t\tif (!line.startsWith('@@ ')) {\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst header = line;\n\t\tconst [previousHeaderPart, currentHeaderPart] = header.split('@@')[1].trim().split(' ');\n\n\t\tconst current = parseHunkHeaderPart(currentHeaderPart.slice(1));\n\t\tconst previous = parseHunkHeaderPart(previousHeaderPart.slice(1));\n\n\t\tconst hunkLines = new Map<number, ParsedGitDiffHunkLine>();\n\t\tlet fileLineNumber = current.position.start;\n\n\t\tline = lines[++i];\n\t\tconst contentStartLine = i;\n\n\t\t// Parse hunks lines\n\t\twhile (i < lines.length && !line.startsWith('@@ ')) {\n\t\t\tswitch (line[0]) {\n\t\t\t\t// deleted\n\t\t\t\tcase '-': {\n\t\t\t\t\tlet deletedLineNumber = fileLineNumber;\n\t\t\t\t\twhile (line?.startsWith('-')) {\n\t\t\t\t\t\thunkLines.set(deletedLineNumber++, {\n\t\t\t\t\t\t\tcurrent: undefined,\n\t\t\t\t\t\t\tprevious: line.slice(1),\n\t\t\t\t\t\t\tstate: 'removed',\n\t\t\t\t\t\t});\n\t\t\t\t\t\tline = lines[++i];\n\t\t\t\t\t}\n\n\t\t\t\t\tif (line?.startsWith('+')) {\n\t\t\t\t\t\tlet addedLineNumber = fileLineNumber;\n\t\t\t\t\t\twhile (line?.startsWith('+')) {\n\t\t\t\t\t\t\tconst hunkLine = hunkLines.get(addedLineNumber);\n\t\t\t\t\t\t\tif (hunkLine != null) {\n\t\t\t\t\t\t\t\thunkLine.current = line.slice(1);\n\t\t\t\t\t\t\t\thunkLine.state = 'changed';\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\thunkLines.set(addedLineNumber, {\n\t\t\t\t\t\t\t\t\tcurrent: line.slice(1),\n\t\t\t\t\t\t\t\t\tprevious: undefined,\n\t\t\t\t\t\t\t\t\tstate: 'added',\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taddedLineNumber++;\n\t\t\t\t\t\t\tline = lines[++i];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfileLineNumber = addedLineNumber;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfileLineNumber = deletedLineNumber;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// added\n\t\t\t\tcase '+':\n\t\t\t\t\thunkLines.set(fileLineNumber++, {\n\t\t\t\t\t\tcurrent: line.slice(1),\n\t\t\t\t\t\tprevious: undefined,\n\t\t\t\t\t\tstate: 'added',\n\t\t\t\t\t});\n\n\t\t\t\t\tline = lines[++i];\n\t\t\t\t\tbreak;\n\n\t\t\t\t// unchanged (context)\n\t\t\t\tcase ' ':\n\t\t\t\t\thunkLines.set(fileLineNumber++, {\n\t\t\t\t\t\tcurrent: line.slice(1),\n\t\t\t\t\t\tprevious: line.slice(1),\n\t\t\t\t\t\tstate: 'unchanged',\n\t\t\t\t\t});\n\n\t\t\t\t\tline = lines[++i];\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tline = lines[++i];\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst hunk: ParsedGitDiffHunk = {\n\t\t\theader: header,\n\t\t\tcontent: lines.slice(contentStartLine, i).join('\\n'),\n\t\t\tcurrent: current,\n\t\t\tprevious: previous,\n\t\t\tlines: hunkLines,\n\t\t};\n\n\t\thunks.push(hunk);\n\t}\n\n\tsw?.stop({ suffix: ` parsed ${hunks.length} hunks` });\n\n\treturn {\n\t\trawContent: includeRawContent ? data : undefined,\n\t\thunks: hunks,\n\t};\n}\n\n/**\n * Parses the output of `git diff --numstat --summary -z`.\n *\n * Numstat records are null-separated:\n * `additions\\tdeletions\\tpath\\0`\n * Renames and copies have an empty path followed by two additional null-separated fields:\n * `additions\\tdeletions\\t\\0oldPath\\0newPath\\0`\n * The summary section (if any) follows the final null byte as newline-separated lines:\n * ` create mode 100644 path`\n * ` delete mode 100644 path`\n * ` rename old => new (100%)`\n * ` copy old => new (85%)`\n * ` mode change 100644 => 120000 path`\n *\n * Numstat alone cannot distinguish: rename vs. copy, or modified vs. type-changed.\n * The summary pass refines those statuses: copies are promoted to `C`, and mode changes\n * that cross the file-type boundary (regular file ↔ symlink ↔ gitlink, i.e. the high two\n * octal digits differ) are promoted to `T`.\n */\nexport function parseGitDiffNumStatFiles(data: string, repoPath: string): GitFile[] | undefined {\n\tusing sw = maybeStopWatch('Git.parseDiffNumStatFiles', { log: { onlyExit: true, level: 'debug' } });\n\tif (!data) {\n\t\tsw?.stop({ suffix: ` no data` });\n\t\treturn undefined;\n\t}\n\n\tconst files = new Map<string, GitFile>();\n\n\t// Numstat records are \\0-terminated; the summary (if any) lives after the final \\0 as \\n-separated lines.\n\t// Slice explicitly rather than popping the last split element, so numstat and summary never get conflated.\n\tconst lastNullIndex = data.lastIndexOf('\\0');\n\tconst numstatData = lastNullIndex === -1 ? data : data.substring(0, lastNullIndex);\n\tconst summary = lastNullIndex === -1 ? '' : data.substring(lastNullIndex + 1);\n\n\tconst fields = numstatData.split('\\0');\n\n\tlet i = 0;\n\twhile (i < fields.length) {\n\t\tconst field = fields[i];\n\t\tif (!field) {\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst tabIndex1 = field.indexOf('\\t');\n\t\tif (tabIndex1 === -1) {\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst tabIndex2 = field.indexOf('\\t', tabIndex1 + 1);\n\t\tif (tabIndex2 === -1) {\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst insertionsStr = field.substring(0, tabIndex1);\n\t\tconst deletionsStr = field.substring(tabIndex1 + 1, tabIndex2);\n\t\tlet path = field.substring(tabIndex2 + 1);\n\n\t\tlet originalPath: string | undefined;\n\t\tif (path === '') {\n\t\t\t// Rename or copy: next two fields are oldPath and newPath (summary pass distinguishes R vs C)\n\t\t\tif (i + 2 >= fields.length) break;\n\n\t\t\toriginalPath = fields[++i];\n\t\t\tpath = fields[++i];\n\t\t}\n\n\t\t// Binary files report `-` instead of a line count; preserve the explicit check for clarity\n\t\tconst additions = insertionsStr === '-' ? 0 : parseInt(insertionsStr, 10) || 0;\n\t\tconst deletions = deletionsStr === '-' ? 0 : parseInt(deletionsStr, 10) || 0;\n\n\t\tconst normalizedPath = normalizePath(path);\n\t\tfiles.set(normalizedPath, {\n\t\t\trepoPath: repoPath,\n\t\t\tpath: path,\n\t\t\toriginalPath: originalPath,\n\t\t\tstatus: originalPath ? 'R' : 'M',\n\t\t\tstats: { additions: additions, deletions: deletions, changes: additions + deletions },\n\t\t});\n\n\t\ti++;\n\t}\n\n\t// Refine statuses from the summary section:\n\t// create → A, delete → D, copy → C (renames already default to R from numstat),\n\t// mode change across file-type boundaries → T\n\tif (summary) {\n\t\tfor (let line of summary.split('\\n')) {\n\t\t\tline = line.trim();\n\t\t\tif (!line) continue;\n\n\t\t\t// A quoted name can hold the `{`, `}` or ` => ` the regex splits the compact form at\n\t\t\tif (line.startsWith('copy ') && line.includes('\"')) {\n\t\t\t\tconst copied = parseQuotedRenameOrCopyPaths(line.substring(5), true);\n\t\t\t\tif (copied != null) {\n\t\t\t\t\tconst file = files.get(normalizePath(copied.path));\n\t\t\t\t\tif (file != null) {\n\t\t\t\t\t\tfile.status = 'C';\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst match = diffSummaryRegex.exec(line);\n\t\t\tif (match == null) continue;\n\n\t\t\t// Positional destructure matches diffSummaryRegex's 9 capture groups.\n\t\t\t// Group 3 (original-leaf) is unused here — numstat already provides authoritative rename paths.\n\t\t\tconst [\n\t\t\t\t,\n\t\t\t\trenameOrCopy,\n\t\t\t\trenameRoot,\n\t\t\t\t,\n\t\t\t\trenameNewLeaf,\n\t\t\t\trenameSuffix,\n\t\t\t\tcreateOrDelete,\n\t\t\t\tcreateOrDeletePath,\n\t\t\t\toldMode,\n\t\t\t\tnewMode,\n\t\t\t\tmodeChangePath,\n\t\t\t] = match;\n\n\t\t\tif (createOrDelete != null) {\n\t\t\t\tconst file = files.get(normalizePath(unquoteCString(createOrDeletePath)));\n\t\t\t\tif (file != null) {\n\t\t\t\t\tfile.status = createOrDelete === 'create' ? 'A' : 'D';\n\t\t\t\t}\n\t\t\t} else if (renameOrCopy === 'copy') {\n\t\t\t\t// Numstat defaulted to R; promote to C. Reconstruct the full new-side path by\n\t\t\t\t// concatenating prefix + new-leaf + suffix, covering all compact and non-compact forms.\n\t\t\t\tconst file = files.get(normalizePath(renameRoot + renameNewLeaf + renameSuffix));\n\t\t\t\tif (file != null) {\n\t\t\t\t\tfile.status = 'C';\n\t\t\t\t}\n\t\t\t} else if (modeChangePath != null) {\n\t\t\t\t// File-type boundary: 100xxx = regular file, 120000 = symlink, 160000 = gitlink.\n\t\t\t\t// Promote to T only when the high two octal digits differ (ignore permission-only changes).\n\t\t\t\tif (oldMode.substring(0, 2) !== newMode.substring(0, 2)) {\n\t\t\t\t\tconst file = files.get(normalizePath(unquoteCString(modeChangePath)));\n\t\t\t\t\tif (file != null) {\n\t\t\t\t\t\tfile.status = 'T';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Renames are already handled by the numstat section with -z\n\t\t}\n\t}\n\n\tsw?.stop({ suffix: ` parsed ${files.size} files` });\n\n\treturn files.size > 0 ? [...files.values()] : undefined;\n}\n\n/**\n * Parses the output of `git apply --numstat --summary -z`. Unlike `git diff`, `git apply` writes the names of its\n * summary lines as they are, never C-quoted, so they are read as written\n */\nexport function parseGitApplyFiles(data: string, repoPath: string): GitFileChange[] {\n\tusing sw = maybeStopWatch('Git.parseApplyFiles', { log: { onlyExit: true, level: 'debug' } });\n\tif (!data) {\n\t\tsw?.stop({ suffix: ` no data` });\n\t\treturn [];\n\t}\n\n\tconst repoUri = fileUri(normalizePath(repoPath));\n\tconst getUri = (p: string) => joinUriPath(repoUri, normalizePath(p));\n\tconst files = new Map<string, GitFileChange>();\n\n\tconst lines = data.split('\\0');\n\t// remove the summary (last) line to parse later\n\tconst summary = lines.pop();\n\n\tfor (let line of lines) {\n\t\tline = line.trim();\n\t\tif (!line) continue;\n\n\t\t// The name is everything after the second tab: with `-z` it is as it is on disk, so it can hold tabs itself\n\t\tconst tab1 = line.indexOf('\\t');\n\t\tconst tab2 = tab1 === -1 ? -1 : line.indexOf('\\t', tab1 + 1);\n\t\tif (tab2 === -1) continue;\n\n\t\tconst insertions = line.substring(0, tab1);\n\t\tconst deletions = line.substring(tab1 + 1, tab2);\n\t\tconst path = line.substring(tab2 + 1);\n\t\tfiles.set(\n\t\t\tnormalizePath(path),\n\t\t\tnew GitFileChange(repoPath, path, 'M', getUri(path), undefined, undefined, undefined, {\n\t\t\t\tchanges: 0,\n\t\t\t\tadditions: parseInt(insertions, 10),\n\t\t\t\tdeletions: parseInt(deletions, 10),\n\t\t\t}),\n\t\t);\n\t}\n\n\tfor (let line of summary!.split('\\n')) {\n\t\tline = line.trim();\n\t\tif (!line) continue;\n\n\t\tconst match = diffSummaryRegex.exec(line);\n\t\tif (match == null) continue;\n\n\t\t// Positional destructure matches diffSummaryRegex's 9 capture groups.\n\t\t// mode-change groups (8–10) are unused here — git apply's summary does not emit them in practice.\n\t\tconst [\n\t\t\t,\n\t\t\trenameOrCopy,\n\t\t\trenameRoot,\n\t\t\trenameOriginalLeaf,\n\t\t\trenameNewLeaf,\n\t\t\trenameSuffix,\n\t\t\tcreateOrDelete,\n\t\t\tcreateOrDeletePath,\n\t\t] = match;\n\n\t\tif (renameOrCopy != null) {\n\t\t\t// Reconstruct both sides: prefix + leaf + suffix, handling all compact and non-compact forms.\n\t\t\tconst newPath = renameRoot + renameNewLeaf + renameSuffix;\n\t\t\tconst originalPath = renameRoot + renameOriginalLeaf + renameSuffix;\n\t\t\tconst key = normalizePath(newPath);\n\n\t\t\tconst file = files.get(key);\n\t\t\tif (file == null) continue;\n\n\t\t\tfiles.set(\n\t\t\t\tkey,\n\t\t\t\tnew GitFileChange(\n\t\t\t\t\trepoPath,\n\t\t\t\t\tfile.path,\n\t\t\t\t\trenameOrCopy === 'copy' ? 'C' : 'R',\n\t\t\t\t\tgetUri(file.path),\n\t\t\t\t\toriginalPath,\n\t\t\t\t\tgetUri(originalPath),\n\t\t\t\t\tundefined,\n\t\t\t\t\tfile.stats,\n\t\t\t\t),\n\t\t\t);\n\t\t} else if (createOrDelete != null) {\n\t\t\tconst key = normalizePath(createOrDeletePath);\n\t\t\tconst file = files.get(key);\n\t\t\tif (file == null) continue;\n\n\t\t\tfiles.set(\n\t\t\t\tkey,\n\t\t\t\tnew GitFileChange(\n\t\t\t\t\trepoPath,\n\t\t\t\t\tfile.path,\n\t\t\t\t\tcreateOrDelete === 'create' ? 'A' : 'D',\n\t\t\t\t\tgetUri(file.path),\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t\tfile.stats,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tsw?.stop({ suffix: ` parsed ${files.size} files` });\n\n\treturn [...files.values()];\n}\n\nexport function parseGitDiffShortStat(data: string): GitDiffShortStat | undefined {\n\tusing sw = maybeStopWatch('Git.parseDiffShortStat', { log: { onlyExit: true, level: 'debug' } });\n\tif (!data) {\n\t\tsw?.stop({ suffix: ` no data` });\n\t\treturn undefined;\n\t}\n\n\tconst match = shortStatDiffRegex.exec(data);\n\tif (match == null) return undefined;\n\n\tconst [, files, insertions, deletions] = match;\n\n\tconst diffShortStat: GitDiffShortStat = {\n\t\tfiles: files == null ? 0 : parseInt(files, 10),\n\t\tadditions: insertions == null ? 0 : parseInt(insertions, 10),\n\t\tdeletions: deletions == null ? 0 : parseInt(deletions, 10),\n\t};\n\n\tsw?.stop({\n\t\tsuffix: ` parsed ${diffShortStat.files} files, +${diffShortStat.additions} -${diffShortStat.deletions}`,\n\t});\n\n\treturn diffShortStat;\n}\n"],"mappings":";;;;;;;;AAkBA,MAAa,YAAY;AACzB,MAAa,gBAAgB;AAE7B,MAAM,kBACL;AACD,MAAM,qBAAqB;AAC3B,MAAM,eAAe;AACrB,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,oBAAoB;AAC1B,MAAM,wBAAwB;AAU9B,MAAM,mBACL;;;;;;AAOD,SAAS,eAAe,MAAc,QAAoC;CACzE,IAAI,KAAK,WAAW,IAAG,GAAG;EACzB,MAAM,SAAS,kBAAkB,MAAM,CAAC;EACxC,IAAI,UAAU,QAAQ,CAAC,OAAO,MAAM,WAAW,MAAM,GAAG,OAAO,KAAA;EAE/D,OAAO,OAAO,MAAM,UAAU,OAAO,MAAM;CAC5C;CAEA,IAAI,CAAC,KAAK,WAAW,MAAM,GAAG,OAAO,KAAA;CAErC,OAAO,KAAK,SAAS,GAAI,I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K,IAAI;EAC1C,IAAI,SAAS,MAAM,OAAO,KAAA;EAE1B,MAAM,GAAG,OAAO,YAAY,aAAa;EAEzC,MAAM,gBAAkC;GACvC,OAAO,SAAS,OAAO,IAAI,SAAS,OAAO,EAAE;GAC7C,WAAW,cAAc,OAAO,IAAI,SAAS,YAAY,EAAE;GAC3D,WAAW,aAAa,OAAO,IAAI,SAAS,WAAW,EAAE;EAC1D;EAEA,IAAI,KAAK,EACR,QAAQ,WAAW,cAAc,MAAM,WAAW,cAAc,UAAU,IAAI,cAAc,YAC7F,CAAC;EAED,OAAO;;;;;;AACR"}
|
|
@@ -36,6 +36,14 @@ export interface GitDiffSubProvider {
|
|
|
36
36
|
renames?: boolean;
|
|
37
37
|
similarityThreshold?: number;
|
|
38
38
|
uris?: (string | Uri)[];
|
|
39
|
+
/**
|
|
40
|
+
* Limits the diff to these repo-relative paths, matched literally and exactly as given (a name with glob
|
|
41
|
+
* characters matches only itself, a backslash is a file-name character rather than a separator, and a
|
|
42
|
+
* folder is everything under it). Wins over `uris`; an empty list resolves `undefined` without running
|
|
43
|
+
* git. Batched to fit the command line, so a rename whose two sides fall in different batches reads as a
|
|
44
|
+
* delete and an add
|
|
45
|
+
*/
|
|
46
|
+
paths?: string[];
|
|
39
47
|
/**
|
|
40
48
|
* `'throw'` rejects with the failure (a `GitError` carrying git's `stderr` when git ran) rather than
|
|
41
49
|
* resolving `undefined`, which is the default for every failure
|
|
@@ -56,6 +64,8 @@ export interface GitDiffSubProvider {
|
|
|
56
64
|
renames?: boolean;
|
|
57
65
|
similarityThreshold?: number;
|
|
58
66
|
uris?: (string | Uri)[];
|
|
67
|
+
/** As on `getDiff` */
|
|
68
|
+
paths?: string[];
|
|
59
69
|
errors?: GitErrorHandling;
|
|
60
70
|
}, cancellation?: AbortSignal): Promise<ParsedGitDiff | undefined>;
|
|
61
71
|
getDiffFiles?(repoPath: string, contents: string, cancellation?: AbortSignal): Promise<GitDiffFiles | undefined>;
|
|
@@ -24,7 +24,14 @@ export interface GitRevisionSubProvider {
|
|
|
24
24
|
getBlobIds?(repoPath: string, paths: readonly string[], source: 'index' | 'working', cancellation?: AbortSignal): Promise<Map<string, string>>;
|
|
25
25
|
/** The empty tree's id in this repository's object format (SHA-1 or SHA-256). */
|
|
26
26
|
getEmptyTreeSha(repoPath: string): Promise<string>;
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* The bytes of `path` at `rev`. `path` is an absolute path, a URI or a repo-relative path, with `\` taken as a
|
|
29
|
+
* separator (what a Windows path holds), unless `literalPath` is set: then it is a repo-relative path exactly
|
|
30
|
+
* as given, so a file name holding a backslash on Linux or macOS is read as itself
|
|
31
|
+
*/
|
|
32
|
+
getRevisionContent(repoPath: string, path: string, rev: string, options?: {
|
|
33
|
+
literalPath?: boolean;
|
|
34
|
+
}): Promise<Uint8Array | undefined>;
|
|
28
35
|
getSubmoduleHead?(repoPath: string, submodulePath: string): Promise<string | undefined>;
|
|
29
36
|
/**
|
|
30
37
|
* Gets tracked file paths from the index (reflects working tree state, even during rebase).
|