@statewalker/vcs-commands 0.11.0 → 0.13.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 (65) hide show
  1. package/dist/commands/archive/archive-command.d.ts +81 -7
  2. package/dist/commands/archive/archive-command.d.ts.map +1 -1
  3. package/dist/commands/archive/archive-entry.d.ts +48 -5
  4. package/dist/commands/archive/archive-entry.d.ts.map +1 -1
  5. package/dist/commands/archive/tar-archive.d.ts +5 -2
  6. package/dist/commands/archive/tar-archive.d.ts.map +1 -1
  7. package/dist/commands/archive/zip-archive.d.ts +9 -2
  8. package/dist/commands/archive/zip-archive.d.ts.map +1 -1
  9. package/dist/commands/attributes-source.d.ts +5 -0
  10. package/dist/commands/attributes-source.d.ts.map +1 -1
  11. package/dist/commands/cat-file/cat-file-command.d.ts.map +1 -1
  12. package/dist/commands/http-config.d.ts +4 -2
  13. package/dist/commands/http-config.d.ts.map +1 -1
  14. package/dist/commands/index.d.ts +1 -0
  15. package/dist/commands/index.d.ts.map +1 -1
  16. package/dist/commands/index.js +6 -6
  17. package/dist/commands/ls-files-command.d.ts.map +1 -1
  18. package/dist/commands/ls-tree-command.d.ts.map +1 -1
  19. package/dist/commands/mv-command.d.ts.map +1 -1
  20. package/dist/commands/pathspec.d.ts.map +1 -1
  21. package/dist/commands/plumbing-shared.d.ts +72 -0
  22. package/dist/commands/plumbing-shared.d.ts.map +1 -0
  23. package/dist/commands/repack-command.d.ts +12 -3
  24. package/dist/commands/repack-command.d.ts.map +1 -1
  25. package/dist/commands/replace-command.d.ts.map +1 -1
  26. package/dist/commands/rerere-command.d.ts +12 -0
  27. package/dist/commands/rerere-command.d.ts.map +1 -1
  28. package/dist/commands/rerere.d.ts +22 -0
  29. package/dist/commands/rerere.d.ts.map +1 -1
  30. package/dist/commands/revision-resolver.d.ts +9 -4
  31. package/dist/commands/revision-resolver.d.ts.map +1 -1
  32. package/dist/{commands-bQQ9OmCh.js → commands-CPceUCP2.js} +595 -223
  33. package/dist/{fsck-BHT9bUS-.js → fsck-tbrPZX2q.js} +1 -1
  34. package/dist/git-command.d.ts +6 -4
  35. package/dist/git-command.d.ts.map +1 -1
  36. package/dist/index.js +6 -6
  37. package/dist/{maintenance-run-command-Cx2PlGV9.js → maintenance-run-command-UiSIaeP8.js} +43 -17
  38. package/dist/remote-config/remote-config-store.d.ts +4 -1
  39. package/dist/remote-config/remote-config-store.d.ts.map +1 -1
  40. package/dist/{remote-transport-BrQZfyHu.js → remote-transport-C0OSJtor.js} +3 -3
  41. package/dist/results/index.js +1 -1
  42. package/dist/{results-CNHQnU5Y.js → results-CkS1p1CH.js} +378 -52
  43. package/dist/transport-command.d.ts.map +1 -1
  44. package/package.json +12 -12
  45. package/src/commands/archive/archive-command.ts +395 -59
  46. package/src/commands/archive/archive-entry.ts +88 -5
  47. package/src/commands/archive/tar-archive.ts +40 -9
  48. package/src/commands/archive/zip-archive.ts +72 -21
  49. package/src/commands/attributes-source.ts +13 -1
  50. package/src/commands/cat-file/cat-file-command.ts +18 -44
  51. package/src/commands/http-config.ts +60 -2
  52. package/src/commands/index.ts +1 -0
  53. package/src/commands/ls-files-command.ts +25 -33
  54. package/src/commands/ls-tree-command.ts +5 -21
  55. package/src/commands/mv-command.ts +37 -6
  56. package/src/commands/pathspec.ts +2 -4
  57. package/src/commands/plumbing-shared.ts +197 -0
  58. package/src/commands/repack-command.ts +45 -12
  59. package/src/commands/replace-command.ts +16 -4
  60. package/src/commands/rerere-command.ts +17 -0
  61. package/src/commands/rerere.ts +144 -3
  62. package/src/commands/revision-resolver.ts +32 -23
  63. package/src/git-command.ts +17 -20
  64. package/src/remote-config/remote-config-store.ts +11 -3
  65. package/src/transport-command.ts +4 -1
