@statewalker/vcs-commands 0.10.0 → 0.11.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 (72) hide show
  1. package/dist/commands/am/am-command.d.ts.map +1 -1
  2. package/dist/commands/cat-file/cat-file-command.d.ts +9 -0
  3. package/dist/commands/cat-file/cat-file-command.d.ts.map +1 -1
  4. package/dist/commands/checkout-command.d.ts.map +1 -1
  5. package/dist/commands/clone-command.d.ts +9 -0
  6. package/dist/commands/clone-command.d.ts.map +1 -1
  7. package/dist/commands/default-branch.d.ts +12 -0
  8. package/dist/commands/default-branch.d.ts.map +1 -1
  9. package/dist/commands/diff-command.d.ts.map +1 -1
  10. package/dist/commands/format-rev-command.d.ts +6 -4
  11. package/dist/commands/format-rev-command.d.ts.map +1 -1
  12. package/dist/commands/fsmonitor-ipc.d.ts +30 -0
  13. package/dist/commands/fsmonitor-ipc.d.ts.map +1 -0
  14. package/dist/commands/fsmonitor-refresh.d.ts.map +1 -1
  15. package/dist/commands/index.d.ts +1 -0
  16. package/dist/commands/index.d.ts.map +1 -1
  17. package/dist/commands/index.js +6 -6
  18. package/dist/commands/log-output.d.ts +6 -0
  19. package/dist/commands/log-output.d.ts.map +1 -1
  20. package/dist/commands/ls-tree-command.d.ts.map +1 -1
  21. package/dist/commands/repo-command.d.ts +28 -6
  22. package/dist/commands/repo-command.d.ts.map +1 -1
  23. package/dist/commands/reset-command.d.ts +19 -2
  24. package/dist/commands/reset-command.d.ts.map +1 -1
  25. package/dist/commands/rev-parse-command.d.ts +3 -7
  26. package/dist/commands/rev-parse-command.d.ts.map +1 -1
  27. package/dist/commands/revision-resolver.d.ts +15 -1
  28. package/dist/commands/revision-resolver.d.ts.map +1 -1
  29. package/dist/commands/signing.d.ts +8 -1
  30. package/dist/commands/signing.d.ts.map +1 -1
  31. package/dist/commands/status-command.d.ts +14 -1
  32. package/dist/commands/status-command.d.ts.map +1 -1
  33. package/dist/commands/submodule-add-command.d.ts +12 -0
  34. package/dist/commands/submodule-add-command.d.ts.map +1 -1
  35. package/dist/commands/submodule-update-command.d.ts +14 -0
  36. package/dist/commands/submodule-update-command.d.ts.map +1 -1
  37. package/dist/commands/tag-command.d.ts.map +1 -1
  38. package/dist/commands/update-index-command.d.ts +21 -0
  39. package/dist/commands/update-index-command.d.ts.map +1 -1
  40. package/dist/{commands-Mlo1dxQN.js → commands-bQQ9OmCh.js} +354 -77
  41. package/dist/{fsck-CrhVMNIH.js → fsck-BHT9bUS-.js} +1 -1
  42. package/dist/git-command.d.ts +8 -2
  43. package/dist/git-command.d.ts.map +1 -1
  44. package/dist/index.js +6 -6
  45. package/dist/{maintenance-run-command-Bw21HEkH.js → maintenance-run-command-Cx2PlGV9.js} +9 -4
  46. package/dist/{remote-transport-Bu4PGSMD.js → remote-transport-BrQZfyHu.js} +3 -3
  47. package/dist/results/index.js +1 -1
  48. package/dist/{results-ERo9vELd.js → results-CNHQnU5Y.js} +327 -54
  49. package/package.json +12 -12
  50. package/src/commands/am/am-command.ts +30 -14
  51. package/src/commands/cat-file/cat-file-command.ts +46 -8
  52. package/src/commands/checkout-command.ts +22 -1
  53. package/src/commands/clone-command.ts +41 -2
  54. package/src/commands/default-branch.ts +19 -0
  55. package/src/commands/diff-command.ts +19 -1
  56. package/src/commands/format-rev-command.ts +28 -12
  57. package/src/commands/fsmonitor-ipc.ts +121 -0
  58. package/src/commands/fsmonitor-refresh.ts +7 -2
  59. package/src/commands/index.ts +1 -0
  60. package/src/commands/log-output.ts +11 -0
  61. package/src/commands/ls-tree-command.ts +25 -1
  62. package/src/commands/repo-command.ts +124 -25
  63. package/src/commands/reset-command.ts +75 -3
  64. package/src/commands/rev-parse-command.ts +14 -28
  65. package/src/commands/revision-resolver.ts +53 -11
  66. package/src/commands/signing.ts +54 -7
  67. package/src/commands/status-command.ts +31 -2
  68. package/src/commands/submodule-add-command.ts +18 -1
  69. package/src/commands/submodule-update-command.ts +18 -1
  70. package/src/commands/tag-command.ts +33 -11
  71. package/src/commands/update-index-command.ts +137 -5
  72. package/src/git-command.ts +48 -4
