@statewalker/vcs-commands 0.12.0 → 0.14.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.
Files changed (106) hide show
  1. package/dist/commands/archive/archive-command.d.ts +6 -2
  2. package/dist/commands/archive/archive-command.d.ts.map +1 -1
  3. package/dist/commands/archive/remote-archive-command.d.ts +23 -1
  4. package/dist/commands/archive/remote-archive-command.d.ts.map +1 -1
  5. package/dist/commands/archive/upload-archive-writer.d.ts +11 -5
  6. package/dist/commands/archive/upload-archive-writer.d.ts.map +1 -1
  7. package/dist/commands/bundle/bundle-format.d.ts +6 -1
  8. package/dist/commands/bundle/bundle-format.d.ts.map +1 -1
  9. package/dist/commands/bundle/bundle-uri-host.d.ts +12 -1
  10. package/dist/commands/bundle/bundle-uri-host.d.ts.map +1 -1
  11. package/dist/commands/bundle/bundle-uri.d.ts +7 -1
  12. package/dist/commands/bundle/bundle-uri.d.ts.map +1 -1
  13. package/dist/commands/bundle/bundle-verify.d.ts +4 -1
  14. package/dist/commands/bundle/bundle-verify.d.ts.map +1 -1
  15. package/dist/commands/cat-file/cat-file-command.d.ts.map +1 -1
  16. package/dist/commands/check-ignore-command.d.ts.map +1 -1
  17. package/dist/commands/clone-command.d.ts +15 -0
  18. package/dist/commands/clone-command.d.ts.map +1 -1
  19. package/dist/commands/commit-command.d.ts +10 -1
  20. package/dist/commands/commit-command.d.ts.map +1 -1
  21. package/dist/commands/default-branch.d.ts +17 -3
  22. package/dist/commands/default-branch.d.ts.map +1 -1
  23. package/dist/commands/fetch-command.d.ts +2 -1
  24. package/dist/commands/fetch-command.d.ts.map +1 -1
  25. package/dist/commands/fsck/fsck-object-checks.d.ts.map +1 -1
  26. package/dist/commands/git-hooks.d.ts +3 -3
  27. package/dist/commands/git-hooks.d.ts.map +1 -1
  28. package/dist/commands/http-config.d.ts +1 -1
  29. package/dist/commands/http-config.d.ts.map +1 -1
  30. package/dist/commands/index.js +6 -6
  31. package/dist/commands/init-command.d.ts.map +1 -1
  32. package/dist/commands/local-transport.d.ts +11 -1
  33. package/dist/commands/local-transport.d.ts.map +1 -1
  34. package/dist/commands/ls-tree-command.d.ts +10 -0
  35. package/dist/commands/ls-tree-command.d.ts.map +1 -1
  36. package/dist/commands/merge-command.d.ts +11 -1
  37. package/dist/commands/merge-command.d.ts.map +1 -1
  38. package/dist/commands/merge-support.d.ts +19 -2
  39. package/dist/commands/merge-support.d.ts.map +1 -1
  40. package/dist/commands/plumbing-input.d.ts.map +1 -1
  41. package/dist/commands/promisor-remote-reply.d.ts +31 -4
  42. package/dist/commands/promisor-remote-reply.d.ts.map +1 -1
  43. package/dist/commands/promisor-remote.d.ts +8 -1
  44. package/dist/commands/promisor-remote.d.ts.map +1 -1
  45. package/dist/commands/push-command.d.ts.map +1 -1
  46. package/dist/commands/ref-filter/index.d.ts +1 -0
  47. package/dist/commands/ref-filter/index.d.ts.map +1 -1
  48. package/dist/commands/ref-filter/peel-limit.d.ts +8 -0
  49. package/dist/commands/ref-filter/peel-limit.d.ts.map +1 -0
  50. package/dist/commands/ref-filter/ref-filter.d.ts.map +1 -1
  51. package/dist/commands/ref-filter/ref-format.d.ts.map +1 -1
  52. package/dist/commands/serve-repository.d.ts +4 -3
  53. package/dist/commands/serve-repository.d.ts.map +1 -1
  54. package/dist/commands/signing.d.ts +29 -2
  55. package/dist/commands/signing.d.ts.map +1 -1
  56. package/dist/commands/split-cmdline.d.ts +6 -0
  57. package/dist/commands/split-cmdline.d.ts.map +1 -0
  58. package/dist/{commands-C2E51T1z.js → commands-C9M78Chn.js} +1186 -1036
  59. package/dist/errors/commit-errors.d.ts +17 -1
  60. package/dist/errors/commit-errors.d.ts.map +1 -1
  61. package/dist/errors/index.js +18 -3
  62. package/dist/{fsck-BjlxStsM.js → fsck-C4US3l0B.js} +2 -2
  63. package/dist/index.js +7 -7
  64. package/dist/{maintenance-run-command-G_eWdA8O.js → maintenance-run-command-CoJFKr2p.js} +85 -33
  65. package/dist/{remote-transport-CSgTJ1BH.js → remote-transport-C43eykfK.js} +51 -16
  66. package/dist/results/index.js +1 -1
  67. package/dist/{results-Dg1KHG8y.js → results-B0CWLCAp.js} +398 -54
  68. package/dist/transport-command.d.ts +3 -0
  69. package/dist/transport-command.d.ts.map +1 -1
  70. package/package.json +21 -13
  71. package/src/commands/archive/archive-command.ts +7 -3
  72. package/src/commands/archive/remote-archive-command.ts +37 -3
  73. package/src/commands/archive/upload-archive-writer.ts +34 -22
  74. package/src/commands/bundle/bundle-format.ts +10 -2
  75. package/src/commands/bundle/bundle-uri-host.ts +71 -11
  76. package/src/commands/bundle/bundle-uri.ts +11 -4
  77. package/src/commands/bundle/bundle-verify.ts +4 -1
  78. package/src/commands/cat-file/cat-file-command.ts +1 -33
  79. package/src/commands/check-ignore-command.ts +60 -15
  80. package/src/commands/clone-command.ts +89 -11
  81. package/src/commands/commit-command.ts +42 -7
  82. package/src/commands/default-branch.ts +19 -5
  83. package/src/commands/fetch-command.ts +13 -2
  84. package/src/commands/fsck/fsck-object-checks.ts +3 -1
  85. package/src/commands/git-hooks.ts +11 -5
  86. package/src/commands/http-config.ts +47 -1
  87. package/src/commands/init-command.ts +24 -4
  88. package/src/commands/local-transport.ts +53 -9
  89. package/src/commands/ls-tree-command.ts +20 -12
  90. package/src/commands/merge-command.ts +32 -8
  91. package/src/commands/merge-support.ts +42 -4
  92. package/src/commands/plumbing-input.ts +3 -1
  93. package/src/commands/promisor-remote-reply.ts +338 -56
  94. package/src/commands/promisor-remote.ts +25 -3
  95. package/src/commands/push-command.ts +5 -1
  96. package/src/commands/read-tree-command.ts +2 -2
  97. package/src/commands/ref-filter/index.ts +1 -0
  98. package/src/commands/ref-filter/peel-limit.ts +7 -0
  99. package/src/commands/ref-filter/ref-filter.ts +9 -3
  100. package/src/commands/ref-filter/ref-format.ts +2 -1
  101. package/src/commands/repack-command.ts +1 -1
  102. package/src/commands/serve-repository.ts +8 -3
  103. package/src/commands/signing.ts +93 -10
  104. package/src/commands/split-cmdline.ts +32 -0
  105. package/src/errors/commit-errors.ts +24 -2
  106. package/src/transport-command.ts +31 -1
