@statewalker/vcs-commands 0.8.0 → 0.9.0
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/dist/commands/add-command.d.ts +32 -0
- package/dist/commands/add-command.d.ts.map +1 -1
- package/dist/commands/add-patch/add-patch.d.ts +7 -0
- package/dist/commands/add-patch/add-patch.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
- package/dist/commands/am/am-command.d.ts +47 -0
- package/dist/commands/am/am-command.d.ts.map +1 -1
- package/dist/commands/apply/apply-command.d.ts +2 -0
- package/dist/commands/apply/apply-command.d.ts.map +1 -1
- package/dist/commands/apply/apply-parse.d.ts +7 -0
- package/dist/commands/apply/apply-parse.d.ts.map +1 -1
- package/dist/commands/apply/index.d.ts +1 -1
- package/dist/commands/apply/index.d.ts.map +1 -1
- package/dist/commands/blame-command.d.ts +303 -8
- package/dist/commands/blame-command.d.ts.map +1 -1
- package/dist/commands/blame-ignore.d.ts +48 -0
- package/dist/commands/blame-ignore.d.ts.map +1 -0
- package/dist/commands/check-mailmap-command.d.ts +49 -0
- package/dist/commands/check-mailmap-command.d.ts.map +1 -0
- package/dist/commands/checkout-command.d.ts +7 -0
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/checkout-paths.d.ts +4 -0
- package/dist/commands/checkout-paths.d.ts.map +1 -1
- package/dist/commands/cherry-command.d.ts +61 -0
- package/dist/commands/cherry-command.d.ts.map +1 -0
- package/dist/commands/cherry-pick-command.d.ts +23 -1
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-command.d.ts +32 -0
- package/dist/commands/clean-command.d.ts.map +1 -1
- package/dist/commands/clean-interactive.d.ts +56 -0
- package/dist/commands/clean-interactive.d.ts.map +1 -0
- package/dist/commands/clone-command.d.ts +116 -2
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +50 -2
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/describe-command.d.ts +71 -64
- package/dist/commands/describe-command.d.ts.map +1 -1
- package/dist/commands/diff-command.d.ts +118 -6
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/fetch-command.d.ts +60 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/fetch-multiple-command.d.ts +193 -0
- package/dist/commands/fetch-multiple-command.d.ts.map +1 -0
- package/dist/commands/format-patch-command.d.ts +28 -2
- package/dist/commands/format-patch-command.d.ts.map +1 -1
- package/dist/commands/git-describe.d.ts +77 -4
- package/dist/commands/git-describe.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +15 -1
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/index.d.ts +12 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +5 -3
- package/dist/commands/init-command.d.ts +89 -0
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/line-log.d.ts +161 -0
- package/dist/commands/line-log.d.ts.map +1 -0
- package/dist/commands/log-command.d.ts +235 -6
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-graph.d.ts +4 -2
- package/dist/commands/log-graph.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +66 -1
- package/dist/commands/log-output.d.ts.map +1 -1
- package/dist/commands/mailmap.d.ts +24 -1
- package/dist/commands/mailmap.d.ts.map +1 -1
- package/dist/commands/merge-command.d.ts +51 -1
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-drivers.d.ts +2 -0
- package/dist/commands/merge-drivers.d.ts.map +1 -1
- package/dist/commands/merge-strategy-options.d.ts +69 -0
- package/dist/commands/merge-strategy-options.d.ts.map +1 -0
- package/dist/commands/merge-support.d.ts +10 -0
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/message-cleanup.d.ts +2 -0
- package/dist/commands/message-cleanup.d.ts.map +1 -1
- package/dist/commands/name-rev-command.d.ts +65 -0
- package/dist/commands/name-rev-command.d.ts.map +1 -0
- package/dist/commands/name-rev.d.ts +110 -22
- package/dist/commands/name-rev.d.ts.map +1 -1
- package/dist/commands/octopus-merge.d.ts +26 -1
- package/dist/commands/octopus-merge.d.ts.map +1 -1
- package/dist/commands/ort-merge.d.ts +16 -0
- package/dist/commands/ort-merge.d.ts.map +1 -1
- package/dist/commands/ort-recursive.d.ts.map +1 -1
- package/dist/commands/patch-id.d.ts +58 -0
- package/dist/commands/patch-id.d.ts.map +1 -1
- package/dist/commands/pull-command.d.ts +182 -38
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +65 -0
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/range-diff/index.d.ts +4 -0
- package/dist/commands/range-diff/index.d.ts.map +1 -0
- package/dist/commands/range-diff/linear-assignment.d.ts +27 -0
- package/dist/commands/range-diff/linear-assignment.d.ts.map +1 -0
- package/dist/commands/range-diff/range-diff-command.d.ts +121 -0
- package/dist/commands/range-diff/range-diff-command.d.ts.map +1 -0
- package/dist/commands/range-diff/range-diff.d.ts +106 -0
- package/dist/commands/range-diff/range-diff.d.ts.map +1 -0
- package/dist/commands/read-tree-command.d.ts +14 -0
- package/dist/commands/read-tree-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +21 -2
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/remerge-diff.d.ts +59 -0
- package/dist/commands/remerge-diff.d.ts.map +1 -0
- package/dist/commands/remote-command.d.ts +41 -0
- package/dist/commands/remote-command.d.ts.map +1 -1
- package/dist/commands/remote-show-command.d.ts +204 -0
- package/dist/commands/remote-show-command.d.ts.map +1 -0
- package/dist/commands/reset-command.d.ts +19 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts +7 -0
- package/dist/commands/restore-command.d.ts.map +1 -1
- package/dist/commands/rev-list-command.d.ts +75 -3
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +22 -1
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +2 -0
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/sequencer-pick.d.ts +102 -1
- package/dist/commands/sequencer-pick.d.ts.map +1 -1
- package/dist/commands/sequencer-support.d.ts +10 -1
- package/dist/commands/sequencer-support.d.ts.map +1 -1
- package/dist/commands/shortlog-command.d.ts +109 -0
- package/dist/commands/shortlog-command.d.ts.map +1 -0
- package/dist/commands/shortlog.d.ts +151 -0
- package/dist/commands/shortlog.d.ts.map +1 -0
- package/dist/commands/status-command.d.ts +31 -2
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/submodule-commands.d.ts +90 -2
- package/dist/commands/submodule-commands.d.ts.map +1 -1
- package/dist/commands/submodule-fetch.d.ts +149 -0
- package/dist/commands/submodule-fetch.d.ts.map +1 -0
- package/dist/commands/submodule-model.d.ts +8 -0
- package/dist/commands/submodule-model.d.ts.map +1 -1
- package/dist/commands/submodule-unpack.d.ts +120 -0
- package/dist/commands/submodule-unpack.d.ts.map +1 -0
- package/dist/commands/submodule-update-command.d.ts +8 -0
- package/dist/commands/submodule-update-command.d.ts.map +1 -1
- package/dist/commands/subtree-shift.d.ts +27 -0
- package/dist/commands/subtree-shift.d.ts.map +1 -0
- package/dist/commands/switch-command.d.ts +3 -0
- package/dist/commands/switch-command.d.ts.map +1 -1
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/worktree-overwrite-checks.d.ts +2 -0
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
- package/dist/{commands-ISM52N0n.js → commands-CNvli5bl.js} +39426 -61169
- package/dist/errors/command-errors.d.ts +25 -0
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/index.js +29 -1
- package/dist/fsck-CPeDh9fh.js +5138 -0
- package/dist/git-command.d.ts +31 -1
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +97 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/guarded-transport-command.d.ts +82 -0
- package/dist/guarded-transport-command.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/dist/remote-transport-CCmBadm-.js +1606 -0
- package/dist/rename/detect-renames.d.ts +20 -0
- package/dist/rename/detect-renames.d.ts.map +1 -1
- package/dist/rename/diffcore-break.d.ts +51 -0
- package/dist/rename/diffcore-break.d.ts.map +1 -0
- package/dist/rename/index.d.ts +1 -0
- package/dist/rename/index.d.ts.map +1 -1
- package/dist/results/blame-format.d.ts +62 -1
- package/dist/results/blame-format.d.ts.map +1 -1
- package/dist/results/clone-result.d.ts +9 -0
- package/dist/results/clone-result.d.ts.map +1 -1
- package/dist/results/diff-dirstat.d.ts +36 -0
- package/dist/results/diff-dirstat.d.ts.map +1 -0
- package/dist/results/diff-entry.d.ts +10 -0
- package/dist/results/diff-entry.d.ts.map +1 -1
- package/dist/results/diff-formatter.d.ts.map +1 -1
- package/dist/results/diff-output.d.ts +18 -0
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/fetch-result.d.ts +12 -1
- package/dist/results/fetch-result.d.ts.map +1 -1
- package/dist/results/index.d.ts +2 -0
- package/dist/results/index.d.ts.map +1 -1
- package/dist/results/index.js +2 -2
- package/dist/results/init-result.d.ts +8 -1
- package/dist/results/init-result.d.ts.map +1 -1
- package/dist/results/line-range-hunks.d.ts +27 -0
- package/dist/results/line-range-hunks.d.ts.map +1 -0
- package/dist/results/merge-result.d.ts +8 -1
- package/dist/results/merge-result.d.ts.map +1 -1
- package/dist/results/pull-result.d.ts +11 -0
- package/dist/results/pull-result.d.ts.map +1 -1
- package/dist/results/push-result.d.ts +5 -0
- package/dist/results/push-result.d.ts.map +1 -1
- package/dist/results/status-result.d.ts +1 -1
- package/dist/results/status-result.d.ts.map +1 -1
- package/dist/results-BDuEgdLU.js +46847 -0
- package/dist/transport-command.d.ts +14 -0
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/commands/add-command.ts +115 -0
- package/src/commands/add-patch/add-patch.ts +8 -0
- package/src/commands/add-patch/patch-backend.ts +20 -2
- package/src/commands/am/am-command.ts +138 -4
- package/src/commands/apply/apply-command.ts +52 -9
- package/src/commands/apply/apply-parse.ts +10 -0
- package/src/commands/apply/index.ts +8 -1
- package/src/commands/blame-command.ts +1450 -51
- package/src/commands/blame-ignore.ts +307 -0
- package/src/commands/check-mailmap-command.ts +129 -0
- package/src/commands/checkout-command.ts +97 -12
- package/src/commands/checkout-paths.ts +28 -0
- package/src/commands/cherry-command.ts +187 -0
- package/src/commands/cherry-pick-command.ts +42 -1
- package/src/commands/clean-command.ts +92 -12
- package/src/commands/clean-interactive.ts +522 -0
- package/src/commands/clone-command.ts +596 -44
- package/src/commands/commit-command.ts +180 -47
- package/src/commands/describe-command.ts +341 -254
- package/src/commands/diff-command.ts +616 -56
- package/src/commands/fetch-command.ts +353 -6
- package/src/commands/fetch-multiple-command.ts +665 -0
- package/src/commands/format-patch-command.ts +189 -77
- package/src/commands/git-describe.ts +456 -217
- package/src/commands/git-hooks.ts +42 -3
- package/src/commands/index.ts +17 -0
- package/src/commands/init-command.ts +603 -49
- package/src/commands/line-log.ts +931 -0
- package/src/commands/log-command.ts +1414 -177
- package/src/commands/log-graph.ts +6 -3
- package/src/commands/log-output.ts +173 -10
- package/src/commands/mailmap.ts +41 -5
- package/src/commands/merge-command.ts +274 -16
- package/src/commands/merge-drivers.ts +3 -0
- package/src/commands/merge-strategy-options.ts +224 -0
- package/src/commands/merge-support.ts +101 -21
- package/src/commands/message-cleanup.ts +1 -1
- package/src/commands/name-rev-command.ts +184 -0
- package/src/commands/name-rev.ts +700 -109
- package/src/commands/octopus-merge.ts +35 -11
- package/src/commands/ort-merge.ts +41 -7
- package/src/commands/ort-recursive.ts +40 -2
- package/src/commands/patch-id.ts +109 -0
- package/src/commands/pull-command.ts +718 -224
- package/src/commands/push-command.ts +353 -3
- package/src/commands/range-diff/index.ts +3 -0
- package/src/commands/range-diff/linear-assignment.ts +203 -0
- package/src/commands/range-diff/range-diff-command.ts +433 -0
- package/src/commands/range-diff/range-diff.ts +617 -0
- package/src/commands/read-tree-command.ts +74 -3
- package/src/commands/rebase-command.ts +141 -65
- package/src/commands/remerge-diff.ts +241 -0
- package/src/commands/remote-command.ts +98 -10
- package/src/commands/remote-show-command.ts +836 -0
- package/src/commands/reset-command.ts +78 -3
- package/src/commands/restore-command.ts +15 -0
- package/src/commands/rev-list-command.ts +187 -11
- package/src/commands/revert-command.ts +41 -1
- package/src/commands/revision-range.ts +3 -1
- package/src/commands/sequencer-pick.ts +323 -29
- package/src/commands/sequencer-support.ts +164 -2
- package/src/commands/shortlog-command.ts +354 -0
- package/src/commands/shortlog.ts +361 -0
- package/src/commands/show-command.ts +2 -1
- package/src/commands/status-command.ts +115 -25
- package/src/commands/status-format.ts +1 -1
- package/src/commands/submodule-commands.ts +321 -3
- package/src/commands/submodule-fetch.ts +789 -0
- package/src/commands/submodule-model.ts +9 -1
- package/src/commands/submodule-unpack.ts +265 -0
- package/src/commands/submodule-update-command.ts +39 -5
- package/src/commands/subtree-shift.ts +215 -0
- package/src/commands/switch-command.ts +9 -0
- package/src/commands/tree-restore.ts +6 -1
- package/src/commands/worktree-overwrite-checks.ts +5 -0
- package/src/errors/command-errors.ts +35 -0
- package/src/git-command.ts +87 -1
- package/src/git.ts +146 -0
- package/src/guarded-transport-command.ts +171 -0
- package/src/index.ts +1 -0
- package/src/rename/detect-renames.ts +42 -8
- package/src/rename/diffcore-break.ts +166 -0
- package/src/rename/index.ts +1 -0
- package/src/results/blame-format.ts +268 -43
- package/src/results/clone-result.ts +6 -0
- package/src/results/diff-dirstat.ts +117 -0
- package/src/results/diff-entry.ts +12 -0
- package/src/results/diff-formatter.ts +1 -0
- package/src/results/diff-output.ts +127 -2
- package/src/results/fetch-result.ts +12 -1
- package/src/results/index.ts +2 -0
- package/src/results/init-result.ts +10 -1
- package/src/results/line-range-hunks.ts +126 -0
- package/src/results/merge-result.ts +9 -0
- package/src/results/pull-result.ts +7 -0
- package/src/results/push-result.ts +5 -0
- package/src/results/status-result.ts +2 -2
- package/src/transport-command.ts +34 -3
- package/dist/fsck-DLRpbwTj.js +0 -13405
- package/dist/results-TB2IJ64h.js +0 -4700
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `--dirstat` (diff.c's `show_dirstat`, `show_dirstat_by_line`, `gather_dirstat`): how much
|
|
3
|
+
* of the change each directory holds, as a percentage of the whole.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* formatDirstat([{ name: "a/x", changed: 3 }, { name: "b/y", changed: 1 }], DEFAULT_DIRSTAT);
|
|
8
|
+
* // " 75.0% a/\n 25.0% b/\n"
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { compareGitPaths } from "@statewalker/vcs-utils/encoding";
|
|
13
|
+
|
|
14
|
+
/** The dirstat's parameters (`diff_options`' dirstat flags and `dirstat_permille`) */
|
|
15
|
+
export interface DirstatParams {
|
|
16
|
+
/** `lines`: damage from the diffstat's line counts */
|
|
17
|
+
byLine: boolean;
|
|
18
|
+
/** `files`: each changed file counts one */
|
|
19
|
+
byFile: boolean;
|
|
20
|
+
/** `cumulative`: a directory's count includes its subdirectories' */
|
|
21
|
+
cumulative: boolean;
|
|
22
|
+
/** The cut-off, in tenths of a percent (default 30: 3%) */
|
|
23
|
+
permille: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** git's defaults: `changes,noncumulative,3` */
|
|
27
|
+
export const DEFAULT_DIRSTAT: DirstatParams = {
|
|
28
|
+
byLine: false,
|
|
29
|
+
byFile: false,
|
|
30
|
+
cumulative: false,
|
|
31
|
+
permille: 30,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const isDigit = (c: string | undefined) => c !== undefined && c >= "0" && c <= "9";
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* diff.c's `parse_dirstat_params`: the comma-separated parameters applied over `params`;
|
|
38
|
+
* returns git's error lines (` Unknown dirstat parameter '<p>'`), the valid ones applied.
|
|
39
|
+
*/
|
|
40
|
+
export function parseDirstatParams(text: string, params: DirstatParams): string[] {
|
|
41
|
+
const errors: string[] = [];
|
|
42
|
+
if (text === "") return errors;
|
|
43
|
+
for (const p of text.split(",")) {
|
|
44
|
+
if (p === "changes") {
|
|
45
|
+
params.byLine = false;
|
|
46
|
+
params.byFile = false;
|
|
47
|
+
} else if (p === "lines") {
|
|
48
|
+
params.byLine = true;
|
|
49
|
+
params.byFile = false;
|
|
50
|
+
} else if (p === "files") {
|
|
51
|
+
params.byLine = false;
|
|
52
|
+
params.byFile = true;
|
|
53
|
+
} else if (p === "noncumulative") params.cumulative = false;
|
|
54
|
+
else if (p === "cumulative") params.cumulative = true;
|
|
55
|
+
else if (isDigit(p[0])) {
|
|
56
|
+
let at = 0;
|
|
57
|
+
while (isDigit(p[at])) at++;
|
|
58
|
+
let permille = Number(p.slice(0, at)) * 10;
|
|
59
|
+
if (p[at] === "." && isDigit(p[at + 1])) {
|
|
60
|
+
// only the first digit counts, the others are ignored
|
|
61
|
+
permille += p.charCodeAt(at + 1) - 48;
|
|
62
|
+
at += 2;
|
|
63
|
+
while (isDigit(p[at])) at++;
|
|
64
|
+
}
|
|
65
|
+
if (at === p.length) params.permille = permille;
|
|
66
|
+
else errors.push(` Failed to parse dirstat cut-off percentage '${p}'`);
|
|
67
|
+
} else errors.push(` Unknown dirstat parameter '${p}'`);
|
|
68
|
+
}
|
|
69
|
+
return errors;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** One file's damage (`struct dirstat_file`) */
|
|
73
|
+
export interface DirstatFile {
|
|
74
|
+
name: string;
|
|
75
|
+
changed: number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** `conclude_dirstat` / `gather_dirstat`: the directories at or above the cut-off */
|
|
79
|
+
export function formatDirstat(files: readonly DirstatFile[], params: DirstatParams): string {
|
|
80
|
+
let total = 0;
|
|
81
|
+
for (const f of files) total += f.changed;
|
|
82
|
+
// everything renamed: nothing changed
|
|
83
|
+
if (!total) return "";
|
|
84
|
+
const sorted = [...files].sort((a, b) => compareGitPaths(a.name, b.name));
|
|
85
|
+
let at = 0;
|
|
86
|
+
let out = "";
|
|
87
|
+
const gather = (base: string): number => {
|
|
88
|
+
let sum = 0;
|
|
89
|
+
let sources = 0;
|
|
90
|
+
while (at < sorted.length) {
|
|
91
|
+
const f = sorted[at] as DirstatFile;
|
|
92
|
+
if (!f.name.startsWith(base)) break;
|
|
93
|
+
const slash = f.name.indexOf("/", base.length);
|
|
94
|
+
let changes: number;
|
|
95
|
+
if (slash >= 0) {
|
|
96
|
+
changes = gather(f.name.slice(0, slash + 1));
|
|
97
|
+
sources++;
|
|
98
|
+
} else {
|
|
99
|
+
changes = f.changed;
|
|
100
|
+
at++;
|
|
101
|
+
sources += 2;
|
|
102
|
+
}
|
|
103
|
+
sum += changes;
|
|
104
|
+
}
|
|
105
|
+
// no line for the top level, or a directory whose changes all come from one subdirectory
|
|
106
|
+
if (base && sources !== 1 && sum) {
|
|
107
|
+
const permille = Math.trunc((sum * 1000) / total);
|
|
108
|
+
if (permille >= params.permille) {
|
|
109
|
+
out += `${String(Math.trunc(permille / 10)).padStart(4)}.${permille % 10}% ${base}\n`;
|
|
110
|
+
if (!params.cumulative) return 0;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return sum;
|
|
114
|
+
};
|
|
115
|
+
gather("");
|
|
116
|
+
return out;
|
|
117
|
+
}
|
|
@@ -101,6 +101,18 @@ export interface DiffEntry {
|
|
|
101
101
|
* when that commit is the old side's, and no rename pairs with it.
|
|
102
102
|
*/
|
|
103
103
|
newIdUnknown?: boolean;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* `git log -L`: the line ranges of the new side the patch is cut to (0-based, end
|
|
107
|
+
* exclusive, sorted and apart; line-log.c's `line_ranges` of the pair)
|
|
108
|
+
*/
|
|
109
|
+
lineRanges?: readonly LineRange[];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Lines `[start, end)` of a file, 0-based (line-log.c's `struct range`) */
|
|
113
|
+
export interface LineRange {
|
|
114
|
+
start: number;
|
|
115
|
+
end: number;
|
|
104
116
|
}
|
|
105
117
|
|
|
106
118
|
/**
|
|
@@ -136,6 +136,7 @@ export function diffEntryToPair(entry: DiffEntry, blobs: Blobs): DiffFilePair {
|
|
|
136
136
|
: side(entry.oldPath ?? entry.newPath, entry.oldMode, entry.oldId, entry.readOld),
|
|
137
137
|
new: newSide,
|
|
138
138
|
...(entry.score !== undefined ? { score: entry.score } : {}),
|
|
139
|
+
...(entry.lineRanges ? { lineRanges: entry.lineRanges } : {}),
|
|
139
140
|
};
|
|
140
141
|
}
|
|
141
142
|
|
|
@@ -52,7 +52,9 @@ import {
|
|
|
52
52
|
import { WS_DEFAULT_RULE, WS_INCOMPLETE_LINE } from "../whitespace/index.js";
|
|
53
53
|
import { gitBinaryPatch } from "./binary-patch.js";
|
|
54
54
|
import { type ColoredHunk, type DiffColors, WSEH_NEW, writeColoredHunks } from "./diff-color.js";
|
|
55
|
+
import type { LineRange } from "./diff-entry.js";
|
|
55
56
|
import { compileWordRegex, writeWordDiffHunks } from "./diff-words.js";
|
|
57
|
+
import { cutToLineRanges, lineRangesSpan } from "./line-range-hunks.js";
|
|
56
58
|
import { quoteCStyleBody, quotePath, quoteTwo } from "./quote-path.js";
|
|
57
59
|
|
|
58
60
|
/** One side of a file pair */
|
|
@@ -105,6 +107,11 @@ export interface DiffFilePair {
|
|
|
105
107
|
new?: DiffSideSpec;
|
|
106
108
|
/** Similarity percentage of a rename or copy */
|
|
107
109
|
score?: number;
|
|
110
|
+
/**
|
|
111
|
+
* `git log -L`: the patch shows only the changes of these lines of the new side (diff.c's
|
|
112
|
+
* `line_ranges`, see {@link cutToLineRanges})
|
|
113
|
+
*/
|
|
114
|
+
lineRanges?: readonly LineRange[];
|
|
108
115
|
}
|
|
109
116
|
|
|
110
117
|
/** What a diff driver (`diff=<name>` attribute) changes */
|
|
@@ -141,6 +148,11 @@ export interface DiffOutputOptions
|
|
|
141
148
|
indentHeuristic?: boolean;
|
|
142
149
|
/** Length of abbreviated object ids in `index` lines (default 7) */
|
|
143
150
|
abbrev?: number;
|
|
151
|
+
/**
|
|
152
|
+
* diff.c's `additional_path_headers` (`--remerge-diff`'s `remerge CONFLICT` lines): the
|
|
153
|
+
* headers shown after a pair's rename lines, by the pair's first name
|
|
154
|
+
*/
|
|
155
|
+
additionalHeaders?: (name: string) => readonly string[] | undefined;
|
|
144
156
|
/**
|
|
145
157
|
* The length of each id in `index` lines, as git abbreviates them (`DiffCommand` finds
|
|
146
158
|
* them from `core.abbrev`, the repository's size and the other objects); ids not in it
|
|
@@ -422,6 +434,33 @@ export async function writePairPatch(
|
|
|
422
434
|
await builtinDiff(sink, pair, options, undefined, report);
|
|
423
435
|
}
|
|
424
436
|
|
|
437
|
+
/** add_formatted_headers: each line of each header, in the meta color */
|
|
438
|
+
function formattedHeaders(headers: readonly string[], set: string, reset: string): string {
|
|
439
|
+
let text = "";
|
|
440
|
+
for (const header of headers) {
|
|
441
|
+
for (const line of header.split("\n")) text += `${set}${line}${reset}\n`;
|
|
442
|
+
}
|
|
443
|
+
return text;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* A pair create_filepairs_for_header_only_notifications adds for a path with headers but no
|
|
448
|
+
* change (`--remerge-diff`): its `diff --git` line and the headers alone.
|
|
449
|
+
*/
|
|
450
|
+
export function writeHeaderOnlyPatch(
|
|
451
|
+
sink: ByteSink,
|
|
452
|
+
path: string,
|
|
453
|
+
headers: readonly string[],
|
|
454
|
+
options: DiffOutputOptions = {},
|
|
455
|
+
): void {
|
|
456
|
+
const quote = options.quotePath ?? true;
|
|
457
|
+
const set = options.colors?.meta ?? "";
|
|
458
|
+
const reset = options.colors?.reset ?? "";
|
|
459
|
+
const aOne = quoteTwo(options.srcPrefix ?? "a/", stripSlash(path), quote);
|
|
460
|
+
const bTwo = quoteTwo(options.dstPrefix ?? "b/", stripSlash(path), quote);
|
|
461
|
+
sink.text(`${set}diff --git ${aOne} ${bTwo}${reset}\n${formattedHeaders(headers, set, reset)}`);
|
|
462
|
+
}
|
|
463
|
+
|
|
425
464
|
/** `fill_metainfo`: rename/copy lines and the index line; whether they force the header */
|
|
426
465
|
function metainfo(
|
|
427
466
|
pair: DiffFilePair,
|
|
@@ -443,6 +482,15 @@ function metainfo(
|
|
|
443
482
|
text += `${set}${word} from ${quotePath(name, quote)}${reset}\n`;
|
|
444
483
|
text += `${set}${word} to ${quotePath(other ?? name, quote)}${reset}\n`;
|
|
445
484
|
mustShow = true;
|
|
485
|
+
} else if (pair.status === "M" && pair.score) {
|
|
486
|
+
// a broken pair merged back (`-B`): a complete rewrite
|
|
487
|
+
text += `${set}dissimilarity index ${pair.score}%${reset}\n`;
|
|
488
|
+
mustShow = true;
|
|
489
|
+
}
|
|
490
|
+
const more = options.additionalHeaders?.(name);
|
|
491
|
+
if (more && more.length > 0) {
|
|
492
|
+
text += formattedHeaders(more, set, reset);
|
|
493
|
+
mustShow = true;
|
|
446
494
|
}
|
|
447
495
|
if (one.id !== two.id) {
|
|
448
496
|
const abbrev = (id: string) =>
|
|
@@ -530,6 +578,23 @@ async function builtinDiff(
|
|
|
530
578
|
}
|
|
531
579
|
header += meta.text;
|
|
532
580
|
if ((one.mode ^ two.mode) & S_IFMT) return;
|
|
581
|
+
// a complete rewrite (a broken pair, `-B`) of text: every line removed, then added
|
|
582
|
+
if (
|
|
583
|
+
pair.status === "M" &&
|
|
584
|
+
pair.score &&
|
|
585
|
+
(textconvOne || options.text || !(await one.isBinary(threshold))) &&
|
|
586
|
+
(textconvTwo || options.text || !(await two.isBinary(threshold)))
|
|
587
|
+
) {
|
|
588
|
+
const a = textconvOne
|
|
589
|
+
? await textconvOne(await one.textconvInput(), attrOne)
|
|
590
|
+
: await one.read();
|
|
591
|
+
const b = textconvTwo
|
|
592
|
+
? await textconvTwo(await two.textconvInput(), attrTwo)
|
|
593
|
+
: await two.read();
|
|
594
|
+
sink.text(header);
|
|
595
|
+
writeRewriteDiff(sink, a, b, lbl0, lbl1, options.colors);
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
533
598
|
}
|
|
534
599
|
if (report) {
|
|
535
600
|
report.gitLine = `diff --git ${aOne} ${bTwo}`;
|
|
@@ -581,12 +646,19 @@ async function builtinDiff(
|
|
|
581
646
|
const textTwo = textconvTwo
|
|
582
647
|
? await textconvTwo(await two.textconvInput(), attrTwo)
|
|
583
648
|
: await two.read();
|
|
584
|
-
|
|
649
|
+
// `git log -L`: the context widened to the widest range, the hunks then cut to the ranges
|
|
650
|
+
const lineRanges = pair.lineRanges;
|
|
651
|
+
const context = lineRanges
|
|
652
|
+
? Math.max(options.context ?? 3, lineRangesSpan(lineRanges))
|
|
653
|
+
: options.context;
|
|
654
|
+
let result = unifiedDiffHunks(textOne, textTwo, {
|
|
585
655
|
...options,
|
|
656
|
+
...(context !== undefined ? { context } : {}),
|
|
586
657
|
algorithm,
|
|
587
658
|
indentHeuristic: options.indentHeuristic ?? true,
|
|
588
659
|
findFunction: driver?.findFunction,
|
|
589
660
|
});
|
|
661
|
+
if (lineRanges) result = { ...result, hunks: cutToLineRanges(result.hunks, lineRanges) };
|
|
590
662
|
if (report) report.result = result;
|
|
591
663
|
if (result.hunks.length === 0) return;
|
|
592
664
|
if (header) sink.text(header);
|
|
@@ -644,6 +716,55 @@ async function builtinDiff(
|
|
|
644
716
|
});
|
|
645
717
|
}
|
|
646
718
|
|
|
719
|
+
/** diff.c's `count_lines`: lines, a last one without a newline counted */
|
|
720
|
+
export function countLines(data: Uint8Array): number {
|
|
721
|
+
let count = 0;
|
|
722
|
+
let completeLine = 0;
|
|
723
|
+
for (const ch of data) {
|
|
724
|
+
if (ch === 0x0a) {
|
|
725
|
+
count++;
|
|
726
|
+
completeLine = 0;
|
|
727
|
+
} else completeLine++;
|
|
728
|
+
}
|
|
729
|
+
return completeLine ? count + 1 : count;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
/** diff.c's `emit_rewrite_diff`: a complete rewrite as one hunk */
|
|
733
|
+
function writeRewriteDiff(
|
|
734
|
+
sink: ByteSink,
|
|
735
|
+
a: Uint8Array,
|
|
736
|
+
b: Uint8Array,
|
|
737
|
+
lbl0: string,
|
|
738
|
+
lbl1: string,
|
|
739
|
+
colors: DiffOutputOptions["colors"],
|
|
740
|
+
): void {
|
|
741
|
+
const lcA = countLines(a);
|
|
742
|
+
const lcB = countLines(b);
|
|
743
|
+
const count = (n: number) => (n === 0 ? "0,0" : n === 1 ? "1" : `1,${n}`);
|
|
744
|
+
const meta = colors?.meta ?? "";
|
|
745
|
+
const reset = colors?.reset ?? "";
|
|
746
|
+
sink.text(
|
|
747
|
+
`${meta}--- ${lbl0}${reset}${lbl0.includes(" ") ? "\t" : ""}\n` +
|
|
748
|
+
`${meta}+++ ${lbl1}${reset}${lbl1.includes(" ") ? "\t" : ""}\n`,
|
|
749
|
+
);
|
|
750
|
+
sink.text(`${colors?.frag ?? ""}@@ -${count(lcA)} +${count(lcB)} @@${reset}\n`);
|
|
751
|
+
const lines = (data: Uint8Array, prefix: string, color: string) => {
|
|
752
|
+
let at = 0;
|
|
753
|
+
while (at < data.length) {
|
|
754
|
+
let end = data.indexOf(0x0a, at);
|
|
755
|
+
const complete = end >= 0;
|
|
756
|
+
if (!complete) end = data.length;
|
|
757
|
+
sink.text(`${color}${prefix}`);
|
|
758
|
+
sink.push(data.subarray(at, end));
|
|
759
|
+
sink.text(`${color ? reset : ""}\n`);
|
|
760
|
+
if (!complete) sink.text("\\n");
|
|
761
|
+
at = end + 1;
|
|
762
|
+
}
|
|
763
|
+
};
|
|
764
|
+
if (lcA) lines(a, "-", colors?.old ?? "");
|
|
765
|
+
if (lcB) lines(b, "+", colors?.new ?? "");
|
|
766
|
+
}
|
|
767
|
+
|
|
647
768
|
/** The hunks of a text diff with their lines' bytes, for the colored writer */
|
|
648
769
|
function coloredHunksOf(result: UnifiedDiffResult): ColoredHunk[] {
|
|
649
770
|
return result.hunks.map((hunk) => ({
|
|
@@ -724,6 +845,10 @@ export async function computeDiffstat(
|
|
|
724
845
|
file.added = await two.size(threshold);
|
|
725
846
|
file.deleted = await one.size(threshold);
|
|
726
847
|
}
|
|
848
|
+
} else if (pair.status === "M" && pair.score) {
|
|
849
|
+
// a complete rewrite counts every line of both sides
|
|
850
|
+
file.deleted = countLines(await one.read());
|
|
851
|
+
file.added = countLines(await two.read());
|
|
727
852
|
} else if (mayDiffer) {
|
|
728
853
|
const counts = diffLineCounts(await one.read(), await two.read(), {
|
|
729
854
|
...options,
|
|
@@ -1049,7 +1174,7 @@ export function formatNameStatus(
|
|
|
1049
1174
|
const quote = options.quotePath ?? true;
|
|
1050
1175
|
let out = "";
|
|
1051
1176
|
for (const p of pairs) {
|
|
1052
|
-
const score = p.
|
|
1177
|
+
const score = p.score ?? 0;
|
|
1053
1178
|
out += score ? `${p.status}${String(score).padStart(3, "0")}\t` : `${p.status}\t`;
|
|
1054
1179
|
if (p.status === "R" || p.status === "C") {
|
|
1055
1180
|
out += `${quotePath(p.old?.path ?? "", quote)}\t${quotePath(p.new?.path ?? "", quote)}\n`;
|
|
@@ -92,8 +92,19 @@ export interface FetchResult {
|
|
|
92
92
|
* and exits 1; absent when nothing failed
|
|
93
93
|
*/
|
|
94
94
|
errors?: string[];
|
|
95
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* The submodules' fetch results (`--recurse-submodules`), by submodule path; absent when
|
|
97
|
+
* no submodule was fetched
|
|
98
|
+
*/
|
|
96
99
|
submodules?: Map<string, FetchResult>;
|
|
100
|
+
/**
|
|
101
|
+
* What the submodule recursion printed on stderr after the superproject's lines, as git
|
|
102
|
+
* prints it: `Fetching submodule <path>`, each submodule's fetch output, `Errors during
|
|
103
|
+
* submodule fetch:` and the failed submodules' names
|
|
104
|
+
*/
|
|
105
|
+
submoduleOutput?: string;
|
|
106
|
+
/** A submodule's fetch failed (or one could not be accessed): git exits 1 */
|
|
107
|
+
submodulesFailed?: boolean;
|
|
97
108
|
/**
|
|
98
109
|
* The layer hashes of the commit-graph chain the fetch wrote (`fetch.writeCommitGraph`,
|
|
99
110
|
* `--write-commit-graph`), base first; absent when it wrote none
|
package/src/results/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./clone-result.js";
|
|
|
4
4
|
export * from "./combined-diff.js";
|
|
5
5
|
export * from "./diff-check.js";
|
|
6
6
|
export * from "./diff-color.js";
|
|
7
|
+
export * from "./diff-dirstat.js";
|
|
7
8
|
export * from "./diff-entry.js";
|
|
8
9
|
export * from "./diff-formatter.js";
|
|
9
10
|
export * from "./diff-order.js";
|
|
@@ -12,6 +13,7 @@ export * from "./diff-pickaxe.js";
|
|
|
12
13
|
export * from "./diff-words.js";
|
|
13
14
|
export * from "./fetch-result.js";
|
|
14
15
|
export * from "./init-result.js";
|
|
16
|
+
export * from "./line-range-hunks.js";
|
|
15
17
|
export * from "./merge-result.js";
|
|
16
18
|
export * from "./pull-result.js";
|
|
17
19
|
export * from "./push-result.js";
|
|
@@ -33,6 +33,15 @@ export interface InitResult {
|
|
|
33
33
|
/** Whether this is a bare repository */
|
|
34
34
|
bare: boolean;
|
|
35
35
|
|
|
36
|
-
/** Path to the .git directory */
|
|
36
|
+
/** Path to the .git directory (with `--separate-git-dir`, where the repository is) */
|
|
37
37
|
gitDir: string;
|
|
38
|
+
|
|
39
|
+
/** Whether an existing repository was re-initialised (git's "Reinitialized existing") */
|
|
40
|
+
reinitialized?: boolean;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* `core.sharedRepository` as the repository got it (git_config_perm: 0 not shared,
|
|
44
|
+
* `0o660` group, `0o664` everybody, a negated octal mode): git's "shared" in its message
|
|
45
|
+
*/
|
|
46
|
+
shared?: number;
|
|
38
47
|
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hunks of a patch cut to line ranges of its new side, as git 2.5x's `git log -L` prints a
|
|
3
|
+
* commit's diff (diff.c's `line_range_hunk_fn`, `line_range_line_fn` and `flush_rhunk`).
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* // the diff made with at least the widest range's span as context, then cut
|
|
8
|
+
* const hunks = cutToLineRanges(result.hunks, [{ start: 5, end: 9 }]);
|
|
9
|
+
* // one hunk per range that holds a change, headed `@@ -6,4 +6,4 @@`
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* The patch is diffed with its context widened to the widest range, so the changes of one
|
|
13
|
+
* range fall into one hunk; each line is then placed by its new-side line number. Context and
|
|
14
|
+
* added lines inside a range are kept, removed lines only when the next context or added line
|
|
15
|
+
* is inside it (they have no new-side line of their own). A range's lines make one hunk,
|
|
16
|
+
* dropped when it holds no change; its header always prints both counts, with the function
|
|
17
|
+
* line of the last hunk the diff gave.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import type { EmittedHunk, EmittedLine } from "@statewalker/vcs-utils";
|
|
23
|
+
import type { LineRange } from "./diff-entry.js";
|
|
24
|
+
|
|
25
|
+
/** The widest span of `ranges`: the context a patch cut to them is diffed with (at least) */
|
|
26
|
+
export function lineRangesSpan(ranges: readonly LineRange[]): number {
|
|
27
|
+
let span = 0;
|
|
28
|
+
for (const r of ranges) span = Math.max(span, r.end - r.start);
|
|
29
|
+
return span;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** `hunks` cut to the new-side lines of `ranges` (0-based, end exclusive, sorted) */
|
|
33
|
+
export function cutToLineRanges(
|
|
34
|
+
hunks: readonly EmittedHunk[],
|
|
35
|
+
ranges: readonly LineRange[],
|
|
36
|
+
): EmittedHunk[] {
|
|
37
|
+
const out: EmittedHunk[] = [];
|
|
38
|
+
let cur = 0;
|
|
39
|
+
let lnoPost = 0;
|
|
40
|
+
let lnoPre = 0;
|
|
41
|
+
let func: Uint8Array = new Uint8Array(0);
|
|
42
|
+
let rhunk: EmittedLine[] = [];
|
|
43
|
+
let active = false;
|
|
44
|
+
let hasChanges = false;
|
|
45
|
+
let oldBegin = 0;
|
|
46
|
+
let oldCount = 0;
|
|
47
|
+
let newBegin = 0;
|
|
48
|
+
let newCount = 0;
|
|
49
|
+
let pending: EmittedLine[] = [];
|
|
50
|
+
let pendingPreBegin = 0;
|
|
51
|
+
|
|
52
|
+
const flush = () => {
|
|
53
|
+
if (!active) return;
|
|
54
|
+
if (pending.length > 0) {
|
|
55
|
+
rhunk.push(...pending);
|
|
56
|
+
oldCount += pending.length;
|
|
57
|
+
hasChanges = true;
|
|
58
|
+
pending = [];
|
|
59
|
+
}
|
|
60
|
+
active = false;
|
|
61
|
+
if (hasChanges) {
|
|
62
|
+
out.push({
|
|
63
|
+
oldStart: oldBegin,
|
|
64
|
+
oldCount,
|
|
65
|
+
newStart: newBegin,
|
|
66
|
+
newCount,
|
|
67
|
+
func,
|
|
68
|
+
lines: rhunk,
|
|
69
|
+
countsAlways: true,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
rhunk = [];
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
for (const hunk of hunks) {
|
|
76
|
+
lnoPost = hunk.newStart;
|
|
77
|
+
lnoPre = hunk.oldStart;
|
|
78
|
+
func = hunk.func;
|
|
79
|
+
for (const line of hunk.lines) {
|
|
80
|
+
if (line.kind === "-") {
|
|
81
|
+
if (pending.length === 0) pendingPreBegin = lnoPre;
|
|
82
|
+
lnoPre++;
|
|
83
|
+
pending.push(line);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const lno = lnoPost - 1;
|
|
87
|
+
const curPre = lnoPre;
|
|
88
|
+
lnoPost++;
|
|
89
|
+
if (line.kind === " ") lnoPre++;
|
|
90
|
+
while (cur < ranges.length && lno >= (ranges[cur] as LineRange).end) {
|
|
91
|
+
flush();
|
|
92
|
+
pending = [];
|
|
93
|
+
cur++;
|
|
94
|
+
}
|
|
95
|
+
if (cur >= ranges.length) {
|
|
96
|
+
pending = [];
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (lno < (ranges[cur] as LineRange).start) {
|
|
100
|
+
pending = [];
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (!active) {
|
|
104
|
+
active = true;
|
|
105
|
+
hasChanges = false;
|
|
106
|
+
newBegin = lno + 1;
|
|
107
|
+
oldBegin = pending.length > 0 ? pendingPreBegin : curPre;
|
|
108
|
+
oldCount = 0;
|
|
109
|
+
newCount = 0;
|
|
110
|
+
rhunk = [];
|
|
111
|
+
}
|
|
112
|
+
if (pending.length > 0) {
|
|
113
|
+
rhunk.push(...pending);
|
|
114
|
+
oldCount += pending.length;
|
|
115
|
+
hasChanges = true;
|
|
116
|
+
pending = [];
|
|
117
|
+
}
|
|
118
|
+
rhunk.push(line);
|
|
119
|
+
newCount++;
|
|
120
|
+
if (line.kind === "+") hasChanges = true;
|
|
121
|
+
else oldCount++;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
flush();
|
|
125
|
+
return out;
|
|
126
|
+
}
|
|
@@ -71,6 +71,9 @@ export enum MergeStrategy {
|
|
|
71
71
|
*/
|
|
72
72
|
RECURSIVE = "recursive",
|
|
73
73
|
|
|
74
|
+
/** git's merge-ort by its own name (`-s ort`): as RECURSIVE */
|
|
75
|
+
ORT = "ort",
|
|
76
|
+
|
|
74
77
|
/**
|
|
75
78
|
* Always take our side.
|
|
76
79
|
*
|
|
@@ -96,6 +99,12 @@ export enum MergeStrategy {
|
|
|
96
99
|
* Uses a single merge base.
|
|
97
100
|
*/
|
|
98
101
|
RESOLVE = "resolve",
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* git's subtree strategy: merge-ort with the other side (and the base) shifted to match
|
|
105
|
+
* ours' tree shape (`match-trees.c`'s shift_tree); never a fast-forward.
|
|
106
|
+
*/
|
|
107
|
+
SUBTREE = "subtree",
|
|
99
108
|
}
|
|
100
109
|
|
|
101
110
|
/**
|
|
@@ -13,6 +13,8 @@ export interface PullResult {
|
|
|
13
13
|
* fetching (`rebaseResult` then holds git's refusal, `UNCOMMITTED_CHANGES`)
|
|
14
14
|
*/
|
|
15
15
|
fetchResult?: FetchResult;
|
|
16
|
+
/** Every remote's fetch of a `--all` pull over several remotes (`fetchResult` is the last) */
|
|
17
|
+
fetchResults?: FetchResult[];
|
|
16
18
|
/** Result of the merge phase (if applicable; also the fast-forward of a rebasing pull) */
|
|
17
19
|
mergeResult?: MergeResult;
|
|
18
20
|
/**
|
|
@@ -22,6 +24,11 @@ export interface PullResult {
|
|
|
22
24
|
rebaseResult?: RebaseResult;
|
|
23
25
|
/** Whether rebase was used instead of merge */
|
|
24
26
|
rebaseUsed: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* `--recurse-submodules` / `submodule.recurse`: what the submodules' `git submodule update
|
|
29
|
+
* --recursive --checkout|--rebase` printed and its exit status (the pull's, when it failed)
|
|
30
|
+
*/
|
|
31
|
+
submodules?: { stdout: string; stderr: string; exitCode: number };
|
|
25
32
|
/** Whether pull was successful */
|
|
26
33
|
successful: boolean;
|
|
27
34
|
/** Fetch-from remote */
|
|
@@ -118,6 +118,11 @@ export interface PushResult {
|
|
|
118
118
|
* '<remote>'`; absent when none. Under `--porcelain` git prints them before `Done`.
|
|
119
119
|
*/
|
|
120
120
|
upstreamMessages?: string[];
|
|
121
|
+
/**
|
|
122
|
+
* `--recurse-submodules`: what the submodules' pushes printed on stderr before this push's
|
|
123
|
+
* report (`Pushing submodule '<path>'`, each push's report), git's order
|
|
124
|
+
*/
|
|
125
|
+
submoduleOutput?: string;
|
|
121
126
|
/**
|
|
122
127
|
* The push failed although every ref's status says otherwise: the server's report broke
|
|
123
128
|
* git's rules (an `option` line without its `ok`; git exits 1, its porcelain output has no
|
|
@@ -9,7 +9,7 @@ import { quoteCStyleBody } from "./quote-path.js";
|
|
|
9
9
|
* worktree against the index). `" "` unchanged, `M` modified, `T` type changed, `A` added,
|
|
10
10
|
* `D` deleted, `R` renamed, `U` unmerged, `?` untracked, `!` ignored.
|
|
11
11
|
*/
|
|
12
|
-
export type StatusCode = " " | "M" | "T" | "A" | "D" | "R" | "U" | "?" | "!";
|
|
12
|
+
export type StatusCode = " " | "M" | "T" | "A" | "D" | "R" | "C" | "U" | "?" | "!";
|
|
13
13
|
|
|
14
14
|
/** A side of a path: its mode and object id. */
|
|
15
15
|
export interface StatusSide {
|
|
@@ -282,7 +282,7 @@ export function formatStatusPorcelain(
|
|
|
282
282
|
octal(e.worktreeMode),
|
|
283
283
|
e.head?.id ?? ZERO_ID,
|
|
284
284
|
e.staged?.id ?? ZERO_ID,
|
|
285
|
-
|
|
285
|
+
`${e.index === "C" || e.worktree === "C" ? "C" : "R"}${e.renameScore ?? 100}`,
|
|
286
286
|
`${path}${z ? "\0" : "\t"}${from}`,
|
|
287
287
|
].join(" "),
|
|
288
288
|
);
|
package/src/transport-command.ts
CHANGED
|
@@ -84,9 +84,7 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
84
84
|
if (!promisor) return undefined;
|
|
85
85
|
const previous = promisor.fetcher;
|
|
86
86
|
const fetcher = createPromisorFetcher(this._workingCopy, {
|
|
87
|
-
...
|
|
88
|
-
...(this.credentials ? { credentials: this.credentials } : {}),
|
|
89
|
-
...(this.headers ? { headers: this.headers } : {}),
|
|
87
|
+
...this.promisorFetcherAuth(),
|
|
90
88
|
...(this.timeout !== undefined ? { timeout: this.timeout } : {}),
|
|
91
89
|
});
|
|
92
90
|
promisor.setFetcher(fetcher);
|
|
@@ -96,6 +94,22 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
96
94
|
});
|
|
97
95
|
}
|
|
98
96
|
|
|
97
|
+
/**
|
|
98
|
+
* What a lazy fetch during the call reaches the promisor remote with: this command's
|
|
99
|
+
* transports, credentials and headers.
|
|
100
|
+
*/
|
|
101
|
+
protected promisorFetcherAuth(): {
|
|
102
|
+
transports?: GitTransportRegistry;
|
|
103
|
+
credentials?: Credentials;
|
|
104
|
+
headers?: Record<string, string>;
|
|
105
|
+
} {
|
|
106
|
+
return {
|
|
107
|
+
...(this.transportRegistry ? { transports: this.transportRegistry } : {}),
|
|
108
|
+
...(this.credentials ? { credentials: this.credentials } : {}),
|
|
109
|
+
...(this.headers ? { headers: this.headers } : {}),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
99
113
|
/**
|
|
100
114
|
* Set the transports non-local remotes are reached through: the registry's connector for a
|
|
101
115
|
* URL opens the session (default `createDefaultTransports()`: smart HTTP over the global
|
|
@@ -246,6 +260,23 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
246
260
|
return store.value(`remote.${remote}.${key}`);
|
|
247
261
|
}
|
|
248
262
|
|
|
263
|
+
/**
|
|
264
|
+
* Gives a command this one runs (git's child `git fetch`) this command's transports,
|
|
265
|
+
* credentials, headers, timeout, progress callbacks and hook session.
|
|
266
|
+
*/
|
|
267
|
+
protected configureChild<C extends TransportCommand<unknown>>(child: C): C {
|
|
268
|
+
child.shareHooksOf(this);
|
|
269
|
+
child.setTransports(this.getTransports());
|
|
270
|
+
if (this.credentials) child.setCredentials(this.credentials);
|
|
271
|
+
if (this.headers) child.setHeaders(this.headers);
|
|
272
|
+
if (this.timeout) child.setTimeout(this.timeout);
|
|
273
|
+
if (this.gzipRequests !== undefined) child.setGzipRequests(this.gzipRequests);
|
|
274
|
+
if (this.progressCallback) child.setProgressMonitor(this.progressCallback);
|
|
275
|
+
if (this.progressMessageCallback)
|
|
276
|
+
child.setProgressMessageCallback(this.progressMessageCallback);
|
|
277
|
+
return child;
|
|
278
|
+
}
|
|
279
|
+
|
|
249
280
|
/**
|
|
250
281
|
* Get transport options for passing to transport operations.
|
|
251
282
|
*/
|