@@ -77,7 +77,7 @@ export interface RevisionSources {
77
77
  * The object store, for abbreviated ids (its `listPrefix`, else `list`); without it the
78
78
  * typed stores' `keys()` are listed
79
79
  */
80
- objects?: Pick<GitObjects, "list" | "listPrefix" | "objectFormat">;
80
+ objects?: Pick<GitObjects, "list" | "listPrefix" | "objectFormat" | "compat">;
81
81
  /**
82
82
  * The lengths git abbreviates ids to (`repo_find_unique_abbrev` with `core.abbrev`), for
83
83
  * the candidates of an ambiguous short id; 7 digits without it
@@ -119,6 +119,13 @@ export interface ResolveOptions {
119
119
  * searched
120
120
  */
121
121
  onlyToDie?: boolean;
122
+ /**
123
+ * git's `GET_OID_HASH_ANY` (`cat-file`, `ls-tree`, `rev-parse --output-object-format`): in
124
+ * a repository with a compatibility object format, an abbreviated or full id of that format
125
+ * names the object too, and is given back as it is (an id of the compatibility format's
126
+ * length), the storage and mapped compatibility ids disambiguated together
127
+ */
128
+ hashAny?: boolean;
122
129
  }
123
130
 
124
131
  /** git's `get_short_oid` result. */
