@statewalker/vcs-commands 0.13.0 → 0.15.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.map +1 -1
- package/dist/commands/add-patch/patch-backend.d.ts +1 -1
- package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
- package/dist/commands/archive/archive-command.d.ts +6 -2
- package/dist/commands/archive/archive-command.d.ts.map +1 -1
- package/dist/commands/archive/remote-archive-command.d.ts +27 -2
- package/dist/commands/archive/remote-archive-command.d.ts.map +1 -1
- package/dist/commands/archive/upload-archive-writer.d.ts +11 -5
- package/dist/commands/archive/upload-archive-writer.d.ts.map +1 -1
- package/dist/commands/branch-command.d.ts +14 -2
- package/dist/commands/branch-command.d.ts.map +1 -1
- package/dist/commands/bundle/bundle-format.d.ts +6 -1
- package/dist/commands/bundle/bundle-format.d.ts.map +1 -1
- package/dist/commands/bundle/bundle-uri-host.d.ts +12 -1
- package/dist/commands/bundle/bundle-uri-host.d.ts.map +1 -1
- package/dist/commands/bundle/bundle-uri.d.ts +7 -1
- package/dist/commands/bundle/bundle-uri.d.ts.map +1 -1
- package/dist/commands/bundle/bundle-verify.d.ts +4 -1
- package/dist/commands/bundle/bundle-verify.d.ts.map +1 -1
- package/dist/commands/cat-file/batch-format.d.ts +8 -12
- package/dist/commands/cat-file/batch-format.d.ts.map +1 -1
- package/dist/commands/cat-file/cat-file-command.d.ts +39 -5
- package/dist/commands/cat-file/cat-file-command.d.ts.map +1 -1
- package/dist/commands/check-ignore-command.d.ts.map +1 -1
- package/dist/commands/checkout-command.d.ts +4 -0
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/checkout-paths.d.ts +9 -0
- package/dist/commands/checkout-paths.d.ts.map +1 -1
- package/dist/commands/cherry-pick-command.d.ts +3 -0
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-interactive.d.ts +0 -9
- package/dist/commands/clean-interactive.d.ts.map +1 -1
- package/dist/commands/clone-command.d.ts +17 -0
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/column/column-config.d.ts +23 -0
- package/dist/commands/column/column-config.d.ts.map +1 -0
- package/dist/commands/column/column-layout.d.ts +129 -0
- package/dist/commands/column/column-layout.d.ts.map +1 -0
- package/dist/commands/column/index.d.ts +3 -0
- package/dist/commands/column/index.d.ts.map +1 -0
- package/dist/commands/column-command.d.ts +59 -0
- package/dist/commands/column-command.d.ts.map +1 -0
- package/dist/commands/comment-char-config.d.ts +15 -0
- package/dist/commands/comment-char-config.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +30 -2
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/config-command.d.ts +12 -0
- package/dist/commands/config-command.d.ts.map +1 -1
- package/dist/commands/credential-helper.d.ts +214 -0
- package/dist/commands/credential-helper.d.ts.map +1 -0
- package/dist/commands/default-branch.d.ts +33 -3
- package/dist/commands/default-branch.d.ts.map +1 -1
- package/dist/commands/diff-color-config.d.ts +4 -0
- package/dist/commands/diff-color-config.d.ts.map +1 -1
- package/dist/commands/diff-command.d.ts +12 -0
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/fast-export/fast-export-command.d.ts +89 -2
- package/dist/commands/fast-export/fast-export-command.d.ts.map +1 -1
- package/dist/commands/fast-export/fast-import-command.d.ts +113 -8
- package/dist/commands/fast-export/fast-import-command.d.ts.map +1 -1
- package/dist/commands/fast-export/fast-stream-support.d.ts +0 -9
- package/dist/commands/fast-export/fast-stream-support.d.ts.map +1 -1
- package/dist/commands/fetch-command.d.ts +23 -1
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-object-checks.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +31 -3
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/history-command.d.ts +173 -7
- package/dist/commands/history-command.d.ts.map +1 -1
- package/dist/commands/index-host.d.ts +19 -0
- package/dist/commands/index-host.d.ts.map +1 -1
- package/dist/commands/index-refresh.d.ts +36 -0
- package/dist/commands/index-refresh.d.ts.map +1 -0
- package/dist/commands/index.d.ts +9 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +7 -6
- package/dist/commands/init-command.d.ts +20 -0
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/local-transport.d.ts +40 -2
- package/dist/commands/local-transport.d.ts.map +1 -1
- package/dist/commands/log-command.d.ts +7 -0
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +11 -0
- package/dist/commands/log-output.d.ts.map +1 -1
- package/dist/commands/ls-tree-command.d.ts +10 -0
- package/dist/commands/ls-tree-command.d.ts.map +1 -1
- package/dist/commands/maintenance-schedule-command.d.ts +122 -0
- package/dist/commands/maintenance-schedule-command.d.ts.map +1 -0
- package/dist/commands/merge-command.d.ts +13 -1
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-index-command.d.ts +42 -0
- package/dist/commands/merge-index-command.d.ts.map +1 -0
- package/dist/commands/merge-one-file.d.ts +129 -0
- package/dist/commands/merge-one-file.d.ts.map +1 -0
- package/dist/commands/merge-support.d.ts +40 -4
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/object-disk-info.d.ts +35 -0
- package/dist/commands/object-disk-info.d.ts.map +1 -0
- package/dist/commands/octopus-merge.d.ts +3 -3
- package/dist/commands/octopus-merge.d.ts.map +1 -1
- package/dist/commands/plumbing-input.d.ts.map +1 -1
- package/dist/commands/promisor-remote-reply.d.ts +31 -4
- package/dist/commands/promisor-remote-reply.d.ts.map +1 -1
- package/dist/commands/promisor-remote.d.ts +8 -1
- package/dist/commands/promisor-remote.d.ts.map +1 -1
- package/dist/commands/pull-command.d.ts +55 -7
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +18 -1
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/range-diff/range-diff-command.d.ts +37 -1
- package/dist/commands/range-diff/range-diff-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +13 -1
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/ref-filter/for-each-ref-command.d.ts +3 -2
- package/dist/commands/ref-filter/for-each-ref-command.d.ts.map +1 -1
- package/dist/commands/ref-filter/index.d.ts +1 -0
- package/dist/commands/ref-filter/index.d.ts.map +1 -1
- package/dist/commands/ref-filter/peel-limit.d.ts +8 -0
- package/dist/commands/ref-filter/peel-limit.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-filter.d.ts.map +1 -1
- package/dist/commands/ref-filter/ref-format.d.ts +26 -1
- package/dist/commands/ref-filter/ref-format.d.ts.map +1 -1
- package/dist/commands/ref-filter/ref-listing-command.d.ts +9 -0
- package/dist/commands/ref-filter/ref-listing-command.d.ts.map +1 -1
- package/dist/commands/remote-transport.d.ts +27 -0
- package/dist/commands/remote-transport.d.ts.map +1 -1
- package/dist/commands/repack-command.d.ts +18 -2
- package/dist/commands/repack-command.d.ts.map +1 -1
- package/dist/commands/repo-command.d.ts +2 -7
- package/dist/commands/repo-command.d.ts.map +1 -1
- package/dist/commands/reset-command.d.ts +4 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts.map +1 -1
- package/dist/commands/rev-list-command.d.ts +65 -0
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +3 -0
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-filenames.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +17 -0
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +12 -0
- package/dist/commands/revision-resolver.d.ts.map +1 -1
- package/dist/commands/serve-repository.d.ts +21 -4
- package/dist/commands/serve-repository.d.ts.map +1 -1
- package/dist/commands/served-lazy-fetch.d.ts +61 -0
- package/dist/commands/served-lazy-fetch.d.ts.map +1 -0
- package/dist/commands/signing.d.ts +37 -4
- package/dist/commands/signing.d.ts.map +1 -1
- package/dist/commands/split-cmdline.d.ts +6 -0
- package/dist/commands/split-cmdline.d.ts.map +1 -0
- package/dist/commands/status-color-config.d.ts +33 -0
- package/dist/commands/status-color-config.d.ts.map +1 -0
- package/dist/commands/status-command.d.ts +15 -0
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/status-format.d.ts +46 -4
- package/dist/commands/status-format.d.ts.map +1 -1
- package/dist/commands/tag-command.d.ts +15 -1
- package/dist/commands/tag-command.d.ts.map +1 -1
- package/dist/commands/tree-restore.d.ts +14 -0
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/verify-command.d.ts +22 -2
- package/dist/commands/verify-command.d.ts.map +1 -1
- package/dist/commands/worktree-add-command.d.ts.map +1 -1
- package/dist/commands/worktree-overwrite-checks.d.ts +31 -6
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
- package/dist/{commands-CPceUCP2.js → commands-DT3VEv50.js} +15168 -16842
- package/dist/errors/commit-errors.d.ts +37 -1
- package/dist/errors/commit-errors.d.ts.map +1 -1
- package/dist/errors/git-api-error.d.ts +6 -0
- package/dist/errors/git-api-error.d.ts.map +1 -1
- package/dist/errors/index.js +44 -3
- package/dist/{fsck-tbrPZX2q.js → fsck-BZ508Elg.js} +2 -2
- package/dist/git-command.d.ts +33 -1
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +104 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/index.js +8 -7
- package/dist/{remote-transport-C0OSJtor.js → local-transport-D98U6p4d.js} +228 -692
- package/dist/{maintenance-run-command-UiSIaeP8.js → maintenance-run-command-DZFnbnbo.js} +2366 -108
- package/dist/remote-config/remote-config-store.d.ts +6 -0
- package/dist/remote-config/remote-config-store.d.ts.map +1 -1
- package/dist/remote-transport-zvSqwpOB.js +4865 -0
- package/dist/results/cherry-pick-result.d.ts +4 -3
- package/dist/results/cherry-pick-result.d.ts.map +1 -1
- package/dist/results/diff-output.d.ts +7 -0
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/diff-words.d.ts +14 -3
- package/dist/results/diff-words.d.ts.map +1 -1
- package/dist/results/index.js +1 -1
- package/dist/results/line-prefix-sink.d.ts +50 -0
- package/dist/results/line-prefix-sink.d.ts.map +1 -0
- package/dist/results/merge-result.d.ts +4 -3
- package/dist/results/merge-result.d.ts.map +1 -1
- package/dist/results/rebase-result.d.ts +5 -0
- package/dist/results/rebase-result.d.ts.map +1 -1
- package/dist/results/revert-result.d.ts +4 -3
- package/dist/results/revert-result.d.ts.map +1 -1
- package/dist/{results-CkS1p1CH.js → results-rF81cQse.js} +1788 -247
- package/dist/transport-command.d.ts +13 -0
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +21 -13
- package/src/commands/add-command.ts +15 -2
- package/src/commands/add-patch/patch-backend.ts +6 -44
- package/src/commands/archive/archive-command.ts +7 -3
- package/src/commands/archive/remote-archive-command.ts +45 -4
- package/src/commands/archive/upload-archive-writer.ts +34 -22
- package/src/commands/branch-command.ts +57 -4
- package/src/commands/bundle/bundle-format.ts +10 -2
- package/src/commands/bundle/bundle-uri-host.ts +71 -11
- package/src/commands/bundle/bundle-uri.ts +11 -4
- package/src/commands/bundle/bundle-verify.ts +4 -1
- package/src/commands/cat-file/batch-format.ts +17 -18
- package/src/commands/cat-file/cat-file-command.ts +182 -48
- package/src/commands/check-ignore-command.ts +110 -21
- package/src/commands/checkout-command.ts +149 -21
- package/src/commands/checkout-index-command.ts +2 -1
- package/src/commands/checkout-paths.ts +13 -0
- package/src/commands/cherry-pick-command.ts +9 -0
- package/src/commands/clean-interactive.ts +20 -74
- package/src/commands/clone-command.ts +102 -11
- package/src/commands/column/column-config.ts +63 -0
- package/src/commands/column/column-layout.ts +396 -0
- package/src/commands/column/index.ts +2 -0
- package/src/commands/column-command.ts +171 -0
- package/src/commands/comment-char-config.ts +42 -0
- package/src/commands/commit-command.ts +93 -18
- package/src/commands/config-command.ts +28 -0
- package/src/commands/credential-helper.ts +807 -0
- package/src/commands/default-branch.ts +57 -5
- package/src/commands/diff-color-config.ts +23 -10
- package/src/commands/diff-command.ts +25 -2
- package/src/commands/fast-export/fast-export-command.ts +661 -35
- package/src/commands/fast-export/fast-import-command.ts +694 -94
- package/src/commands/fast-export/fast-stream-support.ts +18 -1
- package/src/commands/fetch-command.ts +116 -16
- package/src/commands/fsck/fsck-object-checks.ts +3 -1
- package/src/commands/git-hooks.ts +96 -5
- package/src/commands/history-command.ts +952 -20
- package/src/commands/index-host.ts +51 -0
- package/src/commands/index-refresh.ts +121 -0
- package/src/commands/index.ts +9 -0
- package/src/commands/init-command.ts +57 -4
- package/src/commands/legacy-remotes.ts +4 -20
- package/src/commands/local-transport.ts +183 -18
- package/src/commands/log-command.ts +39 -1
- package/src/commands/log-output.ts +31 -4
- package/src/commands/ls-tree-command.ts +20 -12
- package/src/commands/maintenance-schedule-command.ts +418 -0
- package/src/commands/merge-command.ts +42 -8
- package/src/commands/merge-index-command.ts +202 -0
- package/src/commands/merge-one-file.ts +451 -0
- package/src/commands/merge-support.ts +169 -15
- package/src/commands/object-disk-info.ts +169 -0
- package/src/commands/octopus-merge.ts +37 -128
- package/src/commands/plumbing-input.ts +3 -1
- package/src/commands/promisor-remote-reply.ts +338 -56
- package/src/commands/promisor-remote.ts +39 -6
- package/src/commands/pull-command.ts +173 -27
- package/src/commands/push-command.ts +55 -6
- package/src/commands/range-diff/range-diff-command.ts +86 -3
- package/src/commands/read-tree-command.ts +2 -2
- package/src/commands/rebase-command.ts +46 -1
- package/src/commands/ref-filter/for-each-ref-command.ts +4 -3
- package/src/commands/ref-filter/index.ts +1 -0
- package/src/commands/ref-filter/peel-limit.ts +7 -0
- package/src/commands/ref-filter/ref-filter.ts +68 -7
- package/src/commands/ref-filter/ref-format.ts +85 -11
- package/src/commands/ref-filter/ref-listing-command.ts +30 -0
- package/src/commands/remote-command.ts +2 -2
- package/src/commands/remote-transport.ts +66 -3
- package/src/commands/repack-command.ts +75 -9
- package/src/commands/repo-command.ts +6 -70
- package/src/commands/reset-command.ts +11 -1
- package/src/commands/restore-command.ts +1 -0
- package/src/commands/rev-list-command.ts +205 -3
- package/src/commands/revert-command.ts +9 -0
- package/src/commands/revision-filenames.ts +32 -4
- package/src/commands/revision-range.ts +2 -2
- package/src/commands/revision-resolver.ts +21 -1
- package/src/commands/serve-repository.ts +42 -11
- package/src/commands/served-lazy-fetch.ts +164 -0
- package/src/commands/signing.ts +103 -12
- package/src/commands/split-cmdline.ts +32 -0
- package/src/commands/status-color-config.ts +92 -0
- package/src/commands/status-command.ts +50 -2
- package/src/commands/status-format.ts +198 -50
- package/src/commands/tag-command.ts +57 -2
- package/src/commands/tree-restore.ts +17 -0
- package/src/commands/verify-command.ts +84 -12
- package/src/commands/worktree-add-command.ts +2 -0
- package/src/commands/worktree-overwrite-checks.ts +75 -14
- package/src/errors/commit-errors.ts +52 -2
- package/src/errors/git-api-error.ts +7 -0
- package/src/git-command.ts +105 -4
- package/src/git.ts +153 -0
- package/src/remote-config/remote-config-store.ts +16 -0
- package/src/results/cherry-pick-result.ts +4 -3
- package/src/results/diff-output.ts +8 -0
- package/src/results/diff-words.ts +160 -32
- package/src/results/line-prefix-sink.ts +102 -0
- package/src/results/merge-result.ts +4 -3
- package/src/results/rebase-result.ts +5 -0
- package/src/results/revert-result.ts +4 -3
- package/src/transport-command.ts +79 -3
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where diff.c's `diff_line_prefix` (the graph's padding under `log --graph`) goes in a diff
|
|
3
|
+
* output: a sink recording a position before every line pushed to it, except in the bytes a
|
|
4
|
+
* writer marks as placing the prefix itself (git's word diff writes it only where
|
|
5
|
+
* `fn_out_diff_words_write_helper` and `color_words_output_graph_prefix` put it). The log
|
|
6
|
+
* inserts the prefix afterwards ({@link insertLinePrefix}), once its graph has printed the
|
|
7
|
+
* commit's header and the padding is known.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const sink = new LinePrefixSink();
|
|
12
|
+
* sink.text("diff --git a/f b/f\n");
|
|
13
|
+
* sink.push(markLinePrefix(encodeGitPath("-old\n"), { before: 0, own: true }));
|
|
14
|
+
* insertLinePrefix(sink.bytes(), sink.points, encodeGitPath("| ")); // "| diff --git a/f b/f\n-old\n"
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* Marks follow the chunk itself (a `WeakMap` of arrays), so they survive a sink that holds
|
|
18
|
+
* chunks before passing them on unchanged (`MovedLineBuffer`), but not one that joins them.
|
|
19
|
+
*
|
|
20
|
+
* @module
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { ByteSink } from "@statewalker/vcs-utils";
|
|
24
|
+
|
|
25
|
+
/** Where a marked chunk has the line prefix */
|
|
26
|
+
export interface LinePrefixMark {
|
|
27
|
+
/** How many prefixes go right before the chunk */
|
|
28
|
+
before: number;
|
|
29
|
+
/** The chunk places its prefixes itself: none at its line starts */
|
|
30
|
+
own: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const MARKS = new WeakMap<Uint8Array, LinePrefixMark>();
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Marks `bytes` for a {@link LinePrefixSink}. The mark belongs to the array object: mark a
|
|
37
|
+
* view of its own (`bytes.subarray(0)`) for each push of shared bytes.
|
|
38
|
+
*/
|
|
39
|
+
export function markLinePrefix(bytes: Uint8Array, mark: LinePrefixMark): Uint8Array {
|
|
40
|
+
MARKS.set(bytes, mark);
|
|
41
|
+
return bytes;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** A byte sink recording where the line prefix goes: each line start, marked chunks aside */
|
|
45
|
+
export class LinePrefixSink extends ByteSink {
|
|
46
|
+
/** The offsets in the output where a prefix goes, ascending (one offset may repeat) */
|
|
47
|
+
readonly points: number[] = [];
|
|
48
|
+
private offset = 0;
|
|
49
|
+
private atLineStart = true;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A prefix at the current end of the output, written straight to the file (diff.c's
|
|
53
|
+
* `fputs(line_prefix)`): ahead of what a `MovedLineBuffer` still holds
|
|
54
|
+
*/
|
|
55
|
+
addPoint(): void {
|
|
56
|
+
this.points.push(this.offset);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
override push(bytes: Uint8Array): void {
|
|
60
|
+
if (bytes.length === 0) return;
|
|
61
|
+
const mark = MARKS.get(bytes);
|
|
62
|
+
for (let i = 0; i < (mark?.before ?? 0); i++) this.points.push(this.offset);
|
|
63
|
+
if (mark?.own) {
|
|
64
|
+
super.push(bytes);
|
|
65
|
+
this.offset += bytes.length;
|
|
66
|
+
// whatever git writes next through emit_line_0 (a context line, a hunk header, the
|
|
67
|
+
// next file's header) starts with the prefix
|
|
68
|
+
this.atLineStart = true;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
super.push(bytes);
|
|
72
|
+
let at = 0;
|
|
73
|
+
while (at < bytes.length) {
|
|
74
|
+
if (this.atLineStart) this.points.push(this.offset + at);
|
|
75
|
+
const nl = bytes.indexOf(0x0a, at);
|
|
76
|
+
this.atLineStart = nl >= 0;
|
|
77
|
+
at = nl < 0 ? bytes.length : nl + 1;
|
|
78
|
+
}
|
|
79
|
+
this.offset += bytes.length;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** `bytes` with `prefix` inserted at each of `points` (ascending offsets) */
|
|
84
|
+
export function insertLinePrefix(
|
|
85
|
+
bytes: Uint8Array,
|
|
86
|
+
points: readonly number[],
|
|
87
|
+
prefix: Uint8Array,
|
|
88
|
+
): Uint8Array {
|
|
89
|
+
if (points.length === 0 || prefix.length === 0) return bytes;
|
|
90
|
+
const out = new Uint8Array(bytes.length + points.length * prefix.length);
|
|
91
|
+
let size = 0;
|
|
92
|
+
let from = 0;
|
|
93
|
+
for (const point of points) {
|
|
94
|
+
out.set(bytes.subarray(from, point), size);
|
|
95
|
+
size += point - from;
|
|
96
|
+
out.set(prefix, size);
|
|
97
|
+
size += prefix.length;
|
|
98
|
+
from = point;
|
|
99
|
+
}
|
|
100
|
+
out.set(bytes.subarray(from), size);
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
@@ -136,9 +136,10 @@ export interface MergeResult {
|
|
|
136
136
|
*/
|
|
137
137
|
readonly output?: string[];
|
|
138
138
|
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
139
|
+
* Warnings git printed on stderr, line by line: first git 2.5x's `core.commentChar=auto`
|
|
140
|
+
* deprecation warning and its advice, then what the sparse checkout printed while the
|
|
141
|
+
* result was written (the patterns' warnings, git's "The following paths are not up to
|
|
142
|
+
* date and were left despite sparse patterns:" block). Absent when there was nothing to say.
|
|
142
143
|
*/
|
|
143
144
|
readonly warnings?: string[];
|
|
144
145
|
/**
|
|
@@ -173,6 +173,11 @@ export interface RebaseResult {
|
|
|
173
173
|
* said nothing.
|
|
174
174
|
*/
|
|
175
175
|
readonly rerereOutput?: string[];
|
|
176
|
+
/**
|
|
177
|
+
* What git printed on stderr as it started, line by line: git 2.5x's
|
|
178
|
+
* `core.commentChar=auto` deprecation warning and its advice. Absent when it said nothing.
|
|
179
|
+
*/
|
|
180
|
+
readonly warnings?: string[];
|
|
176
181
|
}
|
|
177
182
|
|
|
178
183
|
/**
|
|
@@ -37,9 +37,10 @@ export interface RevertResult {
|
|
|
37
37
|
/** What is printed on stdout: merge-ort's `Auto-merging f`, `CONFLICT (...)` lines */
|
|
38
38
|
readonly output?: string[];
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
40
|
+
* Warnings git printed on stderr, line by line: first git 2.5x's `core.commentChar=auto`
|
|
41
|
+
* deprecation warning and its advice, then what the sparse checkout printed while the
|
|
42
|
+
* result was written (the patterns' warnings, git's "The following paths are not up to
|
|
43
|
+
* date and were left despite sparse patterns:" block). Absent when there was nothing to say.
|
|
43
44
|
*/
|
|
44
45
|
readonly warnings?: string[];
|
|
45
46
|
/**
|
package/src/transport-command.ts
CHANGED
|
@@ -6,18 +6,23 @@ import {
|
|
|
6
6
|
type HttpCredentialHelper,
|
|
7
7
|
type ProgressInfo,
|
|
8
8
|
} from "@statewalker/vcs-transport";
|
|
9
|
+
import type { ObjectFormat } from "@statewalker/vcs-utils/hash";
|
|
9
10
|
import type { WorkingCopy } from "@statewalker/vcs-working-tree";
|
|
10
11
|
import {
|
|
11
12
|
type BundleUriHost,
|
|
12
13
|
createBundleUriHost,
|
|
13
14
|
fetchBundleUri,
|
|
14
15
|
} from "./commands/bundle/index.js";
|
|
16
|
+
import { configuresCredentialHelper, credentialHelperOf } from "./commands/credential-helper.js";
|
|
17
|
+
import { hookRunnerOf } from "./commands/git-hooks.js";
|
|
15
18
|
import { hostEnvironmentOf } from "./commands/git-ident.js";
|
|
16
19
|
import { httpClientSettingsOf } from "./commands/http-config.js";
|
|
20
|
+
import { remoteHookSession } from "./commands/local-transport.js";
|
|
17
21
|
import { createPromisorFetcher, promisorOf } from "./commands/promisor-remote.js";
|
|
18
22
|
import {
|
|
19
23
|
bundleRemoteOf,
|
|
20
24
|
httpSessionSettings,
|
|
25
|
+
localLazyFetchOf,
|
|
21
26
|
openResolvedRemote,
|
|
22
27
|
type PreparedRemote,
|
|
23
28
|
prepareRemote,
|
|
@@ -81,17 +86,21 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
81
86
|
protected credentialHelper?: HttpCredentialHelper;
|
|
82
87
|
/** git's `warning:` lines of the HTTP client */
|
|
83
88
|
protected warningCallback?: (line: string) => void;
|
|
89
|
+
/** The helper built from `credential.helper` for this command (see {@link httpCredentialHelper}) */
|
|
90
|
+
private configCredentialHelper?: HttpCredentialHelper | null;
|
|
84
91
|
|
|
85
92
|
constructor(workingCopy: WorkingCopy) {
|
|
86
93
|
super(workingCopy);
|
|
87
94
|
// a partial clone's lazy fetch during the call (a clone's checkout, a pull's merge) reaches
|
|
88
|
-
// the promisor remote as this command does: its transports, credentials, headers, timeout
|
|
95
|
+
// the promisor remote as this command does: its transports, credentials, headers, timeout,
|
|
96
|
+
// credential helper and warning sink;
|
|
89
97
|
// the store's previous fetcher comes back when the call ends
|
|
90
98
|
this.aroundEntryPoints(() => {
|
|
91
99
|
if (
|
|
92
100
|
!this.transportRegistry &&
|
|
93
101
|
!this.credentials &&
|
|
94
102
|
!this.headers &&
|
|
103
|
+
!this.credentialHelper &&
|
|
95
104
|
this.timeout === undefined
|
|
96
105
|
) {
|
|
97
106
|
return undefined;
|
|
@@ -102,6 +111,10 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
102
111
|
const fetcher = createPromisorFetcher(this._workingCopy, {
|
|
103
112
|
...this.promisorFetcherAuth(),
|
|
104
113
|
...(this.timeout !== undefined ? { timeout: this.timeout } : {}),
|
|
114
|
+
// git's child fetch reads credential.helper: the helper is asked per URL, so the
|
|
115
|
+
// guarded commands hand it over too
|
|
116
|
+
...(this.credentialHelper ? { credentialHelper: this.credentialHelper } : {}),
|
|
117
|
+
...(this.warningCallback ? { warningCallback: this.warningCallback } : {}),
|
|
105
118
|
});
|
|
106
119
|
promisor.setFetcher(fetcher);
|
|
107
120
|
return () => {
|
|
@@ -232,6 +245,24 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
232
245
|
return this;
|
|
233
246
|
}
|
|
234
247
|
|
|
248
|
+
/**
|
|
249
|
+
* The credential helper this command's HTTP requests ask: the one given to
|
|
250
|
+
* {@link setCredentialHelper}, else, when the configuration names a `credential.helper`
|
|
251
|
+
* and the host has a hook runner, git's helpers of that configuration (credential.c through
|
|
252
|
+
* {@link credentialHelperOf}: their stderr in the hook output), as git's transports read
|
|
253
|
+
* them; else none.
|
|
254
|
+
*/
|
|
255
|
+
protected httpCredentialHelper(): HttpCredentialHelper | undefined {
|
|
256
|
+
if (this.credentialHelper) return this.credentialHelper;
|
|
257
|
+
if (this.configCredentialHelper === undefined) {
|
|
258
|
+
this.configCredentialHelper =
|
|
259
|
+
hookRunnerOf(this._workingCopy) && configuresCredentialHelper(this._workingCopy)
|
|
260
|
+
? credentialHelperOf(this._workingCopy, { hooks: this.hooks })
|
|
261
|
+
: null;
|
|
262
|
+
}
|
|
263
|
+
return this.configCredentialHelper ?? undefined;
|
|
264
|
+
}
|
|
265
|
+
|
|
235
266
|
/**
|
|
236
267
|
* Receives the `warning:` lines git's HTTP client prints on stderr (`rate limited, waiting
|
|
237
268
|
* <n> seconds before retry`).
|
|
@@ -349,8 +380,23 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
349
380
|
...(this.gzipRequests !== undefined ? { gzipRequests: this.gzipRequests } : {}),
|
|
350
381
|
protocolVersion: protocolVersionOf(RemoteConfigStore.from(this._workingCopy)),
|
|
351
382
|
httpSettings: (url) => this.httpSettingsFor(url),
|
|
352
|
-
...(this.
|
|
383
|
+
...credentialHelperOption(this.httpCredentialHelper()),
|
|
353
384
|
...httpSessionSettings(this._workingCopy),
|
|
385
|
+
// a local remote's upload-pack runs the protected uploadpack.packObjectsHook through
|
|
386
|
+
// this host's runner, in the remote's git directory, with local_repo_env cleared
|
|
387
|
+
localHooks: (remote) => remoteHookSession(this._workingCopy, remote, { localPush: true }),
|
|
388
|
+
// GIT_NAMESPACE: what a local remote's upload-pack and receive-pack serve
|
|
389
|
+
...(() => {
|
|
390
|
+
const namespace = hostEnvironmentOf(this._workingCopy)?.namespace;
|
|
391
|
+
return namespace ? { namespace } : {};
|
|
392
|
+
})(),
|
|
393
|
+
// GIT_NO_LAZY_FETCH=0: a local remote's upload-pack fetches what it lacks
|
|
394
|
+
...localLazyFetchOf(hostEnvironmentOf(this._workingCopy), {
|
|
395
|
+
transports: this.getTransports(),
|
|
396
|
+
...(this.credentialHelper ? { credentialHelper: this.credentialHelper } : {}),
|
|
397
|
+
...(this.timeout !== undefined ? { timeout: this.timeout } : {}),
|
|
398
|
+
...(this.warningCallback ? { warningCallback: this.warningCallback } : {}),
|
|
399
|
+
}),
|
|
354
400
|
};
|
|
355
401
|
}
|
|
356
402
|
|
|
@@ -398,10 +444,33 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
398
444
|
message(line: string): void;
|
|
399
445
|
setConfigValue?(key: string, value: string): Promise<void>;
|
|
400
446
|
tempFileName?(): string;
|
|
447
|
+
/** The hash bundle headers are read in (default the repository's) */
|
|
448
|
+
objectFormat?: ObjectFormat;
|
|
401
449
|
}): BundleUriHost {
|
|
402
450
|
const store = RemoteConfigStore.from(this._workingCopy);
|
|
403
451
|
const worktree = repositoryPlaceOf(this._workingCopy);
|
|
452
|
+
const environment = hostEnvironmentOf(this._workingCopy);
|
|
404
453
|
return createBundleUriHost({
|
|
454
|
+
...(options.objectFormat ? { objectFormat: options.objectFormat } : {}),
|
|
455
|
+
// git 2.46+'s unbundle_from_file: VERIFY_BUNDLE_FSCK under fetch_pack_fsck_objects, an
|
|
456
|
+
// index-pack --fsck-objects given no message types (fetch.fsck.* is not read)
|
|
457
|
+
...(options.compatibility !== "2.43"
|
|
458
|
+
? {
|
|
459
|
+
fsckObjects: async () => {
|
|
460
|
+
const { fetchFsckOf } = await import("./commands/fsck/index.js");
|
|
461
|
+
return fetchFsckOf({
|
|
462
|
+
value: (key) => (/^fetch\.fsck\./i.test(key) ? undefined : store.value(key)),
|
|
463
|
+
compatibility: options.compatibility,
|
|
464
|
+
...(environment
|
|
465
|
+
? {
|
|
466
|
+
readFile: (path: string) => environment.readFile(path),
|
|
467
|
+
home: environment.home,
|
|
468
|
+
}
|
|
469
|
+
: {}),
|
|
470
|
+
});
|
|
471
|
+
},
|
|
472
|
+
}
|
|
473
|
+
: {}),
|
|
405
474
|
workingCopy: this._workingCopy,
|
|
406
475
|
setRef: (name, id, log) => this.refsStore.set(name, id, log),
|
|
407
476
|
getRef: async (name) => (await this.refsStore.resolve(name).catch(() => undefined))?.objectId,
|
|
@@ -411,7 +480,7 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
411
480
|
...(options.remoteUrl !== undefined ? { remoteUrl: options.remoteUrl } : {}),
|
|
412
481
|
...(this.credentials ? { credentials: this.credentials } : {}),
|
|
413
482
|
...(this.headers ? { headers: this.headers } : {}),
|
|
414
|
-
...(this.
|
|
483
|
+
...credentialHelperOption(this.httpCredentialHelper()),
|
|
415
484
|
httpSettings: (url) => this.httpSettingsFor(url),
|
|
416
485
|
configValue: (key) => store.value(key),
|
|
417
486
|
setConfigValue:
|
|
@@ -475,3 +544,10 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
475
544
|
};
|
|
476
545
|
}
|
|
477
546
|
}
|
|
547
|
+
|
|
548
|
+
/** The `credentialHelper` option of a session or host, when there is one. */
|
|
549
|
+
function credentialHelperOption(helper: HttpCredentialHelper | undefined): {
|
|
550
|
+
credentialHelper?: HttpCredentialHelper;
|
|
551
|
+
} {
|
|
552
|
+
return helper ? { credentialHelper: helper } : {};
|
|
553
|
+
}
|