@@ -13,6 +13,7 @@
13
13
  import { rerereGc } from "@statewalker/vcs-store-files";
14
14
  import { unifiedDiff } from "@statewalker/vcs-utils";
15
15
  import { decodeGitPath, encodeGitPath } from "@statewalker/vcs-utils/encoding";
16
+ import type { RerereEngine } from "@statewalker/vcs-working-tree/transformation";
16
17
 
17
18
  import { GitCommand } from "../git-command.js";
18
19
  import type { PlumbingTextOutput } from "./check-ref-format-command.js";
@@ -23,6 +24,7 @@ import {
23
24
  type RerereHost,
24
25
  rerereClear,
25
26
  rerereDiff,
27
+ rerereEngineOf,
26
28
  rerereForget,
27
29
  rerereGcLocation,
28
30
  rerereRemaining,
@@ -75,6 +77,21 @@ export class RerereCommand extends GitCommand<PlumbingTextOutput> {
75
77
  return this;
76
78
  }
77
79
 
80
+ /**
81
+ * git's rerere for a resolution store (vcs-store-files `GitResolutionStore`): its records
82
+ * written and replayed as `git rerere` does ({@link rerereEngineOf}); undefined without a
83
+ * worktree. Give the store the index this command reads (`workingCopy.checkout.staging`).
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * const store = createResolutionStore(files, staging, blobs, ".git", "", git.rerere().engine());
88
+ * ```
89
+ */
90
+ engine(): RerereEngine | undefined {
91
+ const host = this.rerereHost();
92
+ return host && rerereEngineOf(host);
93
+ }
94
+
78
95
  async call(): Promise<PlumbingTextOutput> {
79
96
  this.checkCallable();
80
97
  this.setCallable(false);
@@ -24,6 +24,7 @@ import { decodeGitPath, encodeGitPath, parseGitBool } from "@statewalker/vcs-uti
24
24
  import type { FilesApi } from "@statewalker/vcs-utils/files";
25
25
  import { joinPath } from "@statewalker/vcs-utils/files";
26
26
  import type { Staging, WorkingCopy, Worktree } from "@statewalker/vcs-working-tree";
27
+ import type { RerereEngine, RerereReplay } from "@statewalker/vcs-working-tree/transformation";
27
28
 
28
29
  import { conflictMarkerSizeOf } from "../results/diff-check.js";
29
30
  import { worktreeModeTrust } from "./core-config.js";
@@ -412,6 +413,12 @@ class RerereRun {
412
413
  if (!current) return false;
413
414
  const result = await this.tryMerge(id, path, current);
414
415
  if (!result) return false;
416
+ await this.writeReplayed(id, path, result);
417
+ return true;
418
+ }
419
+
420
+ /** The end of `merge`: a replayed resolution written to the worktree. */
421
+ async writeReplayed(id: RerereId, path: string, result: Uint8Array): Promise<void> {
415
422
  // the resolution was used: its mtime tells rerere gc
416
423
  const postimage = this.path(id, "postimage");
417
424
  if (!(await this.files.touch?.(postimage))) {
@@ -423,7 +430,6 @@ class RerereRun {
423
430
  raw: true,
424
431
  ...(entry && !entry.isDirectory ? { mode: entry.mode } : {}),
425
432
  });
426
- return true;
427
433
  }
428
434
 
429
435
  /** `remove_variant`. */
@@ -826,7 +832,7 @@ async function handleCache(
826
832
  path: string,
827
833
  stages: Stages,
828
834
  output?: string,
829
- ): Promise<{ status: number; id?: string }> {
835
+ ): Promise<{ status: number; id?: string; output?: Uint8Array }> {
830
836
  if (stages.some((s) => s.stage === 0)) return { status: -1 };
831
837
  const read = async (stage: number): Promise<Uint8Array> => {
832
838
  const entry = stages.find((s) => s.stage === stage);
@@ -863,7 +869,7 @@ async function handleCache(
863
869
  run.host.objectFormat,
864
870
  );
865
871
  if (output) await run.writeFile(output, parsed.output);
866
- return { status: parsed.status, ...(parsed.id ? { id: parsed.id } : {}) };
872
+ return { status: parsed.status, output: parsed.output, ...(parsed.id ? { id: parsed.id } : {}) };
867
873
  }
868
874
 
869
875
  /** `rerere_forget_one_path`. */
@@ -923,3 +929,138 @@ export async function rerereGcLocation(
923
929
  if (!location) return undefined;
924
930
  return { files: location.files, gitDir: location.path.replace(/\/?rr-cache$/, "") || "." };
925
931
  }
932
+
933
+ /** `check_one_conflict`'s three-staged conflict: no stage 0, ours and theirs regular files. */
934
+ function threeStaged(stages: Stages): boolean {
935
+ if (stages.length === 0 || stages.some((s) => s.stage === 0)) return false;
936
+ const isRegular = (mode: number | undefined) =>
937
+ mode !== undefined && (mode & 0o170000) === 0o100000;
938
+ return (
939
+ isRegular(stages.find((s) => s.stage === 2)?.mode) &&
940
+ isRegular(stages.find((s) => s.stage === 3)?.mode)
941
+ );
942
+ }
943
+
944
+ async function stagesOf(staging: Staging, path: string): Promise<Stages> {
945
+ return (await staging.getEntries(path)).map((e) => ({
946
+ stage: e.stage,
947
+ mode: e.mode,
948
+ objectId: e.objectId,
949
+ }));
950
+ }
951
+
952
+ /**
953
+ * rerere for a resolution store (`ResolutionStore` of vcs-store-files): its records are
954
+ * git's, written by rerere.c's steps only.
955
+ *
956
+ * `record(path)` is what two `git rerere` runs record for a path, one while it was
957
+ * conflicted and one once resolved: the variant `MERGE_RR` names for the path; else the
958
+ * preimage recreated from the stages as `rerere forget` recreates it (`handle_cache`),
959
+ * nothing recorded when a recorded variant replays cleanly onto it (git's first run would
960
+ * have replayed it; its id is returned), else a new variant (`assign_variant`); then the
961
+ * worktree file as the postimage (`copy_file`: an existing one stays) and the path dropped
962
+ * from `MERGE_RR`.
963
+ * `replay(path)` is `do_rerere_one_path`'s replay over the conflicted worktree file.
964
+ * Nothing is written where rerere is off (`setup_rerere`).
965
+ *
966
+ * @example
967
+ * ```typescript
968
+ * const engine = rerereEngineOf(rerereHostOf(workingCopy, staging, worktree, blobs, format));
969
+ * await engine.record("f"); // "<conflict id>"
970
+ * ```
971
+ */
972
+ export function rerereEngineOf(host: RerereHost): RerereEngine {
973
+ return {
974
+ record: (path) => recordOnePath(host, path),
975
+ replay: (path, options) => replayOnePath(host, path, options?.apply === true),
976
+ };
977
+ }
978
+
979
+ async function recordOnePath(host: RerereHost, path: string): Promise<string | undefined> {
980
+ const run = await setupRerere(host);
981
+ if (!run) return undefined;
982
+ // resolved in the worktree: no conflict hunk left (handle_file's 0)
983
+ if ((await run.handleFile(path, false)).status !== 0) return undefined;
984
+ const rr = await run.readRr();
985
+ const waiting = rr.get(path);
986
+ let id: RerereId;
987
+ if (waiting && waiting.variant >= 0) {
988
+ // the id and variant `git rerere` gave the conflict (do_rerere_one_path's first step)
989
+ id = waiting;
990
+ } else {
991
+ const stages = await stagesOf(host.staging, path);
992
+ if (!threeStaged(stages)) return undefined;
993
+ const { status, id: hex, output } = await handleCache(run, path, stages);
994
+ if (status < 1 || !hex || !output) return undefined;
995
+ id = await run.newId(hex);
996
+ // the first run: a recorded resolution that applies cleanly would have been replayed,
997
+ // and nothing recorded (do_rerere_one_path)
998
+ for (let variant = 0; variant < id.dir.status.length; variant++) {
999
+ if (((id.dir.status[variant] ?? 0) & BOTH) !== BOTH) continue;
1000
+ if (await run.tryMerge({ dir: id.dir, variant }, path, output)) return hex;
1001
+ }
1002
+ run.assignVariant(id);
1003
+ await run.mkdir(run.path(id));
1004
+ if (!((id.dir.status[id.variant] ?? 0) & RR_HAS_PREIMAGE)) {
1005
+ await run.writeFile(run.path(id, "preimage"), output);
1006
+ }
1007
+ }
1008
+ fit(id.dir, id.variant);
1009
+ const bits = id.dir.status[id.variant] ?? 0;
1010
+ // copy_file: O_EXCL, an existing postimage stays
1011
+ const postimage = run.path(id, "postimage");
1012
+ if ((await run.files.stats(postimage)) === undefined) {
1013
+ const content = await run.readWorktree(path);
1014
+ if (!content) return undefined;
1015
+ await run.mkdir(run.path(id));
1016
+ await run.writeFile(postimage, content);
1017
+ }
1018
+ id.dir.status[id.variant] = bits | RR_HAS_POSTIMAGE | RR_HAS_PREIMAGE;
1019
+ if (rr.has(path)) {
1020
+ rr.delete(path);
1021
+ await run.writeRr(rr);
1022
+ }
1023
+ return id.dir.hex;
1024
+ }
1025
+
1026
+ async function replayOnePath(
1027
+ host: RerereHost,
1028
+ path: string,
1029
+ apply: boolean,
1030
+ ): Promise<RerereReplay | undefined> {
1031
+ const run = await setupRerere(host);
1032
+ if (!run) return undefined;
1033
+ if (!threeStaged(await stagesOf(host.staging, path))) return undefined;
1034
+ const content = await run.readWorktree(path);
1035
+ if (!content) return undefined;
1036
+ // thisimage: the file normalised (handle_file), kept in memory
1037
+ const parsed = normalizeConflicts(content, await run.markerSize(path), host.objectFormat);
1038
+ if (parsed.status < 1 || !parsed.id) return undefined;
1039
+ const dir = await run.dir(parsed.id);
1040
+ for (let variant = 0; variant < dir.status.length; variant++) {
1041
+ if (((dir.status[variant] ?? 0) & BOTH) !== BOTH) continue;
1042
+ const id = { dir, variant };
1043
+ // git's `merge` writes the normalised file as the variant's thisimage before it tries
1044
+ if (apply) await run.writeFile(run.path(id, "thisimage"), parsed.output);
1045
+ const merged = await run.tryMerge(id, path, parsed.output);
1046
+ if (!merged) continue;
1047
+ const preimage = await run.readFile(run.path(id, "preimage"));
1048
+ const postimage = await run.readFile(run.path(id, "postimage"));
1049
+ if (!preimage || !postimage) continue;
1050
+ if (apply) {
1051
+ await run.writeReplayed(id, path, merged);
1052
+ const rr = await run.readRr();
1053
+ const waiting = rr.get(path);
1054
+ if (waiting !== undefined) {
1055
+ // a different variant applies cleanly: no point keeping the path's own
1056
+ if (waiting && waiting.dir === dir && waiting.variant >= 0 && waiting.variant !== variant) {
1057
+ await run.removeVariant(waiting);
1058
+ }
1059
+ rr.delete(path);
1060
+ await run.writeRr(rr);
1061
+ }
1062
+ }
1063
+ return { signature: dir.hex, variant, preimage, postimage, content: merged };
1064
+ }
1065
+ return undefined;
1066
+ }
@@ -33,7 +33,6 @@
33
33
 
34
34
  import type { Commit, GitObjects, ObjectId, PersonIdent, Refs } from "@statewalker/vcs-core";
35
35
  import {
36
- decodeTreeBytes,
37
36
  isSymbolicRef,
38
37
  isValidRefName,
39
38
  listObjectsWithPrefix,
@@ -41,6 +40,7 @@ import {
41
40
  objectFormatOf,
42
41
  } from "@statewalker/vcs-core";
43
42
  import { compilePosixRegex, isNullObjectId, parseGitBool } from "@statewalker/vcs-utils";
43
+ import { encodeGitPath } from "@statewalker/vcs-utils/encoding";
44
44
  import type { Staging, WorkingCopy } from "@statewalker/vcs-working-tree";
45
45
 
46
46
  import { RevisionError } from "../errors/index.js";
@@ -49,6 +49,7 @@ import { applyRefspecs } from "./branch-tracking.js";
49
49
  import { configLoadError } from "./core-config.js";
50
50
  import { approxidateCareful, formatRfc2822Date } from "./git-date.js";
51
51
  import { loadLegacyRemote } from "./legacy-remotes.js";
52
+ import { findTreeDescEntry } from "./plumbing-shared.js";
52
53
 
53
54
  /** The stores a revision is read from. */
54
55
  export interface RevisionSources {
@@ -931,40 +932,48 @@ export class RevisionResolver {
931
932
  }
932
933
 
933
934
  /**
934
- * git's `get_tree_entry` / `find_tree_entry`: the object at `path` in a tree (the tree
935
- * itself for ""). Components are matched exactly: an empty one (`/a`, `d//b`) names
936
- * nothing, and a trailing `/` only follows a directory (`d/` is d, `a.txt/` nothing).
935
+ * git's `get_tree_entry`: the object at `path` in a tree (the tree itself for ""), found
936
+ * as `find_tree_entry` walks the tree's stored bytes (names unchecked, so an entry named
937
+ * `..` is found; a corrupt tree git's death, {@link CorruptTreeError}). A store without
938
+ * stored bytes answers from its decoded entries, component by component.
937
939
  */
938
- private async findTreeEntry(
939
- tree: ObjectId,
940
- name: string,
941
- ): Promise<{ id: ObjectId; mode: number } | undefined> {
940
+ private async treeEntry(tree: ObjectId, path: string): Promise<ObjectId | undefined> {
941
+ if (path === "") return tree;
942
942
  const trees = this.sources.trees;
943
- try {
944
- return await trees.getEntry(tree, name);
945
- } catch (e) {
946
- if ((e as Error)?.name !== "InvalidTreeEntryNameError" || !trees.raw) return undefined;
947
- const raw = await safe(() => trees.raw?.(tree) ?? Promise.resolve(undefined));
943
+ if (!trees.raw) return this.treeEntryDecoded(tree, path);
944
+ const rawLength = objectFormatOf(this.sources.objects).rawLength;
945
+ let current = tree;
946
+ let rest = encodeGitPath(path);
947
+ for (;;) {
948
+ const id = current;
949
+ const raw = await safe(() => trees.raw?.(id) ?? Promise.resolve(undefined));
950
+ // an empty tree holds nothing (get_tree_entry's `!size`)
948
951
  if (!raw) return undefined;
949
- const entries = decodeTreeBytes(raw, {
950
- canonicalModes: true,
951
- idLength: objectFormatOf(this.sources.objects).rawLength,
952
- checkNames: false,
953
- });
954
- const found = entries.find((e) => e.name === name);
955
- return found ? { id: found.id, mode: found.mode } : undefined;
952
+ const found = findTreeDescEntry(raw, rawLength, rest, current);
953
+ if (!found) return undefined;
954
+ if (!found.rest) {
955
+ this.lastMode = found.mode;
956
+ return found.id;
957
+ }
958
+ current = found.id;
959
+ rest = found.rest;
956
960
  }
957
961
  }
958
962
 
959
- private async treeEntry(tree: ObjectId, path: string): Promise<ObjectId | undefined> {
960
- if (path === "") return tree;
963
+ /**
964
+ * {@link treeEntry} over a store's decoded entries: components matched exactly, an empty
965
+ * one (`/a`, `d//b`) names nothing, a trailing `/` only follows a directory.
966
+ */
967
+ private async treeEntryDecoded(tree: ObjectId, path: string): Promise<ObjectId | undefined> {
968
+ const trees = this.sources.trees;
961
969
  let current = tree;
962
970
  let rest = path;
963
971
  for (;;) {
964
972
  const slash = rest.indexOf("/");
965
973
  const name = slash < 0 ? rest : rest.slice(0, slash);
966
974
  if (name === "") return undefined;
967
- const entry = await this.findTreeEntry(current, name);
975
+ const at = current;
976
+ const entry = await safe(() => trees.getEntry(at, name));
968
977
  if (!entry) return undefined;
969
978
  if (slash < 0) {
970
979
  this.lastMode = entry.mode;
@@ -23,7 +23,6 @@ import {
23
23
  createReplacedCommits,
24
24
  createReplacedTags,
25
25
  createReplacedTrees,
26
- decodeTreeBytes,
27
26
  type GraftFileBase,
28
27
  graftFileBaseDir,
29
28
  graftFileReader,
@@ -79,6 +78,7 @@ import { loadLegacyRemote } from "./commands/legacy-remotes.js";
79
78
  import { type Mailmap, readRepositoryMailmap } from "./commands/mailmap.js";
80
79
  import type { MergeBaseGraph } from "./commands/merge-bases.js";
81
80
  import type { NotesContext } from "./commands/notes-support.js";
81
+ import { walkTreeDesc } from "./commands/plumbing-shared.js";
82
82
  import { postIndexChangeHookOf } from "./commands/post-index-change.js";
83
83
  import { createPromisorFetcher, promisorOf } from "./commands/promisor-remote.js";
84
84
  import { reflogLine } from "./commands/reflog-messages.js";
@@ -1721,38 +1721,35 @@ export abstract class GitCommand<T> {
1721
1721
  }
1722
1722
 
1723
1723
  /**
1724
- * A tree's entries for a listing (`ls-tree`, `cat-file -p`), as git's readers list them: a
1725
- * tree holding a name fsck refuses (`..`, `a/b`), which the store will not decode, is read
1726
- * from its stored bytes without the name check. Undefined when the tree cannot be read.
1724
+ * A tree's entries for a listing (`ls-tree`, `cat-file -p`, `ls-files --with-tree`), as
1725
+ * git's readers walk them (tree-walk.c's `tree_desc`, {@link walkTreeDesc}): from the stored
1726
+ * bytes, names not checked (a tree holding `..` lists), each entry yielded once the next one
1727
+ * decoded, a corrupt entry git's death ({@link CorruptTreeError}) when the walk reaches it.
1728
+ * Undefined when the tree cannot be read (missing, or not a tree).
1727
1729
  */
1728
- protected async listedTreeEntries(id: ObjectId): Promise<readonly TreeEntry[] | undefined> {
1730
+ protected async listedTreeEntries(id: ObjectId): Promise<Iterable<TreeEntry> | undefined> {
1729
1731
  const compat = this.compatObjects;
1730
1732
  if (compat && id.length !== this.objectFormat.hexLength) {
1731
1733
  // a tree named by its compatibility id (GET_OID_HASH_ANY): read converted, its entries
1732
1734
  // the compatibility format's ids, as git's parse_tree of such an id lists them
1733
1735
  const tree = await compat.readAsCompat(id).catch(() => undefined);
1734
1736
  if (tree?.type !== "tree") return undefined;
1735
- return decodeTreeBytes(tree.content, {
1736
- canonicalModes: true,
1737
- idLength: compat.compat.rawLength,
1738
- checkNames: false,
1739
- });
1737
+ return walkTreeDesc(tree.content, compat.compat.rawLength, id);
1740
1738
  }
1739
+ const trees = this.trees;
1740
+ if (trees.raw) {
1741
+ const raw = await trees.raw(id).catch(() => undefined);
1742
+ return raw ? walkTreeDesc(raw, this.objectFormat.rawLength, id) : undefined;
1743
+ }
1744
+ // a store without stored bytes: its decoded entries
1741
1745
  try {
1742
- const loaded = await this.trees.load(id);
1746
+ const loaded = await trees.load(id);
1743
1747
  if (!loaded) return undefined;
1744
1748
  const entries: TreeEntry[] = [];
1745
1749
  for await (const e of loaded) entries.push(e);
1746
1750
  return entries;
1747
- } catch (e) {
1748
- if ((e as Error)?.name !== "InvalidTreeEntryNameError") return undefined;
1749
- const raw = await this.trees.raw?.(id).catch(() => undefined);
1750
- if (!raw) return undefined;
1751
- return decodeTreeBytes(raw, {
1752
- canonicalModes: true,
1753
- idLength: this.objectFormat.rawLength,
1754
- checkNames: false,
1755
- });
1751
+ } catch {
1752
+ return undefined;
1756
1753
  }
1757
1754
  }
1758
1755
 
@@ -735,15 +735,23 @@ export class RemoteConfigStore {
735
735
  /**
736
736
  * Every variable whose canonical key starts with `prefix` (lower case), in the
737
737
  * configuration's order with its text (undefined for a variable without `=`), as git's
738
- * config callbacks see them; undefined when the config cannot list its variables.
738
+ * config callbacks see them, and where each was read (file and line; none for the command
739
+ * line); undefined when the config cannot list its variables.
739
740
  */
740
- entriesWithPrefix(prefix: string): { key: string; value: string | undefined }[] | undefined {
741
+ entriesWithPrefix(
742
+ prefix: string,
743
+ ): { key: string; value: string | undefined; file?: string; line?: number }[] | undefined {
741
744
  if (!this.config.listWithOrigin) return undefined;
742
745
  const lower = prefix.toLowerCase();
743
746
  return this.config
744
747
  .listWithOrigin()
745
748
  .filter((e) => e.key.startsWith(lower))
746
- .map((e) => ({ key: e.key, value: e.text }));
749
+ .map((e) => ({
750
+ key: e.key,
751
+ value: e.text,
752
+ ...(e.file !== undefined ? { file: e.file } : {}),
753
+ ...(e.line !== undefined ? { line: e.line } : {}),
754
+ }));
747
755
  }
748
756
 
749
757
  /**
@@ -251,7 +251,10 @@ export abstract class TransportCommand<T> extends GitCommand<T> {
251
251
  RemoteConfigStore.from(this._workingCopy),
252
252
  url,
253
253
  hostEnvironmentOf(this._workingCopy),
254
- { compatibility: this.hooks.compatibility },
254
+ {
255
+ compatibility: this.hooks.compatibility,
256
+ ...(this.warningCallback ? { onWarning: this.warningCallback } : {}),
257
+ },
255
258
  );
256
259
  return this.warningCallback ? { ...settings, onWarning: this.warningCallback } : settings;
257
260
  }