@@ -200,6 +207,13 @@ export class RevisionResolver {
200
207
  lastMode: number | undefined;
201
208
  private config?: RemoteConfigStore;
202
209
  private disambiguateChecked = false;
210
+ /**
211
+ * Whether an abbreviation missed: git's get_short_oid then runs `odb_reprepare`, which
212
+ * flushes the loose object cache the map had put the compatibility ids into, and nothing
213
+ * puts them back, so the rest of the process finds no compatibility id by `GET_OID_HASH_ANY`
214
+ * (git master: `echo <miss> <compat id> | git cat-file --batch-check` reports both missing)
215
+ */
216
+ private compatIdsFlushed = false;
203
217
  /** Refs read while resolving one revision (`HEAD~3` reads HEAD once) */
204
218
  private readonly refCache = new Map<string, Promise<{ id: ObjectId; ref: string } | undefined>>();
205
219
 
@@ -834,6 +848,11 @@ export class RevisionResolver {
834
848
 
835
849
  /** The type of an object, undefined when the repository does not have it. */
836
850
  async objectType(id: ObjectId): Promise<ObjectType | undefined> {
851
+ const compat = this.sources.objects?.compat;
852
+ if (compat && id.length !== this.hexLength && id.length === compat.compat.hexLength) {
853
+ // an id of the compatibility format (GET_OID_HASH_ANY): its object as converted
854
+ return (await safe(() => compat.readAsCompat(id)))?.type;
855
+ }
837
856
  const { commits, tags, trees, blobs } = this.sources;
838
857
  if (await safe(() => commits.has(id))) return "commit";
839
858
  if (tags && (await safe(() => tags.has(id)))) return "tag";
@@ -1076,16 +1095,26 @@ export class RevisionResolver {
1076
1095
  * when it accepts several.
1077
1096
  */
1078
1097
  private async shortOid(name: string, flags: ResolveOptions = {}): Promise<ShortOid> {
1079
- if (
1080
- name.length < MINIMUM_ABBREV_LENGTH ||
1081
- name.length > this.hexLength ||
1082
- !HEX_DIGITS.test(name)
1083
- ) {
1098
+ // GET_OID_HASH_ANY: the prefix may be of either format (init_object_disambiguation takes
1099
+ // up to GIT_MAX_HEXSZ digits), the map's compatibility ids searched beside the objects
1100
+ const compat =
1101
+ flags.hashAny && !this.compatIdsFlushed ? this.sources.objects?.compat : undefined;
1102
+ const maxLength = Math.max(this.hexLength, compat?.compat.hexLength ?? 0);
1103
+ if (name.length < MINIMUM_ABBREV_LENGTH || name.length > maxLength || !HEX_DIGITS.test(name)) {
1084
1104
  return { status: "invalid" };
1085
1105
  }
1086
1106
  const prefix = name.toLowerCase();
1087
- const candidates = await this.objectsWithPrefix(prefix);
1088
- if (candidates.length === 0) return { status: "missing" };
1107
+ const candidates = name.length <= this.hexLength ? await this.objectsWithPrefix(prefix) : [];
1108
+ if (compat && name.length <= compat.compat.hexLength) {
1109
+ const ids = await compat.compatIdsWithPrefix(prefix);
1110
+ // the reserved mappings (empty tree and blob, null id) are in git's cache too
1111
+ for (const id of ids) if (!candidates.includes(id)) candidates.push(id);
1112
+ candidates.sort();
1113
+ }
1114
+ if (candidates.length === 0) {
1115
+ if (this.sources.objects?.compat) this.compatIdsFlushed = true;
1116
+ return { status: "missing" };
1117
+ }
1089
1118
  const hint = flags.hint ?? this.defaultHint();
1090
1119
  let status: ShortOid;
1091
1120
  let listedHint = hint;
@@ -1117,17 +1146,30 @@ export class RevisionResolver {
1117
1146
  ): Promise<void> {
1118
1147
  const typed: { id: ObjectId; type: ObjectType | undefined }[] = [];
1119
1148
  for (const id of candidates) typed.push({ id, type: await this.objectType(id) });
1120
- // tags, commits, trees, blobs (git's type % 4); by id within a type
1149
+ // tags, commits, trees, blobs (git's type % 4); within a type by hash algorithm (SHA-1
1150
+ // ids, the shorter, before SHA-256 ones: oidcmp's algo order), then by id
1121
1151
  const rank = (t: ObjectType | undefined) =>
1122
1152
  t === "tag" ? 0 : t === "commit" ? 1 : t === "tree" ? 2 : t === "blob" ? 3 : -1;
1123
1153
  typed.sort((a, b) =>
1124
- rank(a.type) !== rank(b.type) ? rank(a.type) - rank(b.type) : a.id < b.id ? -1 : 1,
1154
+ rank(a.type) !== rank(b.type)
1155
+ ? rank(a.type) - rank(b.type)
1156
+ : a.id.length !== b.id.length
1157
+ ? a.id.length - b.id.length
1158
+ : a.id < b.id
1159
+ ? -1
1160
+ : 1,
1125
1161
  );
1126
1162
  const shown: typeof typed = [];
1127
1163
  for (const c of typed)
1128
1164
  if (hint === undefined || (await this.satisfies(c.id, hint))) shown.push(c);
1165
+ // compatibility ids are abbreviated to the default 7 digits (only storage ids are
1166
+ // measured against the repository)
1129
1167
  const lengths =
1130
- (await safe(async () => this.sources.abbreviate?.(shown.map((c) => c.id)))) ?? undefined;
1168
+ (await safe(async () =>
1169
+ this.sources.abbreviate?.(
1170
+ shown.filter((c) => c.id.length === this.hexLength).map((c) => c.id),
1171
+ ),
1172
+ )) ?? undefined;
1131
1173
  const lines = [`error: short object ID ${prefix} is ambiguous`, "hint: The candidates are:"];
1132
1174
  for (const { id, type } of shown) {
1133
1175
  const hash = id.slice(0, lengths?.get(id) ?? 7);
@@ -27,7 +27,12 @@
27
27
  * alternative, warning and going on unsigned (friendlier to hosts that set `gpgSign`
28
28
  * globally), was not taken; switch only on the human's word.
29
29
  */
30
- import { type Commit, collectCommitBytes, type PersonIdent } from "@statewalker/vcs-core";
30
+ import {
31
+ type AnnotatedTag,
32
+ type Commit,
33
+ collectCommitBytes,
34
+ type PersonIdent,
35
+ } from "@statewalker/vcs-core";
31
36
  import { createSha256, parseGitBool } from "@statewalker/vcs-utils";
32
37
  import {
33
38
  expandUserPath,
@@ -386,18 +391,60 @@ export async function signCommit(
386
391
  options: Omit<SignPayloadOptions, "committer"> = {},
387
392
  ): Promise<Commit> {
388
393
  if (sign === undefined) return commit;
389
- const { gpgSignature: _dropped, ...unsigned } = commit;
394
+ const { gpgSignature: _dropped, compatSignature: _droppedCompat, ...unsigned } = commit;
390
395
  const payload = await collectCommitBytes(unsigned);
396
+ const signOptions = { ...options, committer: commit.committer };
391
397
  const signature = new TextDecoder().decode(
392
- await signPayload(workingCopy, sign, payload, { ...options, committer: commit.committer }),
398
+ await signPayload(workingCopy, sign, payload, signOptions),
393
399
  );
394
400
  // add_header_signature: every line of the signature with its newline, the first after the
395
401
  // header's name and a space, the others after a space; the header ends with the
396
402
  // signature's last newline (the commit model holds the lines without it)
397
- return {
398
- ...unsigned,
399
- gpgSignature: signature.endsWith("\n") ? signature.slice(0, -1) : signature,
400
- };
403
+ const signed: Commit = { ...unsigned, gpgSignature: headerSignature(signature) };
404
+ // commit_tree_extended in a repository with a compatibility object format: the commit as
405
+ // that format sees it (its ids mapped) signed too, and both signatures in both objects, so
406
+ // the compatibility id the store computes covers a signature in its own format
407
+ const compat = workingCopy.history.objects?.compat;
408
+ if (compat) {
409
+ const compatPayload = await compat.convertToCompat("commit", payload);
410
+ const compatSignature = new TextDecoder().decode(
411
+ await signPayload(workingCopy, sign, compatPayload, signOptions),
412
+ );
413
+ signed.compatSignature = {
414
+ header: compat.compat.signatureHeader,
415
+ value: headerSignature(compatSignature),
416
+ };
417
+ }
418
+ return signed;
419
+ }
420
+
421
+ /**
422
+ * A signature as a header holds it: its lines without the last newline (add_header_signature
423
+ * writes each line with its newline).
424
+ */
425
+ function headerSignature(signature: string): string {
426
+ return signature.endsWith("\n") ? signature.slice(0, -1) : signature;
427
+ }
428
+
429
+ /**
430
+ * builtin/tag.c `do_sign` in a repository with a compatibility object format: the tag as
431
+ * that format sees it signed too, its signature to go in the tag's header (the storage
432
+ * signature ends the message), so the tag's compatibility id covers a signature in its own
433
+ * format. Undefined without a compatibility format.
434
+ */
435
+ export async function signTagCompat(
436
+ workingCopy: WorkingCopy,
437
+ sign: string,
438
+ payload: Uint8Array,
439
+ options: SignPayloadOptions,
440
+ ): Promise<AnnotatedTag["compatSignature"]> {
441
+ const compat = workingCopy.history.objects?.compat;
442
+ if (!compat) return undefined;
443
+ const compatPayload = await compat.convertToCompat("tag", payload);
444
+ const signature = new TextDecoder().decode(
445
+ await signPayload(workingCopy, sign, compatPayload, options),
446
+ );
447
+ return { header: compat.compat.signatureHeader, value: headerSignature(signature) };
401
448
  }
402
449
 
403
450
  /** A uint32 length-prefixed string of an ssh wire buffer at `at`. */
@@ -218,6 +218,22 @@ async function concat(chunks: AsyncIterable<Uint8Array> | Iterable<Uint8Array>)
218
218
  export interface SubmoduleDirt {
219
219
  modified?: boolean;
220
220
  untracked?: boolean;
221
+ /**
222
+ * The repository could not be looked into because git opens it and we do not (an
223
+ * `extensions.objectStorage` payload): its warning lines. Its own changes are then unknown
224
+ * (no `modified`/`untracked`); a commit other than the index's still shows, read from refs.
225
+ */
226
+ unreadable?: string[];
227
+ }
228
+
229
+ /**
230
+ * The warning lines for a submodule we cannot look into (git opens it, we do not), or
231
+ * undefined for any other failure, which stays fatal as git's child status dies on it.
232
+ */
233
+ export function submoduleNotSupportedWarning(path: string, error: unknown): string[] | undefined {
234
+ if (!(error instanceof Error) || error.name !== "UnsupportedRepositoryFormatError") return;
235
+ if (!(error as { notSupportedHere?: boolean }).notSupportedHere) return;
236
+ return [`warning: cannot look into submodule '${path}': ${error.message}`];
221
237
  }
222
238
 
223
239
  /**
@@ -227,14 +243,23 @@ export interface SubmoduleDirt {
227
243
  * untracked content; any other change, a nested submodule's included, is modified content.
228
244
  * Nothing for a submodule that is not populated (or that the worktree cannot open). A
229
245
  * configuration the inner status cannot read fails with its messages and git's
230
- * `'git status --porcelain=2' failed in submodule <path>`.
246
+ * `'git status --porcelain=2' failed in submodule <path>`. A repository git opens and we do
247
+ * not (an `extensions.objectStorage` payload, statewalker/webrun-vcs#441) is no failure of
248
+ * the superproject: its state is `unreadable`, with a warning.
231
249
  */
232
250
  export async function readSubmoduleDirt(
233
251
  worktree: Worktree,
234
252
  path: string,
235
253
  ignoreUntracked: boolean,
236
254
  ): Promise<SubmoduleDirt> {
237
- const inner: WorkingCopy | undefined = await worktree.openGitlink?.(path);
255
+ let inner: WorkingCopy | undefined;
256
+ try {
257
+ inner = await worktree.openGitlink?.(path);
258
+ } catch (error) {
259
+ const unreadable = submoduleNotSupportedWarning(path, error);
260
+ if (unreadable) return { unreadable };
261
+ throw error;
262
+ }
238
263
  if (!inner) return {};
239
264
  // `git status --porcelain=2` there, with `-uno` when untracked content is ignored
240
265
  const command = new StatusCommand(inner).setRenames(false);
@@ -878,6 +903,8 @@ export class StatusCommand extends GitCommand<Status> {
878
903
  const indexTime = this.staging.getUpdateTime();
879
904
  const gitlinks = new Set<string>();
880
905
  const refresh: IndexStatUpdate[] = [];
906
+ // submodules we cannot look into (a repository git opens and we do not)
907
+ const submoduleWarnings: string[] = [];
881
908
  const unmerged = new Map<string, [StatusSide?, StatusSide?, StatusSide?]>();
882
909
  // the `.gitignore` files whose entry is up to date (git's ce_uptodate after its refresh):
883
910
  // the untracked cache takes their ids from the index
@@ -1005,6 +1032,7 @@ export class StatusCommand extends GitCommand<Status> {
1005
1032
  // a populated submodule's own index and worktree (git's is_submodule_modified)
1006
1033
  if (flags && !flags.dirty && result.worktreeEntry?.isDirectory) {
1007
1034
  dirt = await readSubmoduleDirt(worktree, entry.path, flags.untracked);
1035
+ if (dirt.unreadable) submoduleWarnings.push(...dirt.unreadable);
1008
1036
  }
1009
1037
  if (result.kind === "deleted") {
1010
1038
  y = "D";
@@ -1065,6 +1093,7 @@ export class StatusCommand extends GitCommand<Status> {
1065
1093
 
1066
1094
  const renamed = new Map<string, string>();
1067
1095
  const warnings: string[] = (fsm?.warnings ?? []).map((w) => `warning: ${w}`);
1096
+ warnings.push(...submoduleWarnings);
1068
1097
  const renameMode = this.renameMode();
1069
1098
  if (renameMode) await this.pairRenames(files, renamed, worktree, warnings, renameMode);
1070
1099
 
@@ -3,14 +3,15 @@
3
3
  * `clone_submodule`, `configure_added_submodule`), over the submodule model of
4
4
  * `submodule-model.ts` and the clone, checkout and add commands.
5
5
  */
6
+
6
7
  import { FileMode } from "@statewalker/vcs-core";
7
8
  import type { GitTransportRegistry, HttpCredentialHelper } from "@statewalker/vcs-transport";
8
9
  import { wildmatch } from "@statewalker/vcs-working-tree";
9
-
10
10
  import { GitApiError } from "../errors/index.js";
11
11
  import { RemoteConfigStore } from "../remote-config/index.js";
12
12
  import { AddCommand } from "./add-command.js";
13
13
  import { CheckoutCommand } from "./checkout-command.js";
14
+ import { unknownObjectStorageFormat } from "./default-branch.js";
14
15
  import { checkSubmoduleName } from "./fsck/fsck-object-checks.js";
15
16
  import { gitFileOf } from "./git-hooks.js";
16
17
  import { DO_MATCH_DIRECTORY, matchPathspec, parsePathspec } from "./pathspec.js";
@@ -153,6 +154,7 @@ export class SubmoduleAddCommand extends SubmoduleCommandBase {
153
154
  private force = false;
154
155
  private reference?: string;
155
156
  private depth?: number;
157
+ private objectStorageFormat?: string;
156
158
  private transports?: GitTransportRegistry;
157
159
  private credentialHelper?: HttpCredentialHelper;
158
160
  private warningCallback?: (line: string) => void;
@@ -199,6 +201,17 @@ export class SubmoduleAddCommand extends SubmoduleCommandBase {
199
201
  return this;
200
202
  }
201
203
 
204
+ /**
205
+ * `--object-storage-format=<name>` (git master): the object storage of the submodules
206
+ * cloned. Only `files` is a name git knows (the repository as always); anything else,
207
+ * `files://<dir>` included, dies `unknown object storage format '<v>'` before any work.
208
+ */
209
+ setObjectStorageFormat(format: string): this {
210
+ this.checkCallable();
211
+ this.objectStorageFormat = format;
212
+ return this;
213
+ }
214
+
202
215
  /** `--depth <n>`: a shallow clone (ignored, with git's warning, for a local path). */
203
216
  setDepth(depth: number): this {
204
217
  this.checkCallable();
@@ -232,6 +245,10 @@ export class SubmoduleAddCommand extends SubmoduleCommandBase {
232
245
 
233
246
  async call(): Promise<SubmoduleCommandResult> {
234
247
  this.start();
248
+ if (this.objectStorageFormat !== undefined) {
249
+ const unknown = unknownObjectStorageFormat(this.objectStorageFormat, "name");
250
+ if (unknown) this.die(unknown);
251
+ }
235
252
  if (!(await this.writingGitmodulesOk())) {
236
253
  this.die("fatal: please make sure that the .gitmodules file is in the working tree");
237
254
  }
@@ -5,6 +5,7 @@
5
5
  * `compute_rev_name`), over the submodule model of `submodule-model.ts`, the clone, fetch,
6
6
  * checkout, merge and rebase commands.
7
7
  */
8
+
8
9
  import type { ObjectId } from "@statewalker/vcs-core";
9
10
  import {
10
11
  type Credentials,
@@ -14,12 +15,12 @@ import {
14
15
  } from "@statewalker/vcs-transport";
15
16
  import type { PosixFilesApi } from "@statewalker/vcs-utils/files";
16
17
  import { type WorkingCopy, wildmatch } from "@statewalker/vcs-working-tree";
17
-
18
18
  import { GitApiError } from "../errors/index.js";
19
19
  import { GitCommand } from "../git-command.js";
20
20
  import { RemoteConfigStore } from "../remote-config/index.js";
21
21
  import { CheckoutCommand, CheckoutStatus } from "./checkout-command.js";
22
22
  import { createIdAbbreviator } from "./core-config.js";
23
+ import { unknownObjectStorageFormat } from "./default-branch.js";
23
24
  import { DiffCommand } from "./diff-command.js";
24
25
  import { FetchCommand } from "./fetch-command.js";
25
26
  import { createDescriber } from "./git-describe.js";
@@ -244,6 +245,7 @@ export class SubmoduleUpdateCommand extends SubmoduleCommandBase {
244
245
  private requireInit = false;
245
246
  /** `--filter=<spec>` of the clones */
246
247
  private filter?: string;
248
+ private objectStorageFormat?: string;
247
249
  /** `--[no-]single-branch` of the clones */
248
250
  private singleBranch?: boolean;
249
251
  private transports?: GitTransportRegistry;
@@ -331,6 +333,17 @@ export class SubmoduleUpdateCommand extends SubmoduleCommandBase {
331
333
  return this;
332
334
  }
333
335
 
336
+ /**
337
+ * `--object-storage-format=<name>` (git master): the object storage of the submodules
338
+ * cloned. Only `files` is a name git knows (the repository as always); anything else,
339
+ * `files://<dir>` included, dies `unknown object storage format '<v>'` before any work.
340
+ */
341
+ setObjectStorageFormat(format: string): this {
342
+ this.checkCallable();
343
+ this.objectStorageFormat = format;
344
+ return this;
345
+ }
346
+
334
347
  /** `--filter=<spec>`: partial clones of the submodules (`CloneCommand.setFilter`). */
335
348
  setFilter(spec: string | undefined): this {
336
349
  this.checkCallable();
@@ -485,6 +498,10 @@ export class SubmoduleUpdateCommand extends SubmoduleCommandBase {
485
498
 
486
499
  async call(): Promise<SubmoduleCommandResult> {
487
500
  this.start();
501
+ if (this.objectStorageFormat !== undefined) {
502
+ const unknown = unknownObjectStorageFormat(this.objectStorageFormat, "name");
503
+ if (unknown) this.die(unknown);
504
+ }
488
505
  if (this.requireInit) this.init = true;
489
506
  const list = await this.moduleList(this.paths);
490
507
  if (!list) return this.finish();
@@ -35,7 +35,7 @@ import {
35
35
  type RefSortKey,
36
36
  signatureStart,
37
37
  } from "./ref-filter/index.js";
38
- import { SigningFailedError, signPayload } from "./signing.js";
38
+ import { SigningFailedError, signPayload, signTagCompat } from "./signing.js";
39
39
  import {
40
40
  amendWithTrailers,
41
41
  type TrailerCommandRunner,
@@ -504,13 +504,18 @@ export class TagCommand extends GitCommand<Ref> {
504
504
  // build_tag_object signs before writing (do_sign): the signature appended to the tag
505
505
  // object, so to its message
506
506
  if (sign) {
507
- const signature = await this.signTag(
508
- await collectTagBytes(tag),
509
- tagger,
510
- compatibility,
511
- warnings,
512
- );
513
- if (signature) tag.message = `${message}${new TextDecoder().decode(signature)}`;
507
+ const payload = await collectTagBytes(tag);
508
+ const signature = await this.signTag(payload, tagger, compatibility, warnings);
509
+ if (signature) {
510
+ tag.message = `${message}${new TextDecoder().decode(signature)}`;
511
+ // with a compatibility object format do_sign signs the converted tag too and puts
512
+ // that signature in the header (so in both objects: the conversion moves each
513
+ // signature to where its own format keeps it)
514
+ const compatSignature = await this.signTag(payload, tagger, compatibility, warnings, {
515
+ compat: true,
516
+ });
517
+ if (compatSignature) tag.compatSignature = compatSignature;
518
+ }
514
519
  }
515
520
  tagObjectId = await this.tagsStore.storeTag(tag);
516
521
  } else {
@@ -640,7 +645,21 @@ export class TagCommand extends GitCommand<Ref> {
640
645
  tagger: PersonIdent,
641
646
  compatibility: "2.43" | "2.56",
642
647
  warnings: string[],
643
- ): Promise<Uint8Array | undefined> {
648
+ ): Promise<Uint8Array | undefined>;
649
+ private async signTag(
650
+ payload: Uint8Array,
651
+ tagger: PersonIdent,
652
+ compatibility: "2.43" | "2.56",
653
+ warnings: string[],
654
+ options: { compat: true },
655
+ ): Promise<AnnotatedTag["compatSignature"]>;
656
+ private async signTag(
657
+ payload: Uint8Array,
658
+ tagger: PersonIdent,
659
+ compatibility: "2.43" | "2.56",
660
+ warnings: string[],
661
+ options?: { compat: true },
662
+ ): Promise<Uint8Array | AnnotatedTag["compatSignature"]> {
644
663
  const gitDir = (await this.hooks.hostGitDir({ real: false }).catch(() => undefined))?.replace(
645
664
  /\/+$/,
646
665
  "",
@@ -654,11 +673,14 @@ export class TagCommand extends GitCommand<Ref> {
654
673
  : `${gitDir}/TAG_EDITMSG`;
655
674
  const cwd = await this.hooks.hostWorkingDirectory().catch(() => undefined);
656
675
  try {
657
- return await signPayload(this.workingCopy, this.signingKey ?? "", payload, {
676
+ const signOptions = {
658
677
  committer: tagger,
659
678
  ...(cwd !== undefined ? { cwd } : {}),
660
679
  tail: ["error: unable to sign the tag", `The tag message has been left in ${path}`],
661
- });
680
+ };
681
+ const key = this.signingKey ?? "";
682
+ if (options?.compat) return await signTagCompat(this.workingCopy, key, payload, signOptions);
683
+ return await signPayload(this.workingCopy, key, payload, signOptions);
662
684
  } catch (e) {
663
685
  if (!(e instanceof SigningFailedError)) throw e;
664
686
  // git 2.43's do_sign fails only on a negative return, and its sign_buffer_ssh returns