@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
|
@@ -126,12 +126,29 @@ export function signatureStartOf(message: string, compatibility: "2.43" | "2.56"
|
|
|
126
126
|
* git.fastImport().setMarksFiles(marksFilesOf(files, { gitDir: ".git" })).setExportMarks("marks");
|
|
127
127
|
* ```
|
|
128
128
|
*/
|
|
129
|
+
/** `.` and `..` components resolved, as the host resolves a path git opens. */
|
|
130
|
+
function normalizePath(path: string): string {
|
|
131
|
+
const out: string[] = [];
|
|
132
|
+
for (const part of path.split("/")) {
|
|
133
|
+
if (part === "." || (part === "" && out.length > 0)) continue;
|
|
134
|
+
if (
|
|
135
|
+
part === ".." &&
|
|
136
|
+
out.length > 0 &&
|
|
137
|
+
out[out.length - 1] !== ".." &&
|
|
138
|
+
out[out.length - 1] !== ""
|
|
139
|
+
) {
|
|
140
|
+
out.pop();
|
|
141
|
+
} else out.push(part);
|
|
142
|
+
}
|
|
143
|
+
return out.join("/") || ".";
|
|
144
|
+
}
|
|
145
|
+
|
|
129
146
|
export function marksFilesOf(
|
|
130
147
|
files: FilesApi,
|
|
131
148
|
options: { cwd?: string; gitDir?: string } = {},
|
|
132
149
|
): FastMarksFiles {
|
|
133
150
|
const join = (dir: string | undefined, path: string) =>
|
|
134
|
-
path.startsWith("/") || !dir ? path : `${dir.replace(/\/+$/, "")}/${path}
|
|
151
|
+
normalizePath(path.startsWith("/") || !dir ? path : `${dir.replace(/\/+$/, "")}/${path}`);
|
|
135
152
|
const resolve = (path: string, relative?: boolean) =>
|
|
136
153
|
relative ? join(`${options.gitDir ?? ".git"}/info/fast-import`, path) : join(options.cwd, path);
|
|
137
154
|
return {
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
type FetchRefUpdate,
|
|
22
22
|
fetchFromConnection,
|
|
23
23
|
fetchRefcolWidth,
|
|
24
|
+
fetchResultOf,
|
|
24
25
|
fetchUpdateDisplay,
|
|
25
26
|
formatFetchDisplay,
|
|
26
27
|
formatFetchHead,
|
|
@@ -33,6 +34,7 @@ import {
|
|
|
33
34
|
ObjectFormatMismatchError,
|
|
34
35
|
parseRefSpec,
|
|
35
36
|
type RefSpec,
|
|
37
|
+
refusedRefOf,
|
|
36
38
|
type TagMode,
|
|
37
39
|
type FetchOptions as TransportFetchOptions,
|
|
38
40
|
transportSummaryWidth,
|
|
@@ -65,7 +67,11 @@ import {
|
|
|
65
67
|
promisorRemotes,
|
|
66
68
|
registerPartialClone,
|
|
67
69
|
} from "./promisor-remote.js";
|
|
68
|
-
import {
|
|
70
|
+
import {
|
|
71
|
+
promisorAutoFilter,
|
|
72
|
+
promisorRemoteReplyOf,
|
|
73
|
+
resetPromisorAcceptance,
|
|
74
|
+
} from "./promisor-remote-reply.js";
|
|
69
75
|
import { withRemoteUploadPack } from "./remote-transport.js";
|
|
70
76
|
import { clientSessionIdOf } from "./session-id.js";
|
|
71
77
|
import {
|
|
@@ -172,6 +178,7 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
172
178
|
private refetch = false;
|
|
173
179
|
/** `--negotiation-tip=<revision>` (a revision, or a ref glob), in order */
|
|
174
180
|
private negotiationTips: string[] = [];
|
|
181
|
+
private negotiationIncludes: string[] = [];
|
|
175
182
|
private negotiateOnlyMode = false;
|
|
176
183
|
private setUpstream = false;
|
|
177
184
|
/** `--[no-]recurse-submodules[=<mode>]`; unset: the configuration's */
|
|
@@ -441,7 +448,8 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
441
448
|
* (git's fetch_one_setup_partial); a filter given registers the remote as a promisor remote
|
|
442
449
|
* first when it is not one with a filter (partial_clone_register:
|
|
443
450
|
* `core.repositoryformatversion = 1`, `remote.<name>.promisor`, `.partialclonefilter`). A
|
|
444
|
-
* pack fetched under a filter is kept as a promisor pack.
|
|
451
|
+
* pack fetched under a filter is kept as a promisor pack. `auto` (git 2.54) is the filter
|
|
452
|
+
* the promisor remotes accepted from the server's `promisor-remote` capability advertise.
|
|
445
453
|
*/
|
|
446
454
|
setFilter(spec: string | false): this {
|
|
447
455
|
this.checkCallable();
|
|
@@ -485,6 +493,20 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
485
493
|
return this;
|
|
486
494
|
}
|
|
487
495
|
|
|
496
|
+
/**
|
|
497
|
+
* git 2.56's `git fetch --negotiation-include=<revision>`: these commits (a revision, or a
|
|
498
|
+
* glob of refs) are sent as `have` lines whatever the negotiator chooses, before its own;
|
|
499
|
+
* without any, the remote's `remote.<name>.negotiationInclude` values (an empty value
|
|
500
|
+
* clears the earlier ones). A revision naming nothing is skipped; a glob matching no ref is
|
|
501
|
+
* ignored with git's warning. git 2.43 has no such option: under its compatibility the call
|
|
502
|
+
* dies as git's option parser does (`unknown option`, exit 129).
|
|
503
|
+
*/
|
|
504
|
+
setNegotiationIncludes(...revisions: string[]): this {
|
|
505
|
+
this.checkCallable();
|
|
506
|
+
this.negotiationIncludes = [...revisions];
|
|
507
|
+
return this;
|
|
508
|
+
}
|
|
509
|
+
|
|
488
510
|
/**
|
|
489
511
|
* `git fetch --negotiate-only`: negotiates with the remote from {@link setNegotiationTips}
|
|
490
512
|
* (protocol v2, a server with `wait-for-done`) and fetches nothing; the commits the server
|
|
@@ -848,6 +870,12 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
848
870
|
async call(): Promise<FetchResult> {
|
|
849
871
|
this.checkCallable();
|
|
850
872
|
this.setCallable(false);
|
|
873
|
+
if (this.negotiationIncludes.length > 0 && this.negotiationCompatibility() === "2.43") {
|
|
874
|
+
throw new GitApiError(
|
|
875
|
+
`error: unknown option \`negotiation-include=${this.negotiationIncludes[0]}'`,
|
|
876
|
+
{ exitCode: 129 },
|
|
877
|
+
);
|
|
878
|
+
}
|
|
851
879
|
if (this.negotiateOnlyMode) {
|
|
852
880
|
// cmd_fetch: --negotiate-only never recurses, and needs a tip
|
|
853
881
|
if (this.recurseSubmodules === "yes" || this.recurseSubmodules === "on-demand") {
|
|
@@ -1022,7 +1050,15 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
1022
1050
|
const tipsGiven = this.negotiationTipsGiven();
|
|
1023
1051
|
const negotiationTips =
|
|
1024
1052
|
tipsGiven.length > 0 ? await this.resolveNegotiationTips(messages, tipsGiven) : undefined;
|
|
1053
|
+
// --negotiation-include (git 2.56): resolved after the restricting tips (prepare_transport)
|
|
1054
|
+
const includesGiven = this.negotiationIncludesGiven();
|
|
1055
|
+
const negotiationIncludes =
|
|
1056
|
+
includesGiven.length > 0
|
|
1057
|
+
? await this.resolveNegotiationTips(messages, includesGiven, "--negotiation-include")
|
|
1058
|
+
: undefined;
|
|
1025
1059
|
const unpackLimit = unpackLimitOf({ getAll: (key) => store.values(key) }, "fetch");
|
|
1060
|
+
// a new git process: no promisor remote accepted yet (--filter=auto, lazy-fetch order)
|
|
1061
|
+
resetPromisorAcceptance(this.workingCopy);
|
|
1026
1062
|
const fetchOptions: TransportFetchOptions = {
|
|
1027
1063
|
...(sessionId !== undefined ? { sessionId } : {}),
|
|
1028
1064
|
// fetch.uriProtocols: the packs a v2 server offloads to packfile URIs
|
|
@@ -1070,6 +1106,8 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
1070
1106
|
atomic: this.atomic || undefined,
|
|
1071
1107
|
// git 2.5x writes a fetch's refs in one transaction that refuses each on its own
|
|
1072
1108
|
...(compatibility !== "2.43" ? { batchNonAtomic: true } : {}),
|
|
1109
|
+
// do_fetch commits its transaction even with no update: 2.5x always, 2.43 with --atomic
|
|
1110
|
+
...(compatibility !== "2.43" || this.atomic ? { emptyTransaction: true } : {}),
|
|
1073
1111
|
dryRun: this.dryRun,
|
|
1074
1112
|
onProgress: this.progressMessageCallback,
|
|
1075
1113
|
// index-pack's "Receiving objects" and "Resolving deltas"
|
|
@@ -1106,10 +1144,13 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
1106
1144
|
...(this.refetch ? { refetch: true } : {}),
|
|
1107
1145
|
...(negotiationAlgorithm !== "consecutive" ? { negotiationAlgorithm } : {}),
|
|
1108
1146
|
...(negotiationTips ? { negotiationTips } : {}),
|
|
1147
|
+
...(negotiationIncludes?.length ? { negotiationIncludes } : {}),
|
|
1109
1148
|
// the transport's warnings (a filter the server ignores, the dumb walker's alternates)
|
|
1110
1149
|
onWarning: (line: string) => messages.push(line),
|
|
1111
1150
|
// the server's promisor-remote capability (promisor.acceptFromServer, storeFields)
|
|
1112
1151
|
promisorRemote: promisorRemoteReplyOf(this.workingCopy, (line) => messages.push(line)),
|
|
1152
|
+
// --filter=auto (or a recorded `auto`): the accepted promisor remotes' advertised filter
|
|
1153
|
+
autoFilter: () => promisorAutoFilter(this.workingCopy, (line) => messages.push(line)),
|
|
1113
1154
|
};
|
|
1114
1155
|
// --upload-pack, else remote.<name>.uploadpack (transport_get)
|
|
1115
1156
|
const uploadPack = this.uploadPack ?? this.remoteProgram(this.remote, "uploadpack");
|
|
@@ -1119,9 +1160,45 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
1119
1160
|
};
|
|
1120
1161
|
// git's fetch runs with fetch_if_missing = 0: its walks read through the history's view
|
|
1121
1162
|
// without lazy fetch (the facade above), never a store-wide switch
|
|
1163
|
+
// the FETCH_HEAD lines of a fetch, as git's get_ref_map marks them
|
|
1164
|
+
const markedOf = (result: FetchClientResult) =>
|
|
1165
|
+
this.fetchHeadEntries(result, {
|
|
1166
|
+
given: given.length,
|
|
1167
|
+
merge: mergeRefs,
|
|
1168
|
+
// explicit refspecs (and the HEAD of an unconfigured remote) are all to merge;
|
|
1169
|
+
// configured ones only when the first names one ref and no upstream is set
|
|
1170
|
+
explicit: !useConfig,
|
|
1171
|
+
firstIsExact: given.length > 0 && !parseRefSpec(given[0]).wildcard,
|
|
1172
|
+
hasMerge: upstream !== undefined,
|
|
1173
|
+
});
|
|
1122
1174
|
const result = await withRemoteUploadPack(remote, sessionOptions, (connection) =>
|
|
1123
1175
|
fetchFromConnection(connection, fetchOptions),
|
|
1124
|
-
).catch((error: unknown) => {
|
|
1176
|
+
).catch(async (error: unknown) => {
|
|
1177
|
+
// a refusing reference-transaction hook (git dies): without --atomic append_fetch_head
|
|
1178
|
+
// had written each line as the refs were stored, all of them before git 2.5x's one
|
|
1179
|
+
// transaction, those up to the refused ref's own in 2.43's one per ref; with --atomic
|
|
1180
|
+
// they wait for commit_fetch_head and FETCH_HEAD stays truncated (statewalker/webrun-vcs#503)
|
|
1181
|
+
const partial =
|
|
1182
|
+
error instanceof RefTransactionAbortedError ? fetchResultOf(error) : undefined;
|
|
1183
|
+
if (partial && writesFetchHead && !this.atomic && checkout?.writeFetchHead) {
|
|
1184
|
+
// in git's write order (store_updated_refs' two passes: the lines for merge first)
|
|
1185
|
+
const kept = (await markedOf(partial)).filter((e) => !e.shallowRejected);
|
|
1186
|
+
const marked = [
|
|
1187
|
+
...kept.filter((e) => !e.notForMerge),
|
|
1188
|
+
...kept.filter((e) => e.notForMerge),
|
|
1189
|
+
];
|
|
1190
|
+
const refusedRef = refusedRefOf(error);
|
|
1191
|
+
const at =
|
|
1192
|
+
refusedRef === undefined ? -1 : marked.findIndex((e) => e.localRef === refusedRef);
|
|
1193
|
+
const written = at < 0 ? marked : marked.slice(0, at + 1);
|
|
1194
|
+
await checkout.writeFetchHead(
|
|
1195
|
+
formatFetchHead(
|
|
1196
|
+
written.map(({ oid, remoteRef, notForMerge }) => ({ oid, remoteRef, notForMerge })),
|
|
1197
|
+
remoteUrl,
|
|
1198
|
+
),
|
|
1199
|
+
{ append: true },
|
|
1200
|
+
);
|
|
1201
|
+
}
|
|
1125
1202
|
// git dies on a source that names no remote ref (a hidden one included)
|
|
1126
1203
|
const message = error instanceof Error ? error.message : "";
|
|
1127
1204
|
if (message.startsWith("couldn't find remote ref ")) {
|
|
@@ -1155,15 +1232,7 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
1155
1232
|
// a failed --atomic transaction: git's error after the ref lines
|
|
1156
1233
|
if (result.refTransactionError !== undefined) errors.push(result.refTransactionError);
|
|
1157
1234
|
|
|
1158
|
-
const marked = await
|
|
1159
|
-
given: given.length,
|
|
1160
|
-
merge: mergeRefs,
|
|
1161
|
-
// explicit refspecs (and the HEAD of an unconfigured remote) are all to merge;
|
|
1162
|
-
// configured ones only when the first names one ref and no upstream is set
|
|
1163
|
-
explicit: !useConfig,
|
|
1164
|
-
firstIsExact: given.length > 0 && !parseRefSpec(given[0]).wildcard,
|
|
1165
|
-
hasMerge: upstream !== undefined,
|
|
1166
|
-
});
|
|
1235
|
+
const marked = await markedOf(result);
|
|
1167
1236
|
// store_updated_refs: a ref rejected for the shallow commits it needs is skipped, with
|
|
1168
1237
|
// git's warning when it is for merge
|
|
1169
1238
|
for (const e of marked) {
|
|
@@ -1288,9 +1357,33 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
1288
1357
|
if (this.negotiationTips.length > 0 || this.negotiationCompatibility() === "2.43") {
|
|
1289
1358
|
return this.negotiationTips;
|
|
1290
1359
|
}
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1360
|
+
return this.remoteTransportOption("negotiationRestrict");
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
/**
|
|
1364
|
+
* The `--negotiation-include` revisions given, else the remote's
|
|
1365
|
+
* `remote.<name>.negotiationInclude` values; none under git 2.43, which has neither.
|
|
1366
|
+
*/
|
|
1367
|
+
private negotiationIncludesGiven(): string[] {
|
|
1368
|
+
if (this.negotiationCompatibility() === "2.43") return [];
|
|
1369
|
+
if (this.negotiationIncludes.length > 0) return this.negotiationIncludes;
|
|
1370
|
+
return this.remoteTransportOption("negotiationInclude");
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
/**
|
|
1374
|
+
* A multi-valued `remote.<name>.<key>` as transport.c's parse_transport_option keeps it:
|
|
1375
|
+
* each value appended, an empty one clearing the list. git reads it for the remote named
|
|
1376
|
+
* as given, a URL or path too (remote_get makes a remote of that name).
|
|
1377
|
+
*/
|
|
1378
|
+
private remoteTransportOption(key: string): string[] {
|
|
1379
|
+
const list: string[] = [];
|
|
1380
|
+
for (const value of RemoteConfigStore.from(this.workingCopy).values(
|
|
1381
|
+
`remote.${this.remote}.${key}`,
|
|
1382
|
+
)) {
|
|
1383
|
+
if (value === "") list.length = 0;
|
|
1384
|
+
else list.push(value);
|
|
1385
|
+
}
|
|
1386
|
+
return list;
|
|
1294
1387
|
}
|
|
1295
1388
|
|
|
1296
1389
|
/**
|
|
@@ -1301,9 +1394,10 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
1301
1394
|
private async resolveNegotiationTips(
|
|
1302
1395
|
messages: string[],
|
|
1303
1396
|
given: readonly string[] = this.negotiationTips,
|
|
1397
|
+
optionName?: string,
|
|
1304
1398
|
): Promise<ObjectId[]> {
|
|
1305
1399
|
const legacy = this.negotiationCompatibility() === "2.43";
|
|
1306
|
-
const option = legacy ? "--negotiation-tip" : "--negotiation-restrict";
|
|
1400
|
+
const option = optionName ?? (legacy ? "--negotiation-tip" : "--negotiation-restrict");
|
|
1307
1401
|
const tips: ObjectId[] = [];
|
|
1308
1402
|
const glob = (text: string) => /[*?[\\]/.test(text);
|
|
1309
1403
|
const refs = given.some(glob)
|
|
@@ -1349,6 +1443,11 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
1349
1443
|
const messages: string[] = [...legacyMessages];
|
|
1350
1444
|
const given = this.negotiationTipsGiven();
|
|
1351
1445
|
const tips = await this.resolveNegotiationTips(messages, given);
|
|
1446
|
+
const includesGiven = this.negotiationIncludesGiven();
|
|
1447
|
+
const includes =
|
|
1448
|
+
includesGiven.length > 0
|
|
1449
|
+
? await this.resolveNegotiationTips(messages, includesGiven, "--negotiation-include")
|
|
1450
|
+
: [];
|
|
1352
1451
|
const remote = await this.prepareRemote(remoteUrl);
|
|
1353
1452
|
if (given.length === 0) {
|
|
1354
1453
|
throw new GitApiError("fatal: --negotiate-only needs one or more --negotiation-restrict=*", {
|
|
@@ -1377,6 +1476,7 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
1377
1476
|
negotiateOnly(connection, {
|
|
1378
1477
|
repository: createRepositoryFacade({ history: historyWithoutLazyFetch(history) }),
|
|
1379
1478
|
tips,
|
|
1479
|
+
...(includes.length > 0 ? { includes } : {}),
|
|
1380
1480
|
negotiationAlgorithm: algorithm,
|
|
1381
1481
|
shallow,
|
|
1382
1482
|
...(sessionId !== undefined ? { sessionId } : {}),
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
isNtfsGitWorktreeFile,
|
|
16
16
|
isValidRefName,
|
|
17
17
|
} from "@statewalker/vcs-core";
|
|
18
|
+
import { decodeGitPath } from "@statewalker/vcs-utils/encoding";
|
|
18
19
|
import { bytesToHex } from "@statewalker/vcs-utils/hash/utils";
|
|
19
20
|
|
|
20
21
|
import type { FsckMessageTypes, FsckMsgId } from "./fsck-msg-ids.js";
|
|
@@ -648,7 +649,8 @@ export function fsckTree(
|
|
|
648
649
|
}
|
|
649
650
|
if (!plain) {
|
|
650
651
|
const entryId = () => bytesToHex(buf.subarray(idAt, idAt + raw));
|
|
651
|
-
|
|
652
|
+
// git's bytes: a byte outside valid UTF-8 kept as an escape (is_hfs_dotgit reads it)
|
|
653
|
+
const text = decodeGitPath(buf.subarray(start, end));
|
|
652
654
|
hasDot ||= text === ".";
|
|
653
655
|
hasDotdot ||= text === "..";
|
|
654
656
|
hasDotgit ||= isDotGitComponent(text);
|
|
@@ -22,7 +22,12 @@
|
|
|
22
22
|
|
|
23
23
|
import type { RefTransactionHook } from "@statewalker/vcs-core";
|
|
24
24
|
import { parseGitBool } from "@statewalker/vcs-utils";
|
|
25
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
type FilesApi,
|
|
27
|
+
sharedRepositoryOf,
|
|
28
|
+
withReadOnlyObjectFiles,
|
|
29
|
+
withSharedPerm,
|
|
30
|
+
} from "@statewalker/vcs-utils/files";
|
|
26
31
|
import {
|
|
27
32
|
expandUserPath,
|
|
28
33
|
type GitHostEnvironment,
|
|
@@ -989,9 +994,9 @@ export class HookSession {
|
|
|
989
994
|
}
|
|
990
995
|
|
|
991
996
|
/**
|
|
992
|
-
* The repository's FilesApi for writes in its git directories
|
|
993
|
-
*
|
|
994
|
-
*
|
|
997
|
+
* The repository's FilesApi for writes in its git directories, wrapped as the files
|
|
998
|
+
* backend's own FilesApi is: under `core.sharedRepository` what is created there gets git's
|
|
999
|
+
* modes (`adjust_shared_perm`), otherwise the object files git keeps read-only are 0444.
|
|
995
1000
|
*/
|
|
996
1001
|
private async repositoryFiles(layout: HookLayout): Promise<FilesApi> {
|
|
997
1002
|
let shared = 0;
|
|
@@ -1000,8 +1005,9 @@ export class HookSession {
|
|
|
1000
1005
|
} catch {
|
|
1001
1006
|
shared = 0;
|
|
1002
1007
|
}
|
|
1003
|
-
if (!shared) return layout.files;
|
|
1004
1008
|
const common = await commonDirOf(layout.files, layout.gitDir);
|
|
1009
|
+
// unshared, git still creates loose objects and pack-family files 0444 (umask applied)
|
|
1010
|
+
if (!shared) return withReadOnlyObjectFiles(layout.files, joinFilesPath(common, "objects"));
|
|
1005
1011
|
return withSharedPerm(layout.files, () => shared, common);
|
|
1006
1012
|
}
|
|
1007
1013
|
|
|
@@ -1079,6 +1085,91 @@ export class HookSession {
|
|
|
1079
1085
|
return { exitCode: outcome.exitCode, stdout: outcome.stdout, stderr: outcome.stderr };
|
|
1080
1086
|
}
|
|
1081
1087
|
|
|
1088
|
+
/**
|
|
1089
|
+
* A credential helper as credential.c's `run_credential_helper` starts it: `command` (the
|
|
1090
|
+
* helper and its operation, `git credential-store get`) through the shell (`use_shell`) in
|
|
1091
|
+
* the directory git runs in, `stdin` written to it, its stdout kept (read only for `get`),
|
|
1092
|
+
* its stderr git's. Undefined without a runner or a layout (no helper runs); an exit code of
|
|
1093
|
+
* 127 when the runner fails to start it.
|
|
1094
|
+
*/
|
|
1095
|
+
async runCredentialHelper(
|
|
1096
|
+
command: string,
|
|
1097
|
+
stdin: string,
|
|
1098
|
+
): Promise<{ exitCode: number; stdout: Uint8Array; stderr: Uint8Array } | undefined> {
|
|
1099
|
+
const runner = this.runner;
|
|
1100
|
+
if (!runner) return undefined;
|
|
1101
|
+
const layout = await this.host.layout();
|
|
1102
|
+
if (!layout) return undefined;
|
|
1103
|
+
const { invocation } = this.invocationOf(
|
|
1104
|
+
layout,
|
|
1105
|
+
"credential-helper",
|
|
1106
|
+
{ kind: "configured", name: "credential-helper", command },
|
|
1107
|
+
{ keepStdout: true, prefix: false, stdin },
|
|
1108
|
+
);
|
|
1109
|
+
let outcome: HookOutcome | undefined;
|
|
1110
|
+
try {
|
|
1111
|
+
outcome = await runner.run(invocation);
|
|
1112
|
+
} catch {
|
|
1113
|
+
outcome = undefined;
|
|
1114
|
+
}
|
|
1115
|
+
if (!outcome) return { exitCode: 127, stdout: new Uint8Array(0), stderr: new Uint8Array(0) };
|
|
1116
|
+
return { exitCode: outcome.exitCode, stdout: outcome.stdout, stderr: outcome.stderr };
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
/**
|
|
1120
|
+
* Runs a program git starts from an argv without a shell (run-command.c with `use_shell =
|
|
1121
|
+
* 0`, as `pipe_command` runs `gpg.ssh.defaultKeyCommand`): `argv[0]` as `execvp` runs it
|
|
1122
|
+
* (a word with a `/` is a path from the directory git runs in, any other is looked up in
|
|
1123
|
+
* `PATH`; no `~` or variable expansion), the arguments verbatim, stdin closed, git's own
|
|
1124
|
+
* variables with nothing removed. Its exit code and output; `startError` is the line git
|
|
1125
|
+
* prints when it cannot start the program (`error: cannot run <word>: <reason>` for a word
|
|
1126
|
+
* it looks up in `PATH`, `fatal: cannot exec '<path>': <reason>` for a path), the program
|
|
1127
|
+
* then counting as failed (exit code 127). Undefined without a runner or a layout.
|
|
1128
|
+
*/
|
|
1129
|
+
async runArgv(
|
|
1130
|
+
name: string,
|
|
1131
|
+
argv: readonly string[],
|
|
1132
|
+
): Promise<
|
|
1133
|
+
{ exitCode: number; stdout: string; stderr: string; startError?: string } | undefined
|
|
1134
|
+
> {
|
|
1135
|
+
const runner = this.runner;
|
|
1136
|
+
if (!runner) return undefined;
|
|
1137
|
+
const layout = await this.host.layout();
|
|
1138
|
+
if (!layout) return undefined;
|
|
1139
|
+
const [program = "", ...args] = argv;
|
|
1140
|
+
const { invocation } = this.invocationOf(
|
|
1141
|
+
layout,
|
|
1142
|
+
name,
|
|
1143
|
+
{ kind: "configured", name, command: program },
|
|
1144
|
+
{ args, keepStdout: true },
|
|
1145
|
+
);
|
|
1146
|
+
delete invocation.command;
|
|
1147
|
+
invocation.argv = true;
|
|
1148
|
+
let outcome: HookOutcome | undefined;
|
|
1149
|
+
let failure: string | undefined;
|
|
1150
|
+
try {
|
|
1151
|
+
outcome = await runner.run(invocation);
|
|
1152
|
+
} catch (error) {
|
|
1153
|
+
failure = String((error as Error)?.message ?? error);
|
|
1154
|
+
}
|
|
1155
|
+
failure = outcome ? outcome.startFailure : (failure ?? "No such file or directory");
|
|
1156
|
+
if (failure !== undefined) {
|
|
1157
|
+
// run-command.c: a PATH lookup that fails is the parent's error(), an exec that fails
|
|
1158
|
+
// is the child's die (child_err_spew)
|
|
1159
|
+
// locate_in_PATH skips files that are not executable, so a word it cannot run is
|
|
1160
|
+
// always ENOENT there, where execvp may answer EACCES
|
|
1161
|
+
const startError = program.includes("/")
|
|
1162
|
+
? `fatal: cannot exec '${program}': ${failure}`
|
|
1163
|
+
: `error: cannot run ${program}: No such file or directory`;
|
|
1164
|
+
return { exitCode: 127, stdout: "", stderr: "", startError };
|
|
1165
|
+
}
|
|
1166
|
+
return {
|
|
1167
|
+
exitCode: outcome?.exitCode ?? 127,
|
|
1168
|
+
stdout: decoder.decode(outcome?.stdout ?? new Uint8Array(0)),
|
|
1169
|
+
stderr: decoder.decode(outcome?.stderr ?? new Uint8Array(0)),
|
|
1170
|
+
};
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1082
1173
|
/**
|
|
1083
1174
|
* A program git runs through the shell with variables of its own (diff.c's
|
|
1084
1175
|
* `run_external_diff`: `use_shell`, the worktree's top as its directory, its stdout git's):
|