@@ -1,4 +1,5 @@
1
1
  import { type Credentials, type GitTransportRegistry, type HttpClientSettings, type HttpCredentialHelper, type ProgressInfo } from "@statewalker/vcs-transport";
2
+ import type { ObjectFormat } from "@statewalker/vcs-utils/hash";
2
3
  import type { WorkingCopy } from "@statewalker/vcs-working-tree";
3
4
  import { type BundleUriHost } from "./commands/bundle/index.js";
4
5
  import { type PreparedRemote, type RemoteSessionOptions, type ResolvedRemote } from "./commands/remote-transport.js";
@@ -206,6 +207,8 @@ export declare abstract class TransportCommand<T> extends GitCommand<T> {
206
207
  message(line: string): void;
207
208
  setConfigValue?(key: string, value: string): Promise<void>;
208
209
  tempFileName?(): string;
210
+ /** The hash bundle headers are read in (default the repository's) */
211
+ objectFormat?: ObjectFormat;
209
212
  }): BundleUriHost;
210
213
  /**
211
214
  * `git -c fetch.bundleURI=<uri> fetch`: the bundle URI this fetch downloads before talking
@@ -1 +1 @@
1
- {"version":3,"file":"transport-command.d.ts","sourceRoot":"","sources":["../src/transport-command.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAIL,KAAK,cAAc,EAGnB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EAGpB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,gBAAgB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commands (commit, checkout, merge, diff, log)",
5
5
  "bugs": {
6
6
  "url": "https://github.com/statewalker/webrun-vcs/issues"
@@ -43,16 +43,24 @@
43
43
  },
44
44
  "files": [
45
45
  "dist",
46
- "src"
46
+ "src",
47
+ "!**/__tests__",
48
+ "!**/__mocks__",
49
+ "!**/__fixtures__",
50
+ "!**/fixtures",
51
+ "!**/tests",
52
+ "!**/test",
53
+ "!**/*.test.*",
54
+ "!**/*.spec.*"
47
55
  ],
