@statewalker/vcs-commands 0.14.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/remote-archive-command.d.ts +4 -1
- package/dist/commands/archive/remote-archive-command.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/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 +2 -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 +21 -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 +17 -1
- 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 +21 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +28 -0
- 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 +29 -1
- 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/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 +2 -0
- 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 +21 -2
- 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/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/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 +17 -1
- 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 +10 -4
- package/dist/commands/signing.d.ts.map +1 -1
- 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-C9M78Chn.js → commands-DT3VEv50.js} +14879 -16703
- package/dist/errors/commit-errors.d.ts +23 -3
- 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 +30 -4
- package/dist/{fsck-C4US3l0B.js → fsck-BZ508Elg.js} +1 -1
- 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-C43eykfK.js → local-transport-D98U6p4d.js} +184 -683
- package/dist/{maintenance-run-command-CoJFKr2p.js → maintenance-run-command-DZFnbnbo.js} +2285 -79
- 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-B0CWLCAp.js → results-rF81cQse.js} +1425 -202
- package/dist/transport-command.d.ts +10 -0
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/commands/add-command.ts +15 -2
- package/src/commands/add-patch/patch-backend.ts +6 -44
- package/src/commands/archive/remote-archive-command.ts +10 -3
- package/src/commands/branch-command.ts +57 -4
- package/src/commands/cat-file/batch-format.ts +17 -18
- package/src/commands/cat-file/cat-file-command.ts +181 -15
- package/src/commands/check-ignore-command.ts +61 -17
- 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 +13 -0
- 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 +61 -21
- package/src/commands/config-command.ts +28 -0
- package/src/commands/credential-helper.ts +807 -0
- package/src/commands/default-branch.ts +38 -0
- 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 +103 -14
- package/src/commands/git-hooks.ts +85 -0
- 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 +34 -1
- package/src/commands/legacy-remotes.ts +4 -20
- package/src/commands/local-transport.ts +130 -9
- package/src/commands/log-command.ts +39 -1
- package/src/commands/log-output.ts +31 -4
- package/src/commands/maintenance-schedule-command.ts +418 -0
- package/src/commands/merge-command.ts +10 -0
- package/src/commands/merge-index-command.ts +202 -0
- package/src/commands/merge-one-file.ts +451 -0
- package/src/commands/merge-support.ts +127 -11
- package/src/commands/object-disk-info.ts +169 -0
- package/src/commands/octopus-merge.ts +37 -128
- package/src/commands/promisor-remote.ts +14 -3
- package/src/commands/pull-command.ts +173 -27
- package/src/commands/push-command.ts +50 -5
- package/src/commands/range-diff/range-diff-command.ts +86 -3
- 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/ref-filter.ts +59 -4
- package/src/commands/ref-filter/ref-format.ts +83 -10
- 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 +34 -8
- package/src/commands/served-lazy-fetch.ts +164 -0
- package/src/commands/signing.ts +18 -10
- 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 +31 -3
- 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 +48 -2
|
@@ -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,
|
|
@@ -176,6 +178,7 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
176
178
|
private refetch = false;
|
|
177
179
|
/** `--negotiation-tip=<revision>` (a revision, or a ref glob), in order */
|
|
178
180
|
private negotiationTips: string[] = [];
|
|
181
|
+
private negotiationIncludes: string[] = [];
|
|
179
182
|
private negotiateOnlyMode = false;
|
|
180
183
|
private setUpstream = false;
|
|
181
184
|
/** `--[no-]recurse-submodules[=<mode>]`; unset: the configuration's */
|
|
@@ -490,6 +493,20 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
490
493
|
return this;
|
|
491
494
|
}
|
|
492
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
|
+
|
|
493
510
|
/**
|
|
494
511
|
* `git fetch --negotiate-only`: negotiates with the remote from {@link setNegotiationTips}
|
|
495
512
|
* (protocol v2, a server with `wait-for-done`) and fetches nothing; the commits the server
|
|
@@ -853,6 +870,12 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
853
870
|
async call(): Promise<FetchResult> {
|
|
854
871
|
this.checkCallable();
|
|
855
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
|
+
}
|
|
856
879
|
if (this.negotiateOnlyMode) {
|
|
857
880
|
// cmd_fetch: --negotiate-only never recurses, and needs a tip
|
|
858
881
|
if (this.recurseSubmodules === "yes" || this.recurseSubmodules === "on-demand") {
|
|
@@ -1027,6 +1050,12 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
1027
1050
|
const tipsGiven = this.negotiationTipsGiven();
|
|
1028
1051
|
const negotiationTips =
|
|
1029
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;
|
|
1030
1059
|
const unpackLimit = unpackLimitOf({ getAll: (key) => store.values(key) }, "fetch");
|
|
1031
1060
|
// a new git process: no promisor remote accepted yet (--filter=auto, lazy-fetch order)
|
|
1032
1061
|
resetPromisorAcceptance(this.workingCopy);
|
|
@@ -1115,6 +1144,7 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
1115
1144
|
...(this.refetch ? { refetch: true } : {}),
|
|
1116
1145
|
...(negotiationAlgorithm !== "consecutive" ? { negotiationAlgorithm } : {}),
|
|
1117
1146
|
...(negotiationTips ? { negotiationTips } : {}),
|
|
1147
|
+
...(negotiationIncludes?.length ? { negotiationIncludes } : {}),
|
|
1118
1148
|
// the transport's warnings (a filter the server ignores, the dumb walker's alternates)
|
|
1119
1149
|
onWarning: (line: string) => messages.push(line),
|
|
1120
1150
|
// the server's promisor-remote capability (promisor.acceptFromServer, storeFields)
|
|
@@ -1130,9 +1160,45 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
1130
1160
|
};
|
|
1131
1161
|
// git's fetch runs with fetch_if_missing = 0: its walks read through the history's view
|
|
1132
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
|
+
});
|
|
1133
1174
|
const result = await withRemoteUploadPack(remote, sessionOptions, (connection) =>
|
|
1134
1175
|
fetchFromConnection(connection, fetchOptions),
|
|
1135
|
-
).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
|
+
}
|
|
1136
1202
|
// git dies on a source that names no remote ref (a hidden one included)
|
|
1137
1203
|
const message = error instanceof Error ? error.message : "";
|
|
1138
1204
|
if (message.startsWith("couldn't find remote ref ")) {
|
|
@@ -1166,15 +1232,7 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
1166
1232
|
// a failed --atomic transaction: git's error after the ref lines
|
|
1167
1233
|
if (result.refTransactionError !== undefined) errors.push(result.refTransactionError);
|
|
1168
1234
|
|
|
1169
|
-
const marked = await
|
|
1170
|
-
given: given.length,
|
|
1171
|
-
merge: mergeRefs,
|
|
1172
|
-
// explicit refspecs (and the HEAD of an unconfigured remote) are all to merge;
|
|
1173
|
-
// configured ones only when the first names one ref and no upstream is set
|
|
1174
|
-
explicit: !useConfig,
|
|
1175
|
-
firstIsExact: given.length > 0 && !parseRefSpec(given[0]).wildcard,
|
|
1176
|
-
hasMerge: upstream !== undefined,
|
|
1177
|
-
});
|
|
1235
|
+
const marked = await markedOf(result);
|
|
1178
1236
|
// store_updated_refs: a ref rejected for the shallow commits it needs is skipped, with
|
|
1179
1237
|
// git's warning when it is for merge
|
|
1180
1238
|
for (const e of marked) {
|
|
@@ -1299,9 +1357,33 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
1299
1357
|
if (this.negotiationTips.length > 0 || this.negotiationCompatibility() === "2.43") {
|
|
1300
1358
|
return this.negotiationTips;
|
|
1301
1359
|
}
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
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;
|
|
1305
1387
|
}
|
|
1306
1388
|
|
|
1307
1389
|
/**
|
|
@@ -1312,9 +1394,10 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
1312
1394
|
private async resolveNegotiationTips(
|
|
1313
1395
|
messages: string[],
|
|
1314
1396
|
given: readonly string[] = this.negotiationTips,
|
|
1397
|
+
optionName?: string,
|
|
1315
1398
|
): Promise<ObjectId[]> {
|
|
1316
1399
|
const legacy = this.negotiationCompatibility() === "2.43";
|
|
1317
|
-
const option = legacy ? "--negotiation-tip" : "--negotiation-restrict";
|
|
1400
|
+
const option = optionName ?? (legacy ? "--negotiation-tip" : "--negotiation-restrict");
|
|
1318
1401
|
const tips: ObjectId[] = [];
|
|
1319
1402
|
const glob = (text: string) => /[*?[\\]/.test(text);
|
|
1320
1403
|
const refs = given.some(glob)
|
|
@@ -1360,6 +1443,11 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
1360
1443
|
const messages: string[] = [...legacyMessages];
|
|
1361
1444
|
const given = this.negotiationTipsGiven();
|
|
1362
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
|
+
: [];
|
|
1363
1451
|
const remote = await this.prepareRemote(remoteUrl);
|
|
1364
1452
|
if (given.length === 0) {
|
|
1365
1453
|
throw new GitApiError("fatal: --negotiate-only needs one or more --negotiation-restrict=*", {
|
|
@@ -1388,6 +1476,7 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
1388
1476
|
negotiateOnly(connection, {
|
|
1389
1477
|
repository: createRepositoryFacade({ history: historyWithoutLazyFetch(history) }),
|
|
1390
1478
|
tips,
|
|
1479
|
+
...(includes.length > 0 ? { includes } : {}),
|
|
1391
1480
|
negotiationAlgorithm: algorithm,
|
|
1392
1481
|
shallow,
|
|
1393
1482
|
...(sessionId !== undefined ? { sessionId } : {}),
|
|
@@ -1085,6 +1085,91 @@ export class HookSession {
|
|
|
1085
1085
|
return { exitCode: outcome.exitCode, stdout: outcome.stdout, stderr: outcome.stderr };
|
|
1086
1086
|
}
|
|
1087
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
|
+
|
|
1088
1173
|
/**
|
|
1089
1174
|
* A program git runs through the shell with variables of its own (diff.c's
|
|
1090
1175
|
* `run_external_diff`: `use_shell`, the worktree's top as its directory, its stdout git's):
|