48
56
  "dependencies": {
49
57
  "@statewalker/webrun-rpc": "^0.15.0",
50
- "@statewalker/vcs-core": "^0.12.0",
51
- "@statewalker/vcs-store-files": "^0.12.0",
52
- "@statewalker/vcs-store-mem": "^0.12.0",
53
- "@statewalker/vcs-transport": "^0.12.0",
54
- "@statewalker/vcs-utils": "^0.11.0",
55
- "@statewalker/vcs-working-tree": "^0.12.0"
58
+ "@statewalker/vcs-core": "^0.13.0",
59
+ "@statewalker/vcs-store-files": "^0.13.0",
60
+ "@statewalker/vcs-transport": "^0.14.0",
61
+ "@statewalker/vcs-utils": "^0.11.1",
62
+ "@statewalker/vcs-store-mem": "^0.13.0",
63
+ "@statewalker/vcs-working-tree": "^0.13.0"
56
64
  },
57
65
  "devDependencies": {
58
66
  "@types/node": "^26.6.4",
@@ -61,11 +69,11 @@
61
69
  "typescript": "^7.0.2",
62
70
  "vitest": "^5.1.0",
63
71
  "ws": "^8.22.0",
64
- "@statewalker/vcs-store-kv": "^0.12.0",
65
- "@statewalker/vcs-store-sql": "^0.12.0",
66
- "@statewalker/vcs-transport-adapters": "^0.12.0",
67
- "@statewalker/vcs-utils-node": "^0.12.0",
68
- "@statewalker/vcs-transport-lfs": "^0.10.0"
72
+ "@statewalker/vcs-store-kv": "^0.13.0",
73
+ "@statewalker/vcs-transport-adapters": "^0.14.0",
74
+ "@statewalker/vcs-store-sql": "^0.13.0",
75
+ "@statewalker/vcs-transport-lfs": "^0.10.1",
76
+ "@statewalker/vcs-utils-node": "^0.12.1"
69
77
  },
70
78
  "scripts": {
71
79
  "build": "rm -rf dist && rolldown -c && tsc --emitDeclarationOnly --declaration",
@@ -334,9 +334,13 @@ export class ArchiveCommand extends GitCommand<Uint8Array> {
334
334
  return this;
335
335
  }
336
336
 
337
- /** What git printed on stderr (`-v`'s paths, warnings). */
338
- getMessages(): string[] {
339
- return [...this.messages];
337
+ /**
338
+ * What git printed on stderr (`-v`'s paths, warnings), from the `from`th message on: read
339
+ * while {@link callStream} runs, the messages so far (upload-archive sends them on as they
340
+ * come).
341
+ */
342
+ getMessages(from = 0): string[] {
343
+ return this.messages.slice(from);
340
344
  }
341
345
 
342
346
  /** `git archive --list`: the formats, as git lists them. */
@@ -19,11 +19,17 @@ import { withRemoteSession } from "../remote-transport.js";
19
19
  import { ArchiveCommand } from "./archive-command.js";
20
20
  import { uploadArchiveWriterOf } from "./upload-archive-writer.js";
21
21
 
22
+ /** What the in-process upload-archive may write ahead of the client. */
23
+ const LOCAL_HIGH_WATER_MARK = 1 << 20;
24
+
22
25
  /** What `git archive --remote` gave. */
23
26
  export interface RemoteArchiveResult {
24
27
  /** 0; 1 when the remote reported an error; 128 when the client died */
25
28
  exitCode: number;
26
- /** The archive (git's stdout, or `-o`'s file), the `--list` lines for `--list` */
29
+ /**
30
+ * The archive (git's stdout, or `-o`'s file), the `--list` lines for `--list`; empty when
31
+ * {@link RemoteArchiveCommand.setOutput} took them
32
+ */
27
33
  archive: Uint8Array;
28
34
  /**
29
35
  * git's stderr: the remote's messages as `remote: <line> ` lines (`-v`'s paths, its
@@ -56,6 +62,7 @@ export class RemoteArchiveCommand extends TransportCommand<RemoteArchiveResult>
56
62
  private exec?: string;
57
63
  private outputName?: string;
58
64
  private readonly args: string[] = [];
65
+ private output?: (chunk: Uint8Array) => void | Promise<void>;
59
66
 
60
67
  /** `--remote=<repo>`: a remote's name or a URL (a path for a local repository). */
61
68
  setRemote(remote: string): this {
@@ -81,6 +88,29 @@ export class RemoteArchiveCommand extends TransportCommand<RemoteArchiveResult>
81
88
  return this;
82
89
  }
83
90
 
91
+ /**
92
+ * Takes the archive as it arrives, chunk by chunk (git writing its stdout or `-o`'s file),
93
+ * instead of collecting it in {@link RemoteArchiveResult.archive}: the next chunk is read
94
+ * once the returned promise settles, so neither end holds the archive whole. A rejection
95
+ * is the client's death (exit 128).
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * const writer = file.getWriter();
100
+ * const { exitCode } = await git
101
+ * .archiveRemote()
102
+ * .setRemote("origin")
103
+ * .addArguments("HEAD")
104
+ * .setOutput((chunk) => writer.write(chunk))
105
+ * .call();
106
+ * ```
107
+ */
108
+ setOutput(output: (chunk: Uint8Array) => void | Promise<void>): this {
109
+ this.checkCallable();
110
+ this.output = output;
111
+ return this;
112
+ }
113
+
84
114
  /** `git archive`'s other arguments, as given (`--format=tar`, `-v`, `HEAD`, `--`, paths). */
85
115
  addArguments(...args: string[]): this {
86
116
  this.checkCallable();
@@ -100,7 +130,10 @@ export class RemoteArchiveCommand extends TransportCommand<RemoteArchiveResult>
100
130
  this.outputName !== undefined
101
131
  ? new ArchiveCommand(this.workingCopy).formatFromFilename(this.outputName)
102
132
  : undefined;
103
- const options = formatHint ? { formatHint } : {};
133
+ const options = {
134
+ ...(formatHint ? { formatHint } : {}),
135
+ ...(this.output ? { output: this.output } : {}),
136
+ };
104
137
  const url = RemoteConfigStore.from(this.workingCopy).remoteUrlOf(this.remote);
105
138
  const remote = await this.prepareRemote(url);
106
139
  if (remote.kind === "bundle") {
@@ -110,7 +143,8 @@ export class RemoteArchiveCommand extends TransportCommand<RemoteArchiveResult>
110
143
  // git spawns git-upload-archive in the repository: ours serves it in process
111
144
  const writer = uploadArchiveWriterOf(remote.repository);
112
145
  if (!writer) throw new GitApiError("fatal: operation not supported by protocol");
113
- const [client, server] = createDuplexPair();
146
+ // bounded, as git's pipe to its upload-archive child: the server waits for the client
147
+ const [client, server] = createDuplexPair({ highWaterMark: LOCAL_HIGH_WATER_MARK });
114
148
  const serving = serveUploadArchive(server, writer).finally(() => server.close?.());
115
149
  const [result, served] = await Promise.all([
116
150
  requestRemoteArchive(client, this.args, options).finally(() => client.close?.()),
@@ -5,7 +5,7 @@
5
5
  * upload-archive protocol (vcs-transport `serveUploadArchive`).
6
6
  */
7
7
 
8
- import type { UploadArchiveOutput, UploadArchiveWriter } from "@statewalker/vcs-transport";
8
+ import type { UploadArchiveSink, UploadArchiveWriter } from "@statewalker/vcs-transport";
9
9
  import { parseGitBool } from "@statewalker/vcs-utils";
10
10
  import type { OpenedRepository, WorkingCopy } from "@statewalker/vcs-working-tree";
11
11
  import { GitApiError } from "../../errors/index.js";
@@ -25,20 +25,34 @@ export interface ArchiveWriterOptions {
25
25
  /**
26
26
  * Runs `git archive <args>` as upload-archive's writer runs it in `workingCopy` (a
27
27
  * repository's, its worktree never read): git's options parsed from `args`, only formats
28
- * served remotely, a tree-ish only by ref unless `allowUnreachable`. Never throws: git's
29
- * deaths are its stderr and exit status.
28
+ * served remotely, a tree-ish only by ref unless `allowUnreachable`. The archive goes to
29
+ * `sink` as it is written ({@link ArchiveCommand.callStream}: never held whole, the writer
30
+ * waiting on each chunk), stderr's lines with it as they are printed; resolves with git's
31
+ * exit status. Never throws: git's deaths are a stderr line and the status (a sink that
32
+ * rejects, the client gone, stops the writer the same way).
30
33
  *
31
34
  * @example
32
35
  * ```ts
33
- * const { stdout, exitCode } = await runArchiveWriter(workingCopy, ["--format=zip", "HEAD"]);
36
+ * const exitCode = await runArchiveWriter(workingCopy, ["--format=zip", "HEAD"], {
37
+ * stdout: async (chunk) => file.write(chunk),
38
+ * stderr: async (text) => log(text),
39
+ * });
34
40
  * ```
35
41
  */
36
42
  export async function runArchiveWriter(
37
43
  workingCopy: WorkingCopy,
38
44
  args: readonly string[],
45
+ sink: UploadArchiveSink,
39
46
  options: ArchiveWriterOptions = {},
40
- ): Promise<UploadArchiveOutput> {
47
+ ): Promise<number> {
41
48
  let command: ArchiveCommand | undefined;
49
+ let sent = 0;
50
+ const flushMessages = async () => {
51
+ if (!command) return;
52
+ const lines = command.getMessages(sent);
53
+ sent += lines.length;
54
+ if (lines.length > 0) await sink.stderr(lines.map((m) => `${m}\n`).join(""));
55
+ };
42
56
  try {
43
57
  command = new ArchiveCommand(workingCopy).setUploadArchive({
44
58
  allowUnreachable: options.allowUnreachable === true,
@@ -47,29 +61,27 @@ export async function runArchiveWriter(
47
61
  const list = applyArchiveArgs(command, args);
48
62
  if (list) {
49
63
  const lines = command.listFormats().map((name) => `${name}\n`);
50
- return { exitCode: 0, stdout: encoder.encode(lines.join("")), stderr: "" };
64
+ await sink.stdout(encoder.encode(lines.join("")));
65
+ return 0;
66
+ }
67
+ for await (const chunk of command.callStream()) {
68
+ // what was printed while this chunk was made goes first (git's -v: the path, then
69
+ // its entry)
70
+ await flushMessages();
71
+ await sink.stdout(chunk);
51
72
  }
52
- const archive = await command.call();
53
- return { exitCode: 0, stdout: archive, stderr: messagesOf(command) };
73
+ await flushMessages();
74
+ return 0;
54
75
  } catch (error) {
55
76
  const message = (error as Error).message ?? String(error);
56
77
  const exitCode = error instanceof GitApiError ? error.exitCode : 128;
57
78
  const text = /^(fatal|error|usage|warning):/.test(message) ? message : `fatal: ${message}`;
58
- return {
59
- exitCode,
60
- stdout: new Uint8Array(0),
61
- stderr: `${command ? messagesOf(command) : ""}${text}\n`,
62
- };
79
+ await flushMessages().catch(() => {});
80
+ await sink.stderr(`${text}\n`).catch(() => {});
81
+ return exitCode;
63
82
  }
64
83
  }
65
84
 
66
- function messagesOf(command: ArchiveCommand): string {
67
- return command
68
- .getMessages()
69
- .map((m) => `${m}\n`)
70
- .join("");
71
- }
72
-
73
85
  /**
74
86
  * {@link runArchiveWriter} for an opened repository (`Worktree.openRepository`), as git's
75
87
  * upload-archive serves it: in its git directory (no worktree), `uploadarchive.allowUnreachable`
@@ -88,11 +100,11 @@ export function uploadArchiveWriterOf(
88
100
  ): UploadArchiveWriter | undefined {
89
101
  const worktrees = repository.worktrees;
90
102
  if (!worktrees) return undefined;
91
- return async (args) => {
103
+ return async (args, sink) => {
92
104
  const value = repository.config?.getAll("uploadarchive.allowUnreachable").at(-1);
93
105
  const allowUnreachable = value === undefined ? false : (parseGitBool(value ?? "true") ?? false);
94
106
  const admin = await worktrees.openAdmin();
95
- return runArchiveWriter(withoutWorktree(worktreeAdminWorkingCopy(admin)), args, {
107
+ return runArchiveWriter(withoutWorktree(worktreeAdminWorkingCopy(admin)), args, sink, {
96
108
  allowUnreachable,
97
109
  ...options,
98
110
  });
@@ -85,7 +85,15 @@ const HEX = /^[0-9a-fA-F]$/;
85
85
  * if (!parsed.ok) console.error(`error: ${parsed.error}`);
86
86
  * ```
87
87
  */
88
- export function parseBundleHeader(bytes: Uint8Array, name = "<bundle>"): ParsedBundleHeader {
88
+ export function parseBundleHeader(
89
+ bytes: Uint8Array,
90
+ name = "<bundle>",
91
+ /**
92
+ * The hash a header without `@object-format=` names ids in (git's `the_hash_algo`: the
93
+ * repository's)
94
+ */
95
+ defaultFormat: ObjectFormat = SHA1_OBJECT_FORMAT,
96
+ ): ParsedBundleHeader {
89
97
  let at = 0;
90
98
  /** strbuf_getwholeline_fd: the next line with its LF; undefined at the end */
91
99
  const nextLine = (): Uint8Array | undefined => {
@@ -106,7 +114,7 @@ export function parseBundleHeader(bytes: Uint8Array, name = "<bundle>"): ParsedB
106
114
  notABundle: true,
107
115
  };
108
116
  }
109
- let objectFormat: ObjectFormat = SHA1_OBJECT_FORMAT;
117
+ let objectFormat: ObjectFormat = defaultFormat;
110
118
  let filter: string | undefined;
111
119
  const prerequisites: BundlePrerequisite[] = [];
112
120
  const references: BundleRef[] = [];
@@ -4,14 +4,24 @@
4
4
  * written under `refs/bundles/`) and `fetch.bundleCreationToken`.
5
5
  */
6
6
 
7
- import { historyWithoutLazyFetch, type ObjectId, type RefLogOptions } from "@statewalker/vcs-core";
7
+ import {
8
+ historyWithoutLazyFetch,
9
+ type ObjectId,
10
+ objectFormatOf,
11
+ type RefLogOptions,
12
+ } from "@statewalker/vcs-core";
8
13
  import {
9
14
  type Credentials,
15
+ checkReceivedPack,
10
16
  createRepositoryFacade,
17
+ FetchCheckError,
11
18
  type HttpClientSettings,
12
19
  type HttpCredentialHelper,
20
+ ReceivedObjects,
21
+ type ReceivedObjectsFsck,
13
22
  SmartHttpClient,
14
23
  } from "@statewalker/vcs-transport";
24
+ import type { ObjectFormat } from "@statewalker/vcs-utils/hash";
15
25
 
16
26
  import type { WorkingCopy } from "../../types.js";
17
27
  import type { BundleUriHost } from "./bundle-uri.js";
@@ -47,6 +57,16 @@ export interface BundleUriHostOptions {
47
57
  message(line: string): void;
48
58
  /** How the downloaded list file is named in errors */
49
59
  tempFileName?(): string;
60
+ /**
61
+ * The hash a bundle header without `@object-format=` is read in (git's `the_hash_algo`):
62
+ * default the repository's
63
+ */
64
+ objectFormat?: ObjectFormat;
65
+ /**
66
+ * git 2.46+'s `VERIFY_BUNDLE_FSCK` (`fetch.fsckObjects`, else `transfer.fsckObjects`): the
67
+ * fsck index-pack's `--fsck-objects` runs over the bundle's objects, or undefined for none
68
+ */
69
+ fsckObjects?(): Promise<ReceivedObjectsFsck | undefined>;
50
70
  }
51
71
 
52
72
  /** The origin of a URL, or undefined for one `new URL` cannot read. */
@@ -61,6 +81,7 @@ function originOf(url: string): string | undefined {
61
81
  /** A host over a repository (see {@link BundleUriHostOptions}). */
62
82
  export function createBundleUriHost(options: BundleUriHostOptions): BundleUriHost {
63
83
  const history = options.workingCopy.history;
84
+ const objectFormat = options.objectFormat ?? objectFormatOf(history);
64
85
  return {
65
86
  async download(uri) {
66
87
  if (/^https?:/.test(uri)) return downloadHttp(options, uri);
@@ -69,7 +90,7 @@ export function createBundleUriHost(options: BundleUriHostOptions): BundleUriHos
69
90
  return options.readLocalFile(path).catch(() => undefined);
70
91
  },
71
92
  async unbundle(bytes) {
72
- const opened = openBundle(bytes, "<bundle>");
93
+ const opened = openBundle(bytes, "<bundle>", objectFormat);
73
94
  if (!opened.ok) return false;
74
95
  const { header, pack } = opened.bundle;
75
96
  const objects = historyWithoutLazyFetch(history);
@@ -85,18 +106,56 @@ export function createBundleUriHost(options: BundleUriHostOptions): BundleUriHos
85
106
  for (const line of verified.stderr.split("\n")) if (line) options.message(line);
86
107
  if (!verified.ok) return false;
87
108
  const facade = createRepositoryFacade({ history: objects });
109
+ const fsck = await options.fsckObjects?.();
88
110
  let packId: string | undefined;
89
111
  try {
90
- const imported = await facade.importPack(
91
- (async function* () {
92
- yield pack;
93
- })(),
94
- { keepPack: true },
95
- );
96
- packId = imported.packId;
112
+ if (fsck) {
113
+ // index-pack --fsck-objects: the objects checked in a quarantine (no links: a bundle
114
+ // has prerequisites), which a refusal discards
115
+ const received = new ReceivedObjects(objectFormat.rawLength);
116
+ const { quarantine, ...imported } = await facade.importPack(
117
+ (async function* () {
118
+ yield pack;
119
+ })(),
120
+ {
121
+ keepPack: true,
122
+ quarantine: true,
123
+ onObject: (id, type, entry) => received.add(id, type, entry),
124
+ },
125
+ );
126
+ let committed = false;
127
+ try {
128
+ const checked = await checkReceivedPack(quarantine?.repository ?? facade, received, {
129
+ fsck,
130
+ links: false,
131
+ shallow: new Set<string>(),
132
+ kept: true,
133
+ tail: null,
134
+ });
135
+ // index-pack's fsck warnings (stderr; VERIFY_BUNDLE_QUIET quiets verify_bundle only)
136
+ for (const line of checked.messages) options.message(line);
137
+ await quarantine?.commit();
138
+ committed = true;
139
+ } finally {
140
+ if (!committed) await quarantine?.discard().catch(() => {});
141
+ }
142
+ packId = imported.packId;
143
+ } else {
144
+ const imported = await facade.importPack(
145
+ (async function* () {
146
+ yield pack;
147
+ })(),
148
+ { keepPack: true },
149
+ );
150
+ packId = imported.packId;
151
+ }
97
152
  } catch (error) {
98
- const message = error instanceof Error ? error.message : String(error);
99
- options.message(message.startsWith("fatal: ") ? message : `fatal: ${message}`);
153
+ if (error instanceof FetchCheckError) {
154
+ for (const line of error.lines) options.message(line);
155
+ } else {
156
+ const message = error instanceof Error ? error.message : String(error);
157
+ options.message(message.startsWith("fatal: ") ? message : `fatal: ${message}`);
158
+ }
100
159
  options.message("error: index-pack died");
101
160
  return false;
102
161
  }
@@ -130,6 +189,7 @@ export function createBundleUriHost(options: BundleUriHostOptions): BundleUriHos
130
189
  creationToken: () => options.configValue("fetch.bundleCreationToken"),
131
190
  setCreationToken: (value) => options.setConfigValue("fetch.bundleCreationToken", value),
132
191
  message: (line) => options.message(line),
192
+ objectFormat,
133
193
  ...(options.tempFileName ? { tempFileName: options.tempFileName } : {}),
134
194
  };
135
195
  }
@@ -11,6 +11,8 @@
11
11
  * heuristic, and give git's warnings in order.
12
12
  */
13
13
 
14
+ import type { ObjectFormat } from "@statewalker/vcs-utils/hash";
15
+
14
16
  import { parseBundleHeader } from "./bundle-format.js";
15
17
  import { BundleList, parseBundleListConfig, type RemoteBundleInfo } from "./bundle-list.js";
16
18
 
@@ -37,14 +39,19 @@ export interface BundleUriHost {
37
39
  * `<objects>/bundles/tmp_uri_XXXXXX`)
38
40
  */
39
41
  tempFileName?(): string;
42
+ /**
43
+ * The hash a bundle header without `@object-format=` is read in (git's `the_hash_algo`, the
44
+ * repository's; default SHA-1)
45
+ */
46
+ objectFormat?: ObjectFormat;
40
47
  }
41
48
 
42
49
  /** bundle-uri.c's `max_bundle_uri_depth`. */
43
50
  const MAX_BUNDLE_URI_DEPTH = 4;
44
51
 
45
52
  /** Whether the bytes read as a bundle (`is_bundle`: the whole header parses). */
46
- export function isBundle(bytes: Uint8Array): boolean {
47
- return parseBundleHeader(bytes).ok;
53
+ export function isBundle(bytes: Uint8Array, objectFormat?: ObjectFormat): boolean {
54
+ return parseBundleHeader(bytes, undefined, objectFormat).ok;
48
55
  }
49
56
 
50
57
  /**
@@ -72,7 +79,7 @@ async function fetchBundleUriInternal(
72
79
  return false;
73
80
  }
74
81
  bundle.file = bytes;
75
- if (!isBundle(bytes)) {
82
+ if (!isBundle(bytes, host.objectFormat)) {
76
83
  const ok = await fetchBundleListInConfigFormat(host, global, bundle, bytes, depth);
77
84
  if (!ok) {
78
85
  bundle.file = null;
@@ -160,7 +167,7 @@ async function fetchBundlesByToken(host: BundleUriHost, list: BundleList): Promi
160
167
  bundle.unbundled = true;
161
168
  direction = 1;
162
169
  skipUnbundle = true;
163
- } else if (!bundle.file || !isBundle(bundle.file)) {
170
+ } else if (!bundle.file || !isBundle(bundle.file, host.objectFormat)) {
164
171
  host.message(`warning: file downloaded from '${bundle.uri}' is not a bundle`);
165
172
  break;
166
173
  }
@@ -6,6 +6,7 @@
6
6
 
7
7
  import { type History, historyWithoutLazyFetch, type ObjectId } from "@statewalker/vcs-core";
8
8
  import { connectivityErrors, createRepositoryFacade } from "@statewalker/vcs-transport";
9
+ import type { ObjectFormat } from "@statewalker/vcs-utils/hash";
9
10
 
10
11
  import { type BundleHeader, listBundleRefs, parseBundleHeader } from "./bundle-format.js";
11
12
 
@@ -61,8 +62,10 @@ export interface OpenedBundle {
61
62
  export function openBundle(
62
63
  bytes: Uint8Array,
63
64
  name: string,
65
+ /** The hash of a header without `@object-format=` (the repository's) */
66
+ defaultFormat?: ObjectFormat,
64
67
  ): { ok: true; bundle: OpenedBundle } | { ok: false; error: string } {
65
- const parsed = parseBundleHeader(bytes, name);
68
+ const parsed = parseBundleHeader(bytes, name, defaultFormat);
66
69
  if (!parsed.ok) return { ok: false, error: `error: ${parsed.error}\n` };
67
70
  return { ok: true, bundle: { header: parsed.header, pack: bytes.subarray(parsed.packOffset) } };
68
71
  }
@@ -27,6 +27,7 @@ import {
27
27
  } from "../remote-object-info-command.js";
28
28
  import { applyMailmapToHeader } from "../rev-filter/index.js";
29
29
  import type { RevisionResolver } from "../revision-resolver.js";
30
+ import { splitCmdline } from "../split-cmdline.js";
30
31
  import {
31
32
  type BatchFormat,
32
33
  type BatchObjectData,
@@ -795,39 +796,6 @@ const MAX_ALLOWED_OBJ_LIMIT = 10000;
795
796
  /** cat-file.c's MAX_REMOTE_OBJ_INFO_LINE: a URL of 8 KiB and the ids (GIT_MAX_HEXSZ + 1 each). */
796
797
  const MAX_REMOTE_OBJ_INFO_LINE = 8 * 1024 + MAX_ALLOWED_OBJ_LIMIT * (64 + 1);
797
798
 
798
- /**
799
- * alias.c's split_cmdline: words split on whitespace, quotes removed, a backslash escaping
800
- * the next character outside single quotes; split_cmdline_strerror's text on an error.
801
- */
802
- function splitCmdline(line: string): string[] | string {
803
- // one word to begin with; every whitespace run ends one and starts the next (a trailing
804
- // run leaves an empty last word, as git's)
805
- const args: string[] = [];
806
- let current = "";
807
- let quoted = "";
808
- for (let i = 0; i < line.length; i++) {
809
- const c = line[i] as string;
810
- if (!quoted && /[ \t\n\r]/.test(c)) {
811
- args.push(current);
812
- current = "";
813
- while (i + 1 < line.length && /[ \t\n\r]/.test(line[i + 1] as string)) i++;
814
- } else if (!quoted && (c === "'" || c === '"')) {
815
- quoted = c;
816
- } else if (c === quoted) {
817
- quoted = "";
818
- } else {
819
- if (c === "\\" && quoted !== "'") {
820
- i++;
821
- if (i >= line.length) return "cmdline ends with \\";
822
- }
823
- current += line[i];
824
- }
825
- }
826
- if (quoted) return "unclosed quote";
827
- args.push(current);
828
- return args;
829
- }
830
-
831
799
  function modeLetter(mode: CatFileMode): string {
832
800
  return mode === "type" ? "t" : mode === "size" ? "s" : mode === "exists" ? "e" : "p";
833
801
  }