@statewalker/vcs-commands 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. package/dist/commands/add-command.d.ts.map +1 -1
  2. package/dist/commands/add-patch/patch-backend.d.ts +1 -1
  3. package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
  4. package/dist/commands/archive/archive-command.d.ts +6 -2
  5. package/dist/commands/archive/archive-command.d.ts.map +1 -1
  6. package/dist/commands/archive/remote-archive-command.d.ts +27 -2
  7. package/dist/commands/archive/remote-archive-command.d.ts.map +1 -1
  8. package/dist/commands/archive/upload-archive-writer.d.ts +11 -5
  9. package/dist/commands/archive/upload-archive-writer.d.ts.map +1 -1
  10. package/dist/commands/branch-command.d.ts +14 -2
  11. package/dist/commands/branch-command.d.ts.map +1 -1
  12. package/dist/commands/bundle/bundle-format.d.ts +6 -1
  13. package/dist/commands/bundle/bundle-format.d.ts.map +1 -1
  14. package/dist/commands/bundle/bundle-uri-host.d.ts +12 -1
  15. package/dist/commands/bundle/bundle-uri-host.d.ts.map +1 -1
  16. package/dist/commands/bundle/bundle-uri.d.ts +7 -1
  17. package/dist/commands/bundle/bundle-uri.d.ts.map +1 -1
  18. package/dist/commands/bundle/bundle-verify.d.ts +4 -1
  19. package/dist/commands/bundle/bundle-verify.d.ts.map +1 -1
  20. package/dist/commands/cat-file/batch-format.d.ts +8 -12
  21. package/dist/commands/cat-file/batch-format.d.ts.map +1 -1
  22. package/dist/commands/cat-file/cat-file-command.d.ts +39 -5
  23. package/dist/commands/cat-file/cat-file-command.d.ts.map +1 -1
  24. package/dist/commands/check-ignore-command.d.ts.map +1 -1
  25. package/dist/commands/checkout-command.d.ts +4 -0
  26. package/dist/commands/checkout-command.d.ts.map +1 -1
  27. package/dist/commands/checkout-paths.d.ts +9 -0
  28. package/dist/commands/checkout-paths.d.ts.map +1 -1
  29. package/dist/commands/cherry-pick-command.d.ts +3 -0
  30. package/dist/commands/cherry-pick-command.d.ts.map +1 -1
  31. package/dist/commands/clean-interactive.d.ts +0 -9
  32. package/dist/commands/clean-interactive.d.ts.map +1 -1
  33. package/dist/commands/clone-command.d.ts +17 -0
  34. package/dist/commands/clone-command.d.ts.map +1 -1
  35. package/dist/commands/column/column-config.d.ts +23 -0
  36. package/dist/commands/column/column-config.d.ts.map +1 -0
  37. package/dist/commands/column/column-layout.d.ts +129 -0
  38. package/dist/commands/column/column-layout.d.ts.map +1 -0
  39. package/dist/commands/column/index.d.ts +3 -0
  40. package/dist/commands/column/index.d.ts.map +1 -0
  41. package/dist/commands/column-command.d.ts +59 -0
  42. package/dist/commands/column-command.d.ts.map +1 -0
  43. package/dist/commands/comment-char-config.d.ts +15 -0
  44. package/dist/commands/comment-char-config.d.ts.map +1 -1
  45. package/dist/commands/commit-command.d.ts +30 -2
  46. package/dist/commands/commit-command.d.ts.map +1 -1
  47. package/dist/commands/config-command.d.ts +12 -0
  48. package/dist/commands/config-command.d.ts.map +1 -1
  49. package/dist/commands/credential-helper.d.ts +214 -0
  50. package/dist/commands/credential-helper.d.ts.map +1 -0
  51. package/dist/commands/default-branch.d.ts +33 -3
  52. package/dist/commands/default-branch.d.ts.map +1 -1
  53. package/dist/commands/diff-color-config.d.ts +4 -0
  54. package/dist/commands/diff-color-config.d.ts.map +1 -1
  55. package/dist/commands/diff-command.d.ts +12 -0
  56. package/dist/commands/diff-command.d.ts.map +1 -1
  57. package/dist/commands/fast-export/fast-export-command.d.ts +89 -2
  58. package/dist/commands/fast-export/fast-export-command.d.ts.map +1 -1
  59. package/dist/commands/fast-export/fast-import-command.d.ts +113 -8
  60. package/dist/commands/fast-export/fast-import-command.d.ts.map +1 -1
  61. package/dist/commands/fast-export/fast-stream-support.d.ts +0 -9
  62. package/dist/commands/fast-export/fast-stream-support.d.ts.map +1 -1
  63. package/dist/commands/fetch-command.d.ts +23 -1
  64. package/dist/commands/fetch-command.d.ts.map +1 -1
  65. package/dist/commands/fsck/fsck-object-checks.d.ts.map +1 -1
  66. package/dist/commands/git-hooks.d.ts +31 -3
  67. package/dist/commands/git-hooks.d.ts.map +1 -1
  68. package/dist/commands/history-command.d.ts +173 -7
  69. package/dist/commands/history-command.d.ts.map +1 -1
  70. package/dist/commands/index-host.d.ts +19 -0
  71. package/dist/commands/index-host.d.ts.map +1 -1
  72. package/dist/commands/index-refresh.d.ts +36 -0
  73. package/dist/commands/index-refresh.d.ts.map +1 -0
  74. package/dist/commands/index.d.ts +9 -0
  75. package/dist/commands/index.d.ts.map +1 -1
  76. package/dist/commands/index.js +7 -6
  77. package/dist/commands/init-command.d.ts +20 -0
  78. package/dist/commands/init-command.d.ts.map +1 -1
  79. package/dist/commands/local-transport.d.ts +40 -2
  80. package/dist/commands/local-transport.d.ts.map +1 -1
  81. package/dist/commands/log-command.d.ts +7 -0
  82. package/dist/commands/log-command.d.ts.map +1 -1
  83. package/dist/commands/log-output.d.ts +11 -0
  84. package/dist/commands/log-output.d.ts.map +1 -1
  85. package/dist/commands/ls-tree-command.d.ts +10 -0
  86. package/dist/commands/ls-tree-command.d.ts.map +1 -1
  87. package/dist/commands/maintenance-schedule-command.d.ts +122 -0
  88. package/dist/commands/maintenance-schedule-command.d.ts.map +1 -0
  89. package/dist/commands/merge-command.d.ts +13 -1
  90. package/dist/commands/merge-command.d.ts.map +1 -1
  91. package/dist/commands/merge-index-command.d.ts +42 -0
  92. package/dist/commands/merge-index-command.d.ts.map +1 -0
  93. package/dist/commands/merge-one-file.d.ts +129 -0
  94. package/dist/commands/merge-one-file.d.ts.map +1 -0
  95. package/dist/commands/merge-support.d.ts +40 -4
  96. package/dist/commands/merge-support.d.ts.map +1 -1
  97. package/dist/commands/object-disk-info.d.ts +35 -0
  98. package/dist/commands/object-disk-info.d.ts.map +1 -0
  99. package/dist/commands/octopus-merge.d.ts +3 -3
  100. package/dist/commands/octopus-merge.d.ts.map +1 -1
  101. package/dist/commands/plumbing-input.d.ts.map +1 -1
  102. package/dist/commands/promisor-remote-reply.d.ts +31 -4
  103. package/dist/commands/promisor-remote-reply.d.ts.map +1 -1
  104. package/dist/commands/promisor-remote.d.ts +8 -1
  105. package/dist/commands/promisor-remote.d.ts.map +1 -1
  106. package/dist/commands/pull-command.d.ts +55 -7
  107. package/dist/commands/pull-command.d.ts.map +1 -1
  108. package/dist/commands/push-command.d.ts +18 -1
  109. package/dist/commands/push-command.d.ts.map +1 -1
  110. package/dist/commands/range-diff/range-diff-command.d.ts +37 -1
  111. package/dist/commands/range-diff/range-diff-command.d.ts.map +1 -1
  112. package/dist/commands/rebase-command.d.ts +13 -1
  113. package/dist/commands/rebase-command.d.ts.map +1 -1
  114. package/dist/commands/ref-filter/for-each-ref-command.d.ts +3 -2
  115. package/dist/commands/ref-filter/for-each-ref-command.d.ts.map +1 -1
  116. package/dist/commands/ref-filter/index.d.ts +1 -0
  117. package/dist/commands/ref-filter/index.d.ts.map +1 -1
  118. package/dist/commands/ref-filter/peel-limit.d.ts +8 -0
  119. package/dist/commands/ref-filter/peel-limit.d.ts.map +1 -0
  120. package/dist/commands/ref-filter/ref-filter.d.ts.map +1 -1
  121. package/dist/commands/ref-filter/ref-format.d.ts +26 -1
  122. package/dist/commands/ref-filter/ref-format.d.ts.map +1 -1
  123. package/dist/commands/ref-filter/ref-listing-command.d.ts +9 -0
  124. package/dist/commands/ref-filter/ref-listing-command.d.ts.map +1 -1
  125. package/dist/commands/remote-transport.d.ts +27 -0
  126. package/dist/commands/remote-transport.d.ts.map +1 -1
  127. package/dist/commands/repack-command.d.ts +18 -2
  128. package/dist/commands/repack-command.d.ts.map +1 -1
  129. package/dist/commands/repo-command.d.ts +2 -7
  130. package/dist/commands/repo-command.d.ts.map +1 -1
  131. package/dist/commands/reset-command.d.ts +4 -1
  132. package/dist/commands/reset-command.d.ts.map +1 -1
  133. package/dist/commands/restore-command.d.ts.map +1 -1
  134. package/dist/commands/rev-list-command.d.ts +65 -0
  135. package/dist/commands/rev-list-command.d.ts.map +1 -1
  136. package/dist/commands/revert-command.d.ts +3 -0
  137. package/dist/commands/revert-command.d.ts.map +1 -1
  138. package/dist/commands/revision-filenames.d.ts.map +1 -1
  139. package/dist/commands/revision-range.d.ts +17 -0
  140. package/dist/commands/revision-range.d.ts.map +1 -1
  141. package/dist/commands/revision-resolver.d.ts +12 -0
  142. package/dist/commands/revision-resolver.d.ts.map +1 -1
  143. package/dist/commands/serve-repository.d.ts +21 -4
  144. package/dist/commands/serve-repository.d.ts.map +1 -1
  145. package/dist/commands/served-lazy-fetch.d.ts +61 -0
  146. package/dist/commands/served-lazy-fetch.d.ts.map +1 -0
  147. package/dist/commands/signing.d.ts +37 -4
  148. package/dist/commands/signing.d.ts.map +1 -1
  149. package/dist/commands/split-cmdline.d.ts +6 -0
  150. package/dist/commands/split-cmdline.d.ts.map +1 -0
  151. package/dist/commands/status-color-config.d.ts +33 -0
  152. package/dist/commands/status-color-config.d.ts.map +1 -0
  153. package/dist/commands/status-command.d.ts +15 -0
  154. package/dist/commands/status-command.d.ts.map +1 -1
  155. package/dist/commands/status-format.d.ts +46 -4
  156. package/dist/commands/status-format.d.ts.map +1 -1
  157. package/dist/commands/tag-command.d.ts +15 -1
  158. package/dist/commands/tag-command.d.ts.map +1 -1
  159. package/dist/commands/tree-restore.d.ts +14 -0
  160. package/dist/commands/tree-restore.d.ts.map +1 -1
  161. package/dist/commands/verify-command.d.ts +22 -2
  162. package/dist/commands/verify-command.d.ts.map +1 -1
  163. package/dist/commands/worktree-add-command.d.ts.map +1 -1
  164. package/dist/commands/worktree-overwrite-checks.d.ts +31 -6
  165. package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
  166. package/dist/{commands-CPceUCP2.js → commands-DT3VEv50.js} +15168 -16842
  167. package/dist/errors/commit-errors.d.ts +37 -1
  168. package/dist/errors/commit-errors.d.ts.map +1 -1
  169. package/dist/errors/git-api-error.d.ts +6 -0
  170. package/dist/errors/git-api-error.d.ts.map +1 -1
  171. package/dist/errors/index.js +44 -3
  172. package/dist/{fsck-tbrPZX2q.js → fsck-BZ508Elg.js} +2 -2
  173. package/dist/git-command.d.ts +33 -1
  174. package/dist/git-command.d.ts.map +1 -1
  175. package/dist/git.d.ts +104 -1
  176. package/dist/git.d.ts.map +1 -1
  177. package/dist/index.js +8 -7
  178. package/dist/{remote-transport-C0OSJtor.js → local-transport-D98U6p4d.js} +228 -692
  179. package/dist/{maintenance-run-command-UiSIaeP8.js → maintenance-run-command-DZFnbnbo.js} +2366 -108
  180. package/dist/remote-config/remote-config-store.d.ts +6 -0
  181. package/dist/remote-config/remote-config-store.d.ts.map +1 -1
  182. package/dist/remote-transport-zvSqwpOB.js +4865 -0
  183. package/dist/results/cherry-pick-result.d.ts +4 -3
  184. package/dist/results/cherry-pick-result.d.ts.map +1 -1
  185. package/dist/results/diff-output.d.ts +7 -0
  186. package/dist/results/diff-output.d.ts.map +1 -1
  187. package/dist/results/diff-words.d.ts +14 -3
  188. package/dist/results/diff-words.d.ts.map +1 -1
  189. package/dist/results/index.js +1 -1
  190. package/dist/results/line-prefix-sink.d.ts +50 -0
  191. package/dist/results/line-prefix-sink.d.ts.map +1 -0
  192. package/dist/results/merge-result.d.ts +4 -3
  193. package/dist/results/merge-result.d.ts.map +1 -1
  194. package/dist/results/rebase-result.d.ts +5 -0
  195. package/dist/results/rebase-result.d.ts.map +1 -1
  196. package/dist/results/revert-result.d.ts +4 -3
  197. package/dist/results/revert-result.d.ts.map +1 -1
  198. package/dist/{results-CkS1p1CH.js → results-rF81cQse.js} +1788 -247
  199. package/dist/transport-command.d.ts +13 -0
  200. package/dist/transport-command.d.ts.map +1 -1
  201. package/package.json +21 -13
  202. package/src/commands/add-command.ts +15 -2
  203. package/src/commands/add-patch/patch-backend.ts +6 -44
  204. package/src/commands/archive/archive-command.ts +7 -3
  205. package/src/commands/archive/remote-archive-command.ts +45 -4
  206. package/src/commands/archive/upload-archive-writer.ts +34 -22
  207. package/src/commands/branch-command.ts +57 -4
  208. package/src/commands/bundle/bundle-format.ts +10 -2
  209. package/src/commands/bundle/bundle-uri-host.ts +71 -11
  210. package/src/commands/bundle/bundle-uri.ts +11 -4
  211. package/src/commands/bundle/bundle-verify.ts +4 -1
  212. package/src/commands/cat-file/batch-format.ts +17 -18
  213. package/src/commands/cat-file/cat-file-command.ts +182 -48
  214. package/src/commands/check-ignore-command.ts +110 -21
  215. package/src/commands/checkout-command.ts +149 -21
  216. package/src/commands/checkout-index-command.ts +2 -1
  217. package/src/commands/checkout-paths.ts +13 -0
  218. package/src/commands/cherry-pick-command.ts +9 -0
  219. package/src/commands/clean-interactive.ts +20 -74
  220. package/src/commands/clone-command.ts +102 -11
  221. package/src/commands/column/column-config.ts +63 -0
  222. package/src/commands/column/column-layout.ts +396 -0
  223. package/src/commands/column/index.ts +2 -0
  224. package/src/commands/column-command.ts +171 -0
  225. package/src/commands/comment-char-config.ts +42 -0
  226. package/src/commands/commit-command.ts +93 -18
  227. package/src/commands/config-command.ts +28 -0
  228. package/src/commands/credential-helper.ts +807 -0
  229. package/src/commands/default-branch.ts +57 -5
  230. package/src/commands/diff-color-config.ts +23 -10
  231. package/src/commands/diff-command.ts +25 -2
  232. package/src/commands/fast-export/fast-export-command.ts +661 -35
  233. package/src/commands/fast-export/fast-import-command.ts +694 -94
  234. package/src/commands/fast-export/fast-stream-support.ts +18 -1
  235. package/src/commands/fetch-command.ts +116 -16
  236. package/src/commands/fsck/fsck-object-checks.ts +3 -1
  237. package/src/commands/git-hooks.ts +96 -5
  238. package/src/commands/history-command.ts +952 -20
  239. package/src/commands/index-host.ts +51 -0
  240. package/src/commands/index-refresh.ts +121 -0
  241. package/src/commands/index.ts +9 -0
  242. package/src/commands/init-command.ts +57 -4
  243. package/src/commands/legacy-remotes.ts +4 -20
  244. package/src/commands/local-transport.ts +183 -18
  245. package/src/commands/log-command.ts +39 -1
  246. package/src/commands/log-output.ts +31 -4
  247. package/src/commands/ls-tree-command.ts +20 -12
  248. package/src/commands/maintenance-schedule-command.ts +418 -0
  249. package/src/commands/merge-command.ts +42 -8
  250. package/src/commands/merge-index-command.ts +202 -0
  251. package/src/commands/merge-one-file.ts +451 -0
  252. package/src/commands/merge-support.ts +169 -15
  253. package/src/commands/object-disk-info.ts +169 -0
  254. package/src/commands/octopus-merge.ts +37 -128
  255. package/src/commands/plumbing-input.ts +3 -1
  256. package/src/commands/promisor-remote-reply.ts +338 -56
  257. package/src/commands/promisor-remote.ts +39 -6
  258. package/src/commands/pull-command.ts +173 -27
  259. package/src/commands/push-command.ts +55 -6
  260. package/src/commands/range-diff/range-diff-command.ts +86 -3
  261. package/src/commands/read-tree-command.ts +2 -2
  262. package/src/commands/rebase-command.ts +46 -1
  263. package/src/commands/ref-filter/for-each-ref-command.ts +4 -3
  264. package/src/commands/ref-filter/index.ts +1 -0
  265. package/src/commands/ref-filter/peel-limit.ts +7 -0
  266. package/src/commands/ref-filter/ref-filter.ts +68 -7
  267. package/src/commands/ref-filter/ref-format.ts +85 -11
  268. package/src/commands/ref-filter/ref-listing-command.ts +30 -0
  269. package/src/commands/remote-command.ts +2 -2
  270. package/src/commands/remote-transport.ts +66 -3
  271. package/src/commands/repack-command.ts +75 -9
  272. package/src/commands/repo-command.ts +6 -70
  273. package/src/commands/reset-command.ts +11 -1
  274. package/src/commands/restore-command.ts +1 -0
  275. package/src/commands/rev-list-command.ts +205 -3
  276. package/src/commands/revert-command.ts +9 -0
  277. package/src/commands/revision-filenames.ts +32 -4
  278. package/src/commands/revision-range.ts +2 -2
  279. package/src/commands/revision-resolver.ts +21 -1
  280. package/src/commands/serve-repository.ts +42 -11
  281. package/src/commands/served-lazy-fetch.ts +164 -0
  282. package/src/commands/signing.ts +103 -12
  283. package/src/commands/split-cmdline.ts +32 -0
  284. package/src/commands/status-color-config.ts +92 -0
  285. package/src/commands/status-command.ts +50 -2
  286. package/src/commands/status-format.ts +198 -50
  287. package/src/commands/tag-command.ts +57 -2
  288. package/src/commands/tree-restore.ts +17 -0
  289. package/src/commands/verify-command.ts +84 -12
  290. package/src/commands/worktree-add-command.ts +2 -0
  291. package/src/commands/worktree-overwrite-checks.ts +75 -14
  292. package/src/errors/commit-errors.ts +52 -2
  293. package/src/errors/git-api-error.ts +7 -0
  294. package/src/git-command.ts +105 -4
  295. package/src/git.ts +153 -0
  296. package/src/remote-config/remote-config-store.ts +16 -0
  297. package/src/results/cherry-pick-result.ts +4 -3
  298. package/src/results/diff-output.ts +8 -0
  299. package/src/results/diff-words.ts +160 -32
  300. package/src/results/line-prefix-sink.ts +102 -0
  301. package/src/results/merge-result.ts +4 -3
  302. package/src/results/rebase-result.ts +5 -0
  303. package/src/results/revert-result.ts +4 -3
  304. package/src/transport-command.ts +79 -3
@@ -1,366 +1,13 @@
1
- import { I as __exportAll, m as receiveFsckOf } from "./fsck-tbrPZX2q.js";
2
- import { GitApiError, InvalidConfigError, InvalidPathError, ReadTreeFailedError, TransportError as TransportError$1 } from "./errors/index.js";
3
- import { $t as SubmoduleUnpack, Bc as SparseUnpack, Du as RemoteConfigStore, Fl as refTransactionHookOf, In as checkSignatureWith, Kl as worktreeModeTrust, Lt as resetMerge, Ml as hookSettingsFromEntries, Os as quoteCStyleBody, Qc as entryNotUptodate, R as StatusCommand, Ra as GitCommand, Uc as pushSparseWarnings, Wl as coreBool, Ya as signingConfigFromEntries, Zc as IndexCaseFolding, _l as withTreePathRefusal, bl as HookSession, bn as worktreeAdminWorkingCopy, ca as planPathsRestore, da as rewriteIndex, en as recursesIntoSubmodules, gn as requireWorktrees, ha as switchTrees, hl as firstInvalidPath, hn as repositoryPlaceOf, hu as hostEnvironmentOf, ia as flatTree, kl as hookHostOf, ml as writeTreeRestorePlan, nl as pruneEmptyParents, pl as restoreCaseOptions, pn as parseExpiry, ra as firstPlainError, rl as removeCaseVariants, sa as plainUnpackError, sl as untrackedUnder, vl as worktreePathRules, xl as LOCAL_REPO_ENV, xn as worktreeUsingBranch, yn as usesBranch } from "./results-CkS1p1CH.js";
4
- import { FileMode, historyWithoutLazyFetch } from "@statewalker/vcs-core";
5
- import { compareGitPaths, decodeGitPath, encodeGitPath, parseGitBool, parseGitInt } from "@statewalker/vcs-utils/encoding";
1
+ import { I as __exportAll, m as receiveFsckOf } from "./fsck-BZ508Elg.js";
2
+ import { GitApiError, InvalidPathError, ReadTreeFailedError, TransportError as TransportError$1 } from "./errors/index.js";
3
+ import { $l as firstInvalidPath, Au as worktreeModeTrust, B as StatusCommand, Bl as removeCaseVariants, Fc as LAZY_FETCH_DISABLED_WARNING, Ga as switchTrees, Gl as untrackedUnder, Gn as requireWorktrees, Hn as parseExpiry, Ic as createPromisorFetcher, Jn as usesBranch, La as plainUnpackError, Lc as hasPromisorRemote, Ma as firstPlainError, Ml as IndexCaseFolding, Na as flatTree, On as SubmoduleUnpack, Ou as coreBool, Pl as entryNotUptodate, Ql as writeTreeRestorePlan, Ra as planPathsRestore, To as signingConfigFromEntries, Va as rewriteIndex, Wn as repositoryPlaceOf, Xn as worktreeUsingBranch, Yn as worktreeAdminWorkingCopy, Zl as restoreCaseOptions, au as LOCAL_REPO_ENV, dr as checkSignatureWith, ed as hostEnvironmentOf, fd as RemoteConfigStore, fn as resetMerge, gu as hookSettingsFromEntries, iu as HookSession, kn as recursesIntoSubmodules, mo as GitCommand, nu as worktreePathRules, oc as quoteCStyleBody, pu as hookHostOf, tu as withTreePathRefusal, wl as pushSparseWarnings, xl as SparseUnpack, yu as refTransactionHookOf, zl as pruneEmptyParents } from "./results-rF81cQse.js";
4
+ import { FileMode, historyWithPromisorFetcher, historyWithoutLazyFetch } from "@statewalker/vcs-core";
5
+ import { compareGitPaths, parseGitBool, parseGitInt } from "@statewalker/vcs-utils/encoding";
6
6
  import { attributesIndexOf, cacheTreeOfTree, entryStatOf, isIndexUnborn, repairCacheTree, sparseFilterMatcher } from "@statewalker/vcs-working-tree";
7
7
  import { parseGitInt as parseGitInt$1 } from "@statewalker/vcs-utils";
8
8
  import { readFile as readFile$1 } from "@statewalker/vcs-utils/files";
9
- import { SHA1_OBJECT_FORMAT as SHA1_OBJECT_FORMAT$1, objectFormatByName as objectFormatByName$1 } from "@statewalker/vcs-utils/hash";
10
9
  import { configFilesApiOf, gc, parseExpiryDate, readConfinedFile, updateServerInfo } from "@statewalker/vcs-store-files";
11
- import { ReceivePackDiedError, connectivityErrors, createRepositoryFacade, createTransportRefStore, isGitUrl, openDuplexConnection, openDuplexReceivePackConnection, openReceivePack, openUploadPack, parseGitUrl, protocolVersionFor, pushCertificateEnv, serveOverDuplex, serverSettingsFromConfig } from "@statewalker/vcs-transport";
12
- //#region src/commands/bundle/bundle-format.ts
13
- /**
14
- * git's bundle files (bundle.c, `Documentation/gitformat-bundle.adoc`): a header naming the
15
- * refs the bundle carries and the commits it needs, then a pack.
16
- *
17
- * @example
18
- * ```typescript
19
- * // # v3 git bundle
20
- * // @object-format=sha256
21
- * // -<id> <subject> (a prerequisite)
22
- * // <id> refs/heads/main (a ref)
23
- * // (an empty line, then the pack)
24
- * const header = parseBundleHeader(bytes);
25
- * if (header.ok) for (const ref of header.header.references) console.log(ref.id, ref.name);
26
- * ```
27
- */
28
- /** The first line of a v2 bundle. */
29
- const V2_BUNDLE_SIGNATURE = "# v2 git bundle\n";
30
- /** The first line of a v3 bundle (capabilities may follow). */
31
- const V3_BUNDLE_SIGNATURE = "# v3 git bundle\n";
32
- /** git's sane_ctype isspace: SP, HT, LF, CR */
33
- const SPACE = (c) => c === 32 || c === 9 || c === 10 || c === 13;
34
- const HEX = /^[0-9a-fA-F]$/;
35
- /**
36
- * bundle.c's `read_bundle_header_fd`: the signature, then lines up to an empty one (or the
37
- * end): v3 capabilities (`@object-format=`, `@filter=`), prerequisites (`-<id>` optionally
38
- * followed by a space and a comment) and refs (`<id> <name>`), each line right-trimmed.
39
- * `name` is how a bad signature is reported (git's `report_path`).
40
- *
41
- * @example
42
- * ```typescript
43
- * const parsed = parseBundleHeader(bytes, "repo.bundle");
44
- * if (!parsed.ok) console.error(`error: ${parsed.error}`);
45
- * ```
46
- */
47
- function parseBundleHeader(bytes, name = "<bundle>") {
48
- let at = 0;
49
- /** strbuf_getwholeline_fd: the next line with its LF; undefined at the end */
50
- const nextLine = () => {
51
- if (at >= bytes.length) return void 0;
52
- const lf = bytes.indexOf(10, at);
53
- const end = lf < 0 ? bytes.length : lf + 1;
54
- const line = bytes.subarray(at, end);
55
- at = end;
56
- return line;
57
- };
58
- const first = nextLine();
59
- const signature = first ? latin1(first) : "";
60
- const version = signature === "# v2 git bundle\n" ? 2 : signature === "# v3 git bundle\n" ? 3 : 0;
61
- if (version === 0) return {
62
- ok: false,
63
- error: `'${name}' does not look like a v2 or v3 bundle file`,
64
- notABundle: true
65
- };
66
- let objectFormat = SHA1_OBJECT_FORMAT$1;
67
- let filter;
68
- const prerequisites = [];
69
- const references = [];
70
- const fail = (error) => ({
71
- ok: false,
72
- error,
73
- notABundle: false
74
- });
75
- for (let line = nextLine(); line !== void 0; line = nextLine()) {
76
- if (line.length === 0 || line[0] === 10) break;
77
- let end = line.length;
78
- while (end > 0 && SPACE(line[end - 1])) end--;
79
- let text = line.subarray(0, end);
80
- if (version === 3 && text[0] === 64) {
81
- const capability = decodeGitPath(text.subarray(1));
82
- if (capability.startsWith("object-format=")) {
83
- const format = objectFormatByName$1(capability.slice(14));
84
- if (!format) return fail(`unrecognized bundle hash algorithm: ${capability.slice(14)}`);
85
- objectFormat = format;
86
- continue;
87
- }
88
- if (capability.startsWith("filter=")) {
89
- filter = capability.slice(7);
90
- continue;
91
- }
92
- return fail(`unknown capability '${capability}'`);
93
- }
94
- const prereq = text[0] === 45;
95
- if (prereq) text = text.subarray(1);
96
- const hex = objectFormat.hexLength;
97
- let valid = text.length >= hex;
98
- for (let i = 0; valid && i < hex; i++) valid = HEX.test(String.fromCharCode(text[i]));
99
- const rest = text.subarray(hex);
100
- if (valid && rest.length > 0 && !SPACE(rest[0])) valid = false;
101
- if (valid && !prereq && rest.length === 0) valid = false;
102
- if (!valid) return fail(`unrecognized header: ${prereq ? "-" : ""}${decodeGitPath(text)} (${text.length})`);
103
- const id = latin1(text.subarray(0, hex)).toLowerCase();
104
- if (prereq) prerequisites.push({
105
- id,
106
- comment: decodeGitPath(rest.subarray(1)).trim()
107
- });
108
- else references.push({
109
- id,
110
- name: decodeGitPath(rest.subarray(1))
111
- });
112
- }
113
- return {
114
- ok: true,
115
- header: {
116
- version,
117
- objectFormat,
118
- ...filter !== void 0 ? { filter } : {},
119
- prerequisites,
120
- references
121
- },
122
- packOffset: at
123
- };
124
- }
125
- /**
126
- * The header `create_bundle` writes: the signature (v3 with `@object-format=` and, for a
127
- * filtered bundle, `@filter=`), `-<id> <comment>` per prerequisite, `<id> <name>` per ref,
128
- * then the empty line the pack follows.
129
- *
130
- * @example
131
- * ```typescript
132
- * const bytes = encodeBundleHeader({ version: 2, objectFormat: SHA1_OBJECT_FORMAT,
133
- * prerequisites: [], references: [{ id, name: "refs/heads/main" }] });
134
- * ```
135
- */
136
- function encodeBundleHeader(header) {
137
- const parts = [];
138
- const text = (s) => parts.push(encodeGitPath(s));
139
- if (header.version === 2) text(V2_BUNDLE_SIGNATURE);
140
- else {
141
- text(V3_BUNDLE_SIGNATURE);
142
- text(`@object-format=${header.objectFormat.name}\n`);
143
- if (header.filter !== void 0) text(`@filter=${header.filter}\n`);
144
- }
145
- for (const p of header.prerequisites) text(`-${p.id} ${p.comment}\n`);
146
- for (const r of header.references) text(`${r.id} ${r.name}\n`);
147
- text("\n");
148
- let length = 0;
149
- for (const p of parts) length += p.length;
150
- const out = new Uint8Array(length);
151
- let at = 0;
152
- for (const p of parts) {
153
- out.set(p, at);
154
- at += p.length;
155
- }
156
- return out;
157
- }
158
- /**
159
- * bundle.c's `list_refs`: `<id> <name>` per ref, only those named in `names` when any are
160
- * (exact names, as `git bundle list-heads <file> <refname>...` and `unbundle` take them).
161
- * A prerequisite is listed with an empty name (`<id> `), as `git bundle verify` prints it.
162
- */
163
- function listBundleRefs(refs, names = []) {
164
- let out = "";
165
- for (const ref of refs) {
166
- const name = "name" in ref ? ref.name : "";
167
- if (names.length > 0 && !names.includes(name)) continue;
168
- out += `${ref.id} ${name}\n`;
169
- }
170
- return out;
171
- }
172
- function latin1(bytes) {
173
- let s = "";
174
- for (let i = 0; i < bytes.length; i++) s += String.fromCharCode(bytes[i]);
175
- return s;
176
- }
177
- //#endregion
178
- //#region src/commands/bundle/bundle-verify.ts
179
- /**
180
- * bundle.c's reading side without a command: a bundle's bytes read (`read_bundle_header`)
181
- * and checked against a repository (`verify_bundle`), as the bundle commands and the bundle
182
- * transport do.
183
- */
184
- /** The bytes of a {@link BundleInput}, collected. */
185
- async function bundleBytes(input) {
186
- if (input instanceof Uint8Array) return input;
187
- const chunks = [];
188
- let length = 0;
189
- for await (const chunk of input) {
190
- chunks.push(chunk);
191
- length += chunk.length;
192
- }
193
- const out = new Uint8Array(length);
194
- let at = 0;
195
- for (const chunk of chunks) {
196
- out.set(chunk, at);
197
- at += chunk.length;
198
- }
199
- return out;
200
- }
201
- /**
202
- * builtin/bundle.c's `open_bundle` (`read_bundle_header`): the header and the pack, or git's
203
- * `error:` line (the bundle reported as `name`: its path, `<stdin>` for `-`).
204
- */
205
- function openBundle(bytes, name) {
206
- const parsed = parseBundleHeader(bytes, name);
207
- if (!parsed.ok) return {
208
- ok: false,
209
- error: `error: ${parsed.error}\n`
210
- };
211
- return {
212
- ok: true,
213
- bundle: {
214
- header: parsed.header,
215
- pack: bytes.subarray(parsed.packOffset)
216
- }
217
- };
218
- }
219
- /**
220
- * bundle.c's `verify_bundle`: every prerequisite must be an object here (each missing one
221
- * on an `error:` line after `Repository lacks these prerequisite commits:`, unless quiet),
222
- * then connected to the refs (`check_connected` of the prerequisites, `--not --all`); with
223
- * `verbose`, what the bundle holds on stdout.
224
- */
225
- async function verifyBundleIn(repository, header, options = {}) {
226
- const objects = historyWithoutLazyFetch(repository.history);
227
- let stderr = "";
228
- let missing = 0;
229
- for (const prerequisite of header.prerequisites) {
230
- if (await objectExists(objects, prerequisite.id)) continue;
231
- missing++;
232
- if (options.quiet) continue;
233
- if (missing === 1) stderr += "error: Repository lacks these prerequisite commits:\n";
234
- stderr += `error: ${prerequisite.id} \n`;
235
- }
236
- if (missing > 0) return {
237
- ok: false,
238
- stdout: "",
239
- stderr
240
- };
241
- let ok = true;
242
- const tips = header.prerequisites.map((p) => p.id);
243
- if (tips.length > 0) {
244
- const facade = createRepositoryFacade({ history: objects });
245
- if (await connectivityErrors(facade, tips, {
246
- known: await repository.refValues(),
247
- shallow: new Set(await repository.shallow())
248
- })) {
249
- ok = false;
250
- stderr += "error: some prerequisite commits exist in the object store, but are not connected to the repository's history\n";
251
- }
252
- }
253
- let stdout = "";
254
- if (options.verbose) {
255
- const refs = header.references;
256
- stdout += refs.length === 1 ? "The bundle contains this ref:\n" : `The bundle contains these ${refs.length} refs:\n`;
257
- stdout += listBundleRefs(refs);
258
- const prereqs = header.prerequisites;
259
- if (prereqs.length === 0) stdout += "The bundle records a complete history.\n";
260
- else {
261
- stdout += prereqs.length === 1 ? "The bundle requires this ref:\n" : `The bundle requires these ${prereqs.length} refs:\n`;
262
- stdout += listBundleRefs(prereqs);
263
- }
264
- stdout += `The bundle uses this hash algorithm: ${header.objectFormat.name}\n`;
265
- if (header.filter !== void 0) stdout += `The bundle uses this filter: ${header.filter}\n`;
266
- }
267
- return {
268
- ok,
269
- stdout,
270
- stderr
271
- };
272
- }
273
- /** git's `parse_object` succeeds: the object is here, whatever its type. */
274
- async function objectExists(history, id) {
275
- const objects = history.objects;
276
- if (objects) return objects.has(id).catch(() => false);
277
- for (const store of [
278
- history.commits,
279
- history.trees,
280
- history.blobs,
281
- history.tags
282
- ]) if (await store.has(id).catch(() => false)) return true;
283
- return false;
284
- }
285
- //#endregion
286
- //#region src/commands/bundle/bundle-transport.ts
287
- /**
288
- * git's bundle transport (transport.c's `bundle_vtable`): a remote URL that is a path to a
289
- * bundle file is read as a repository whose refs are the bundle's and whose only pack is the
290
- * bundle's. Fetch, clone, pull and ls-remote reach it through an upload-pack served in
291
- * process from the bundle: its refs advertised (in git's order: the bundle's refs reversed,
292
- * as `get_refs_from_bundle` prepends each), and any fetch answered with the bundle's pack,
293
- * once the fetching repository has the bundle's prerequisites (`unbundle`'s `verify_bundle`).
294
- */
295
- /**
296
- * A fetch from a bundle the repository lacks the prerequisites of: `verify_bundle`'s lines
297
- * (`git fetch` exits 1; `git clone` adds `fatal: remote transport reported error`, 128).
298
- */
299
- var BundlePrerequisitesError = class extends TransportError$1 {
300
- lines;
301
- constructor(lines) {
302
- super(lines.replace(/\n$/, ""), void 0, { exitCode: 1 });
303
- this.lines = lines;
304
- this.name = "BundlePrerequisitesError";
305
- }
306
- };
307
- /** Bytes per chunk the served pack is cut into. */
308
- const CHUNK = 65536;
309
- /**
310
- * Runs `run` over a connection to an upload-pack serving the bundle (protocol v0). A fetch
311
- * that needs the pack verifies the bundle first: when the repository lacks its prerequisites
312
- * the fetch fails with git's lines (exit 1, as `git fetch` returns).
313
- */
314
- async function withBundleUploadPack(remote, createPair, run) {
315
- const { header, pack } = remote.bundle;
316
- let refused;
317
- const facade = {
318
- objectFormat: header.objectFormat,
319
- importPack: () => Promise.reject(/* @__PURE__ */ new Error("a bundle cannot be written to")),
320
- async *exportPack() {
321
- const verified = await remote.verify();
322
- if (!verified.ok) {
323
- refused = verified.stderr;
324
- throw new Error("bundle prerequisites missing");
325
- }
326
- for (let at = 0; at < pack.length; at += CHUNK) yield pack.subarray(at, at + CHUNK);
327
- },
328
- has: async (oid) => header.references.some((r) => r.id === oid),
329
- async *walkAncestors() {}
330
- };
331
- const [client, server] = createPair();
332
- const serving = serveOverDuplex({
333
- duplex: server,
334
- repository: facade,
335
- refStore: bundleRefStore(header),
336
- service: "git-upload-pack"
337
- }).finally(() => server.close?.());
338
- try {
339
- const connection = await openDuplexConnection(client, { closeDuplex: true });
340
- try {
341
- return await run(connection);
342
- } catch (error) {
343
- if (refused !== void 0) throw new BundlePrerequisitesError(refused);
344
- throw error;
345
- } finally {
346
- await connection.close();
347
- }
348
- } finally {
349
- await client.close?.();
350
- await serving.catch(() => void 0);
351
- }
352
- }
353
- /** The refs a bundle advertises: read-only, in `get_refs_from_bundle`'s (reversed) order. */
354
- function bundleRefStore(header) {
355
- const refs = [...header.references].reverse();
356
- return {
357
- get: async (name) => refs.find((r) => r.name === name)?.id,
358
- update: () => Promise.reject(/* @__PURE__ */ new Error("a bundle cannot be written to")),
359
- listAll: async () => refs.map((r) => [r.name, r.id]),
360
- isRefTip: async (oid) => refs.some((r) => r.id === oid)
361
- };
362
- }
363
- //#endregion
10
+ import { GitNamespaceError, ReceivePackDiedError, createRepositoryFacade, createTransportRefStore, gitNamespacePrefix, openDuplexConnection, openDuplexReceivePackConnection, pushCertificateEnv, serveOverDuplex, serverSettingsFromConfig } from "@statewalker/vcs-transport";
364
11
  //#region src/commands/worktree-prune-command.ts
365
12
  /**
366
13
  * Prune the administrative files of worktrees that are gone.
@@ -1004,7 +651,7 @@ var ReadTreeCommand = class extends GitCommand {
1004
651
  refused(refusal?.message, refusal?.paths);
1005
652
  } else if (treeIds.length === 2) {
1006
653
  const [h, m] = treeIds;
1007
- const refusal = await switchTrees(sequencerCtx, await flatTree(this.trees, h), await flatTree(this.trees, m), {
654
+ const refusal = await switchTrees(sequencerCtx, await flatTree(this.trees, h, { asIndex: true }), await flatTree(this.trees, m, { asIndex: true }), {
1008
655
  action: "merge",
1009
656
  operation: "read-tree",
1010
657
  update,
@@ -1497,6 +1144,106 @@ async function verifyAbsent(worktree, path, tracked, kind, options = {}) {
1497
1144
  return firstPlainError({ [kind]: [path] });
1498
1145
  }
1499
1146
  //#endregion
1147
+ //#region src/commands/served-lazy-fetch.ts
1148
+ /**
1149
+ * The lazy fetch of a served partial clone while upload-pack builds a pack (git's
1150
+ * upload-pack, whose pack-objects reads an absent promisor object through
1151
+ * promisor_remote_get_direct).
1152
+ *
1153
+ * Since git 2.45 (and the 2.43.4 backport) upload-pack sets `GIT_NO_LAZY_FETCH=1` unless its
1154
+ * environment already sets the variable, so by default a pack that needs an absent promisor
1155
+ * object fails: pack-objects prints `warning: lazy fetching disabled; some objects may not be
1156
+ * available` and dies `could not fetch <id> from promisor remote`. Ours does the same unless
1157
+ * lazy fetching is opted in: the operator's `servedRepositoryOf(opened, { lazyFetch })`, or a
1158
+ * local remote's upload-pack when the client's host environment says `GIT_NO_LAZY_FETCH=0`
1159
+ * (git's child inherits it). Then the absent object is fetched from the served repository's
1160
+ * own promisor remotes, through the transports given, and the pack holds it.
1161
+ *
1162
+ * Promisor URLs come from the served repository's configuration, which is repository content:
1163
+ * the fetch never carries static credentials or headers, only a per-URL credential helper.
1164
+ *
1165
+ * @example
1166
+ * ```ts
1167
+ * const served = await servedRepositoryOf(opened, {
1168
+ * lazyFetch: { transports: createDefaultTransports() },
1169
+ * });
1170
+ * ```
1171
+ */
1172
+ /**
1173
+ * The history upload-pack reads for `remote`, as git's upload-pack reads it: a view of its
1174
+ * own whose absent promisor objects are refused with git's warning and death
1175
+ * (`GIT_NO_LAZY_FETCH=1`), or, when `lazyFetch` opts in, fetched from the repository's
1176
+ * promisor remotes through its transports. The store's promisor and fetcher are left as
1177
+ * they are, so receive-pack and every other reader of the store are untouched. A repository
1178
+ * without worktrees or promisor remotes, or without promisor packs unless `lazyFetch` is
1179
+ * given, is read through its view without lazy fetch.
1180
+ *
1181
+ * @example
1182
+ * ```ts
1183
+ * const history = await uploadPackHistory(opened, { transports }, hooks.hostEnvironment);
1184
+ * ```
1185
+ */
1186
+ async function uploadPackHistory(remote, lazyFetch, environment) {
1187
+ const plain = historyWithoutLazyFetch(remote.history);
1188
+ const promisor = (() => {
1189
+ try {
1190
+ return remote.history.objects?.promisor;
1191
+ } catch {
1192
+ return;
1193
+ }
1194
+ })();
1195
+ if (!promisor || !remote.worktrees) return plain;
1196
+ if (!lazyFetch && (await promisor.promisorPacks().catch(() => [])).length === 0) return plain;
1197
+ let view;
1198
+ const workingCopy = await servedWorkingCopy(remote, () => view ?? plain, lazyFetch?.environment ?? environment).catch(() => void 0);
1199
+ if (!workingCopy || !hasPromisorRemote(RemoteConfigStore.from(workingCopy))) return plain;
1200
+ const fetcher = lazyFetch ? createPromisorFetcher(workingCopy, {
1201
+ ...lazyFetch.transports ? { transports: lazyFetch.transports } : {},
1202
+ ...lazyFetch.credentialHelper ? { credentialHelper: lazyFetch.credentialHelper } : {},
1203
+ ...lazyFetch.timeout !== void 0 ? { timeout: lazyFetch.timeout } : {},
1204
+ ...lazyFetch.warningCallback ? { warningCallback: lazyFetch.warningCallback } : {}
1205
+ }) : refusingFetcher(() => view?.objects?.promisor?.warnings);
1206
+ view = historyWithPromisorFetcher(remote.history, fetcher);
1207
+ return view ?? plain;
1208
+ }
1209
+ /**
1210
+ * upload-pack's `GIT_NO_LAZY_FETCH=1`: every read of an absent object still asks (git's
1211
+ * pack-objects reads with `fetch_if_missing`), fetch_objects refuses with its warning (once
1212
+ * per upload-pack process: a refusal of a promisor object is its death), and
1213
+ * promisor_remote_get_direct dies for a promisor object.
1214
+ */
1215
+ function refusingFetcher(warnings) {
1216
+ return {
1217
+ hasPromisorRemote: () => true,
1218
+ invalidate: () => {},
1219
+ fetchIfMissing: () => true,
1220
+ async fetch(ids) {
1221
+ warnings()?.push(LAZY_FETCH_DISABLED_WARNING);
1222
+ return ids;
1223
+ }
1224
+ };
1225
+ }
1226
+ /**
1227
+ * The served repository as a working copy the promisor fetcher reads (its configuration,
1228
+ * remotes, local paths), over the history `history` gives (upload-pack's view: the fetch's
1229
+ * warnings go to its promisor, its objects to the store) and in `environment`.
1230
+ */
1231
+ async function servedWorkingCopy(remote, history, environment) {
1232
+ const worktrees = remote.worktrees;
1233
+ if (!worktrees) return void 0;
1234
+ const base = worktreeAdminWorkingCopy(await worktrees.openAdmin());
1235
+ const own = (target, key) => {
1236
+ const value = Reflect.get(target, key, target);
1237
+ return typeof value === "function" ? value.bind(target) : value;
1238
+ };
1239
+ const config = environment ? new Proxy(base.config, { get: (target, key) => key === "environment" ? environment : own(target, key) }) : base.config;
1240
+ return new Proxy(base, { get: (target, key) => {
1241
+ if (key === "history") return history();
1242
+ if (key === "config") return config;
1243
+ return own(target, key);
1244
+ } });
1245
+ }
1246
+ //#endregion
1500
1247
  //#region src/commands/local-transport.ts
1501
1248
  /**
1502
1249
  * git's local transport: a repository named by a path (or a `file://` URL) is opened through
@@ -1504,6 +1251,21 @@ async function verifyAbsent(worktree, path, tracked, kind, options = {}) {
1504
1251
  * in-memory duplex, where git spawns `git-upload-pack '<path>'`. Which transport a URL takes
1505
1252
  * is decided in `remote-transport.ts` (`resolveRemote`).
1506
1253
  */
1254
+ var local_transport_exports = /* @__PURE__ */ __exportAll({
1255
+ createDuplexPair: () => createDuplexPair,
1256
+ httpBackendEnv: () => httpBackendEnv,
1257
+ openLocalRemote: () => openLocalRemote,
1258
+ pushToDeploy: () => pushToDeploy,
1259
+ quarantineEnv: () => quarantineEnv,
1260
+ receiveFsckSettingsOf: () => receiveFsckSettingsOf,
1261
+ receivePackSettingsOf: () => receivePackSettingsOf,
1262
+ remoteHookSession: () => remoteHookSession,
1263
+ servedMaxTreeDepth: () => servedMaxTreeDepth,
1264
+ servedUseBitmaps: () => servedUseBitmaps,
1265
+ withLocalReceivePack: () => withLocalReceivePack,
1266
+ withLocalUploadPack: () => withLocalUploadPack,
1267
+ withReceiveTransactionHook: () => withReceiveTransactionHook
1268
+ });
1507
1269
  /** The client's lines when the remote end of a local transport died. */
1508
1270
  const COULD_NOT_READ = "fatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.";
1509
1271
  const NOT_A_REPOSITORY = (path) => `fatal: '${path}' does not appear to be a git repository\n${COULD_NOT_READ}`;
@@ -1511,25 +1273,53 @@ const NOT_A_REPOSITORY = (path) => `fatal: '${path}' does not appear to be a git
1511
1273
  * A connected pair of in-memory duplex streams: what one side writes, the other reads. `end`
1512
1274
  * half-closes a side (the other one reads to its end and can still answer); `close` ends it.
1513
1275
  */
1514
- function createDuplexPair() {
1276
+ function createDuplexPair(options = {}) {
1277
+ const highWaterMark = options.highWaterMark;
1515
1278
  const make = () => {
1516
1279
  const queue = [];
1280
+ let queued = 0;
1517
1281
  let ended = false;
1282
+ let abandoned = false;
1518
1283
  let wake;
1284
+ let writers = [];
1285
+ const release = (error) => {
1286
+ const waiting = writers;
1287
+ writers = [];
1288
+ for (const w of waiting) if (error) w.reject(error);
1289
+ else w.resolve();
1290
+ };
1519
1291
  const push = (chunk) => {
1520
1292
  if (chunk === null) ended = true;
1521
- else queue.push(chunk);
1293
+ else {
1294
+ if (abandoned) return Promise.reject(/* @__PURE__ */ new Error("the stream's reader stopped"));
1295
+ queue.push(chunk);
1296
+ queued += chunk.length;
1297
+ }
1522
1298
  wake?.();
1523
1299
  wake = void 0;
1300
+ if (chunk === null || highWaterMark === void 0 || queued < highWaterMark) return;
1301
+ return new Promise((resolve, reject) => writers.push({
1302
+ resolve,
1303
+ reject
1304
+ }));
1305
+ };
1306
+ const abandon = () => {
1307
+ if (highWaterMark === void 0) return;
1308
+ abandoned = true;
1309
+ queue.length = 0;
1310
+ queued = 0;
1311
+ release(/* @__PURE__ */ new Error("the stream's reader stopped"));
1524
1312
  };
1525
1313
  async function* read() {
1526
1314
  while (true) {
1527
1315
  const next = queue.shift();
1528
1316
  if (next) {
1317
+ queued -= next.length;
1318
+ if (highWaterMark === void 0 || queued < highWaterMark) release();
1529
1319
  yield next;
1530
1320
  continue;
1531
1321
  }
1532
- if (ended) return;
1322
+ if (ended || abandoned) return;
1533
1323
  await new Promise((resolve) => {
1534
1324
  wake = resolve;
1535
1325
  });
@@ -1537,7 +1327,8 @@ function createDuplexPair() {
1537
1327
  }
1538
1328
  return {
1539
1329
  push,
1540
- read
1330
+ read,
1331
+ abandon
1541
1332
  };
1542
1333
  };
1543
1334
  const a = make();
@@ -1557,17 +1348,23 @@ function createDuplexPair() {
1557
1348
  return [{
1558
1349
  [Symbol.asyncIterator]: () => a.read()[Symbol.asyncIterator](),
1559
1350
  write: (data) => {
1560
- if (!aClosed) b.push(data.slice());
1351
+ if (!aClosed) return b.push(data.slice());
1561
1352
  },
1562
1353
  end: endLeft,
1563
- close: endLeft
1354
+ close: async () => {
1355
+ a.abandon();
1356
+ await endLeft();
1357
+ }
1564
1358
  }, {
1565
1359
  [Symbol.asyncIterator]: () => b.read()[Symbol.asyncIterator](),
1566
1360
  write: (data) => {
1567
- if (!bClosed) a.push(data.slice());
1361
+ if (!bClosed) return a.push(data.slice());
1568
1362
  },
1569
1363
  end: endRight,
1570
- close: endRight
1364
+ close: async () => {
1365
+ b.abandon();
1366
+ await endRight();
1367
+ }
1571
1368
  }];
1572
1369
  }
1573
1370
  /**
@@ -1583,19 +1380,37 @@ async function openLocalRemote(workingCopy, path) {
1583
1380
  return opened;
1584
1381
  }
1585
1382
  /**
1383
+ * The death of a local upload-pack or receive-pack started under a `GIT_NAMESPACE` git
1384
+ * refuses (`get_git_namespace`'s `bad git namespace path "<ns>"`), as a git 2.5x client shows
1385
+ * it: then its own death, which for a v2 fetch is its ls-refs reader's (`v2`).
1386
+ */
1387
+ function checkLocalNamespace(namespace, v2 = false) {
1388
+ try {
1389
+ gitNamespacePrefix(namespace);
1390
+ } catch (error) {
1391
+ if (error instanceof GitNamespaceError) {
1392
+ const client = v2 ? "fatal: expected flush after ref listing" : COULD_NOT_READ;
1393
+ throw new TransportError$1(`fatal: ${error.message}\n${client}`);
1394
+ }
1395
+ throw error;
1396
+ }
1397
+ }
1398
+ /**
1586
1399
  * Runs `run` over a connection to upload-pack serving a local repository (opened by
1587
1400
  * {@link openLocalRemote}) with protocol v2, git's default `protocol.version` (v0 when the
1588
1401
  * option says 0, v1 when it says 1), as git's local transport runs `git-upload-pack '<path>'`,
1589
1402
  * in process.
1590
1403
  */
1591
1404
  async function withLocalUploadPack(remote, run, options = {}) {
1405
+ checkLocalNamespace(options.namespace, (options.protocolVersion ?? 2) === 2);
1592
1406
  const head = await remote.history.refs.get("HEAD").catch(() => void 0);
1593
1407
  const settings = serverSettingsOf(remote);
1594
1408
  const [client, server] = createDuplexPair();
1409
+ const history = await uploadPackHistory(remote, options.lazyFetch, options.lazyFetch?.environment);
1595
1410
  const serving = (async () => serveOverDuplex({
1596
1411
  duplex: server,
1597
1412
  repository: createRepositoryFacade({
1598
- history: historyWithoutLazyFetch(remote.history),
1413
+ history,
1599
1414
  useBitmaps: servedUseBitmaps(remote),
1600
1415
  sparseFilterPatterns: sparseFilterMatcher,
1601
1416
  maxTreeDepth: servedMaxTreeDepth(remote)
@@ -1614,14 +1429,16 @@ async function withLocalUploadPack(remote, run, options = {}) {
1614
1429
  ...settings.advertiseSID ? { advertiseSID: true } : {},
1615
1430
  ...settings.advertiseObjectInfo ? { advertiseObjectInfo: true } : {},
1616
1431
  ...settings.promisorRemoteInfo !== void 0 ? { promisorRemoteInfo: settings.promisorRemoteInfo } : {},
1617
- ...head && "target" in head ? { currentBranch: head.target } : {}
1432
+ ...options.packObjectsHook ? { packObjectsHook: options.packObjectsHook } : {},
1433
+ ...head && "target" in head ? { currentBranch: head.target } : {},
1434
+ ...options.namespace ? { namespace: options.namespace } : {}
1618
1435
  }))().finally(() => server.close?.());
1619
1436
  try {
1620
1437
  const connection = await openDuplexConnection(client, { closeDuplex: true });
1621
1438
  try {
1622
1439
  return await run(connection);
1623
1440
  } catch (error) {
1624
- throw packFailure(error) ?? error;
1441
+ throw packFailure(error) ?? await packObjectsDeath(error, serving) ?? error;
1625
1442
  } finally {
1626
1443
  await connection.close();
1627
1444
  }
@@ -1631,6 +1448,27 @@ async function withLocalUploadPack(remote, run, options = {}) {
1631
1448
  }
1632
1449
  }
1633
1450
  /**
1451
+ * pack-objects died before the pack's first byte (its stderr already relayed on the
1452
+ * progress band, upload-pack's abort on band 3: `PackObjectsError`): the lines git's local
1453
+ * transport prints after that, upload-pack's own (on the shared stderr: create_pack_file's
1454
+ * error, a failed `uploadpack.packObjectsHook`'s own, then its death), the abort as the client
1455
+ * shows it, and index-pack finding no pack.
1456
+ */
1457
+ async function packObjectsDeath(error, serving) {
1458
+ const abort = "aborting due to possible repository corruption on the remote side.";
1459
+ if (!(error instanceof Error) || error.name !== "ServerError") return void 0;
1460
+ if (!error.message.startsWith(abort)) return void 0;
1461
+ const reported = (await serving.catch(() => void 0))?.error;
1462
+ if (reported === void 0) return void 0;
1463
+ const died = reported.startsWith("fatal: ") ? "error: git upload-pack: git-pack-objects died with error." : `error: ${reported}`;
1464
+ return new TransportError$1([
1465
+ died,
1466
+ `fatal: git upload-pack: ${abort}`,
1467
+ `remote: ${abort}`,
1468
+ "fatal: protocol error: bad pack header"
1469
+ ].join("\n"), void 0, { cause: error });
1470
+ }
1471
+ /**
1634
1472
  * The lines git prints when upload-pack's pack-objects fails on an object it cannot read
1635
1473
  * (upload-pack.c's create_pack_file): its own error and death (upload-pack's stderr, which
1636
1474
  * the local transport shares), the abort message it sends on band 3, then the client's
@@ -1772,6 +1610,7 @@ async function pushToDeploy(worktrees, ref, newOid) {
1772
1610
  * included, is the current branch `receive.denyCurrentBranch` rules on.
1773
1611
  */
1774
1612
  async function withLocalReceivePack(remote, run, hooks, transactionHooks = hooks, options = {}) {
1613
+ checkLocalNamespace(options.namespace);
1775
1614
  try {
1776
1615
  await remote.checkOwnership?.();
1777
1616
  } catch (error) {
@@ -1779,7 +1618,7 @@ async function withLocalReceivePack(remote, run, hooks, transactionHooks = hooks
1779
1618
  throw error;
1780
1619
  }
1781
1620
  const receiveHooks = hooks?.enabled ? scriptReceiveHooks(hooks) : void 0;
1782
- return withReceiveTransactionHook(remote, transactionHooks, () => receiveOver(remote, run, hooks, receiveHooks, options.protocolVersion === 1, options));
1621
+ return withReceiveTransactionHook(remote, options.namespace && transactionHooks ? transactionHooks.withEnv({ GIT_NAMESPACE: options.namespace }) : transactionHooks, () => receiveOver(remote, run, hooks, receiveHooks, options.protocolVersion === 1, options));
1783
1622
  }
1784
1623
  /**
1785
1624
  * The receive-side reference-transaction hooks installed on a ref store, oldest first, and
@@ -1899,6 +1738,7 @@ async function receivePackSettingsOf(remote, hooks, receiveHooks = hooks?.enable
1899
1738
  ...settings.advertiseSID ? { advertiseSID: true } : {},
1900
1739
  ...settings.advertiseAtomic !== void 0 ? { advertiseAtomic: settings.advertiseAtomic } : {},
1901
1740
  ...settings.maxInputSize !== void 0 ? { maxInputSize: settings.maxInputSize } : {},
1741
+ ...host.maxObjectSize !== void 0 ? { maxObjectSize: host.maxObjectSize } : {},
1902
1742
  ...settings.certNonceSeed !== void 0 ? { certNonceSeed: settings.certNonceSeed } : {},
1903
1743
  ...settings.certNonceSlop !== void 0 ? { certNonceSlop: settings.certNonceSlop } : {},
1904
1744
  pushCertificates: { verify: pushCertVerifierOf(remote, hooks) },
@@ -1969,7 +1809,7 @@ function afterPushOf(remote, hooks) {
1969
1809
  const result = await new GarbageCollectCommand(workingCopy).setAuto(true).setQuiet(true).call();
1970
1810
  lines = [...result.errors ?? [], ...result.warnings ?? []];
1971
1811
  } else {
1972
- const { MaintenanceRunCommand } = await import("./maintenance-run-command-UiSIaeP8.js").then((n) => n.r);
1812
+ const { MaintenanceRunCommand } = await import("./maintenance-run-command-DZFnbnbo.js").then((n) => n.r);
1973
1813
  lines = (await new MaintenanceRunCommand(workingCopy).setAuto(true).setQuiet(true).call()).stderr.split("\n").filter((l) => l.length > 0);
1974
1814
  }
1975
1815
  if (lines.length > 0) await ctx.message(`${lines.join("\n")}\n`);
@@ -2016,7 +1856,8 @@ async function receiveOver(remote, run, hooks, receiveHooks, version1, options =
2016
1856
  }),
2017
1857
  refStore: createTransportRefStore(remote.history.refs),
2018
1858
  service: "git-receive-pack",
2019
- ...version1 ? { announceVersion1: true } : {}
1859
+ ...version1 ? { announceVersion1: true } : {},
1860
+ ...options.namespace ? { namespace: options.namespace } : {}
2020
1861
  }).finally(() => server.close?.());
2021
1862
  const died = async (cause) => {
2022
1863
  await client.close?.();
@@ -2169,8 +2010,19 @@ function httpBackendEnv(hooks, client) {
2169
2010
  if (committer.email === void 0) env.GIT_COMMITTER_EMAIL = `${user}@http.${addr}`;
2170
2011
  return env;
2171
2012
  }
2172
- /** {@link httpBackendEnv} of a push its hook context describes (HTTP: it has a request). */
2013
+ /**
2014
+ * The variables receive-pack's hooks inherit from it for a push its hook context describes:
2015
+ * `GIT_NAMESPACE` when the push is served in a namespace, and {@link httpBackendEnv} for one
2016
+ * over HTTP (it has a request).
2017
+ */
2173
2018
  function hookClientEnv(hooks, ctx) {
2019
+ return {
2020
+ ...ctx?.namespace ? { GIT_NAMESPACE: ctx.namespace } : {},
2021
+ ...httpEnvOf(hooks, ctx)
2022
+ };
2023
+ }
2024
+ /** {@link httpBackendEnv} of a push its hook context describes (HTTP: it has a request). */
2025
+ function httpEnvOf(hooks, ctx) {
2174
2026
  return httpBackendEnv(hooks, ctx?.request ? {
2175
2027
  http: true,
2176
2028
  ...ctx.remoteUser !== void 0 ? { remoteUser: ctx.remoteUser } : {},
@@ -2286,320 +2138,4 @@ function scriptReceiveHooks(hooks) {
2286
2138
  };
2287
2139
  }
2288
2140
  //#endregion
2289
- //#region src/commands/remote-transport.ts
2290
- /**
2291
- * How a remote command reaches a remote, as git's `transport_get` and `git_connect` decide:
2292
- * the URL (already rewritten by `url.<base>.insteadOf`, see `RemoteConfigStore`) is checked
2293
- * against `protocol.allow`; a path or `file://` URL is git's local transport (served in
2294
- * process, see `local-transport.ts`); anything else goes to the connector the transport
2295
- * registry names for it (smart HTTP by default).
2296
- */
2297
- var remote_transport_exports = /* @__PURE__ */ __exportAll({
2298
- bundleRemoteOf: () => bundleRemoteOf,
2299
- checkTransportAllowed: () => checkTransportAllowed,
2300
- httpSessionSettings: () => httpSessionSettings,
2301
- isTransportAllowed: () => isTransportAllowed,
2302
- openBundleRemote: () => openBundleRemote,
2303
- openResolvedRemote: () => openResolvedRemote,
2304
- prepareRemote: () => prepareRemote,
2305
- protocolVersionOf: () => protocolVersionOf,
2306
- remoteContextOf: () => remoteContextOf,
2307
- resolveRemote: () => resolveRemote,
2308
- withRemoteReceivePack: () => withRemoteReceivePack,
2309
- withRemoteSession: () => withRemoteSession,
2310
- withRemoteUploadPack: () => withRemoteUploadPack
2311
- });
2312
- const NO_PATH = "fatal: no path specified; see 'git help pull' for valid url syntax";
2313
- /** transport.c's `parse_protocol_config`. */
2314
- function parsePolicy(key, value) {
2315
- const lower = value.toLowerCase();
2316
- if (lower === "always" || lower === "never" || lower === "user") return lower;
2317
- throw new InvalidConfigError(key, `fatal: unknown value for config '${key}': ${value}`);
2318
- }
2319
- /**
2320
- * transport.c's `is_transport_allowed`: `GIT_ALLOW_PROTOCOL` when set (the only transports
2321
- * allowed); else `protocol.<type>.allow`, then `protocol.allow`, then git's defaults (http,
2322
- * https, git and ssh always; ext never; any other, `file` included, only when
2323
- * `GIT_PROTOCOL_FROM_USER` is not false).
2324
- *
2325
- * @example
2326
- * ```ts
2327
- * isTransportAllowed("ext", store); // false
2328
- * isTransportAllowed("file", store, { protocolFromUser: false } as GitHostEnvironment); // false
2329
- * ```
2330
- */
2331
- function isTransportAllowed(type, config, environment) {
2332
- if (environment?.allowProtocol !== void 0) return environment.allowProtocol.split(":").includes(type);
2333
- const key = `protocol.${type}.allow`;
2334
- const own = config.value(key);
2335
- const fallback = config.value("protocol.allow");
2336
- let policy;
2337
- if (own !== void 0) policy = parsePolicy(key, own);
2338
- else if (fallback !== void 0) policy = parsePolicy("protocol.allow", fallback);
2339
- else if ([
2340
- "http",
2341
- "https",
2342
- "git",
2343
- "ssh"
2344
- ].includes(type)) policy = "always";
2345
- else if (type === "ext") policy = "never";
2346
- else policy = "user";
2347
- if (policy === "user") return environment?.protocolFromUser ?? true;
2348
- return policy === "always";
2349
- }
2350
- /** transport.c's `transport_check_allowed`: git's "transport '<type>' not allowed". */
2351
- function checkTransportAllowed(type, config, environment) {
2352
- if (!isTransportAllowed(type, config, environment)) throw new TransportError$1(`fatal: transport '${type}' not allowed`);
2353
- }
2354
- /**
2355
- * `protocol.version` (git's `get_protocol_version_config`): 0, 1 or 2, default 2; any other
2356
- * value is git's "unknown value for config 'protocol.version'".
2357
- */
2358
- function protocolVersionOf(config) {
2359
- const value = config.value("protocol.version");
2360
- if (value === void 0) return 2;
2361
- if (value === "0" || value === "1" || value === "2") return Number(value);
2362
- throw new InvalidConfigError("protocol.version", `fatal: unknown value for config 'protocol.version': ${value}`);
2363
- }
2364
- /**
2365
- * Resolves a remote URL (already rewritten by `insteadOf`) to its transport, in git's order
2366
- * (transport_get, then git_connect): a `<helper>::<address>` URL goes to the connector for
2367
- * the helper; `rsync:` is refused; a path or `file://` URL is the local transport (its path
2368
- * checked first, then `protocol.file.allow`); `ssh`/`git` URLs (path, then
2369
- * `protocol.<scheme>.allow`) and any other `<scheme>://` (`protocol.<scheme>.allow`) go to
2370
- * the registry's connector. Without one, git's words: "unable to find remote helper" where
2371
- * git would run a remote helper, ours for ssh and git:// (git would connect directly).
2372
- *
2373
- * @throws TransportError git's lines (exit 128)
2374
- */
2375
- function resolveRemote(url, context) {
2376
- const { config, environment, transports } = context;
2377
- const parsed = parseGitUrl(url);
2378
- const viaConnector = (type) => {
2379
- checkTransportAllowed(type, config, environment);
2380
- const connector = transports.resolve(parsed);
2381
- return connector ? {
2382
- kind: "connector",
2383
- url,
2384
- parsed,
2385
- connector
2386
- } : void 0;
2387
- };
2388
- const helperMissing = (helper) => new TransportError$1(`fatal: unable to find remote helper for '${helper}'`);
2389
- if (parsed.address !== void 0) return viaConnector(parsed.scheme) ?? throwError(helperMissing(parsed.scheme));
2390
- if (url.startsWith("rsync:")) throw new TransportError$1("fatal: git-over-rsync is no longer supported");
2391
- if (!(!isGitUrl(url) || /^(?:file|git|ssh|git\+ssh|ssh\+git):\/\//.test(url) || url === "")) {
2392
- const scheme = url.slice(0, url.indexOf(":"));
2393
- return viaConnector(scheme) ?? throwError(helperMissing(scheme));
2394
- }
2395
- if (!parsed.path && !parsed.scpLike) throw new TransportError$1(NO_PATH);
2396
- if (parsed.scheme === "ssh" || parsed.local) checkNotAnOption("pathname", parsed.path);
2397
- if (parsed.scheme === "file") {
2398
- checkTransportAllowed("file", config, environment);
2399
- return {
2400
- kind: "local",
2401
- url,
2402
- path: parsed.path
2403
- };
2404
- }
2405
- if (parsed.scheme === "ssh") {
2406
- checkTransportAllowed("ssh", config, environment);
2407
- checkNotAnOption("hostname", `${parsed.user !== void 0 ? `${parsed.user}@` : ""}${parsed.host ?? ""}`);
2408
- }
2409
- return viaConnector(parsed.scheme) ?? throwError(new TransportError$1(`fatal: cannot connect to '${url}': only http(s) and local repositories are reachable here`));
2410
- }
2411
- /**
2412
- * connect.c's `looks_like_command_line_option` checks: git's "strange hostname '<host>'
2413
- * blocked" (and pathname), so a remote URL cannot smuggle an option into the command git
2414
- * runs (`ssh -oProxyCommand=...`).
2415
- *
2416
- * @throws TransportError git's line (exit 128)
2417
- */
2418
- function checkNotAnOption(what, value) {
2419
- if (value.startsWith("-")) throw new TransportError$1(`fatal: strange ${what} '${value}' blocked`);
2420
- }
2421
- function throwError(error) {
2422
- throw error;
2423
- }
2424
- /**
2425
- * {@link resolveRemote}, then a local remote's repository opened (git's "does not appear to
2426
- * be a git repository" when it cannot be).
2427
- */
2428
- async function prepareRemote(workingCopy, url, transports) {
2429
- return openResolvedRemote(workingCopy, resolveRemote(url, remoteContextOf(workingCopy, transports)));
2430
- }
2431
- /** A resolved remote with its local repository opened ({@link prepareRemote}'s second half). */
2432
- async function openResolvedRemote(workingCopy, resolved) {
2433
- if (resolved.kind !== "local") return resolved;
2434
- const bundle = await openBundleRemote(workingCopy, resolved.url, resolved.path);
2435
- if (bundle) return {
2436
- kind: "bundle",
2437
- url: resolved.url,
2438
- path: resolved.path,
2439
- remote: bundle
2440
- };
2441
- return {
2442
- ...resolved,
2443
- repository: await openLocalRemote(workingCopy, resolved.path)
2444
- };
2445
- }
2446
- /**
2447
- * transport_get's `url_is_local_not_ssh(url) && is_file(url) && is_bundle(url, 1)`: a path
2448
- * (not a `file://` URL) to a regular file whose header reads as a bundle's, with what checks
2449
- * it against `workingCopy` (the repository fetching); undefined for anything else.
2450
- */
2451
- async function openBundleRemote(workingCopy, url, path) {
2452
- if (/^file:/i.test(url)) return void 0;
2453
- const bytes = await repositoryPlaceOf(workingCopy)?.readLocalFile?.(path).catch(() => void 0);
2454
- if (!bytes) return void 0;
2455
- return bundleRemoteOf(workingCopy, bytes, path);
2456
- }
2457
- /**
2458
- * A bundle's bytes as a remote of `workingCopy` (the repository fetching): undefined when
2459
- * they do not read as a bundle. `name` is how git reports it (its path as given).
2460
- */
2461
- function bundleRemoteOf(workingCopy, bytes, name) {
2462
- const opened = openBundle(bytes, name);
2463
- if (!opened.ok) return void 0;
2464
- const history = workingCopy.history;
2465
- return {
2466
- bundle: opened.bundle,
2467
- verify: () => verifyBundleIn({
2468
- history,
2469
- refValues: () => refValuesOf(history.refs),
2470
- shallow: async () => await history.refs.getShallow?.().catch(() => void 0) ?? []
2471
- }, opened.bundle.header)
2472
- };
2473
- }
2474
- /** Every ref's value and HEAD's (what `rev-list --all` starts from). */
2475
- async function refValuesOf(refs) {
2476
- const out = /* @__PURE__ */ new Set();
2477
- for await (const ref of refs.list()) {
2478
- const id = "objectId" in ref && ref.objectId ? ref.objectId : (await refs.resolve(ref.name).catch(() => void 0))?.objectId;
2479
- if (id) out.add(id);
2480
- }
2481
- const head = (await refs.resolve("HEAD").catch(() => void 0))?.objectId;
2482
- if (head) out.add(head);
2483
- return [...out];
2484
- }
2485
- /** The resolution context of a working copy: its configuration and host environment. */
2486
- function remoteContextOf(workingCopy, transports) {
2487
- const environment = hostEnvironmentOf(workingCopy);
2488
- return {
2489
- config: RemoteConfigStore.from(workingCopy),
2490
- ...environment ? { environment } : {},
2491
- transports
2492
- };
2493
- }
2494
- /**
2495
- * The dumb-HTTP settings a session takes from the configuration and the environment
2496
- * (`http.followRedirects` and the other `http.*` keys come with `httpSettings`): which
2497
- * alternates a dumb fetch may use (http-walker's `is_transport_allowed(<scheme>, 0)`: as a
2498
- * transport not from the user) and `$GIT_SMART_HTTP`.
2499
- */
2500
- function httpSessionSettings(workingCopy) {
2501
- const config = RemoteConfigStore.from(workingCopy);
2502
- const environment = hostEnvironmentOf(workingCopy);
2503
- const notFromUser = {
2504
- ...environment,
2505
- protocolFromUser: false
2506
- };
2507
- return {
2508
- alternateAllowed: (scheme) => isTransportAllowed(scheme, config, notFromUser),
2509
- ...environment?.smartHttp === false ? { smartHttp: false } : {}
2510
- };
2511
- }
2512
- function connectRequest(remote, service, options) {
2513
- return {
2514
- url: remote.parsed,
2515
- service,
2516
- protocolVersion: protocolVersionFor(service, options.protocolVersion),
2517
- ...options.program !== void 0 ? { program: options.program } : {},
2518
- ...options.credentials ? { credentials: options.credentials } : {},
2519
- ...options.headers ? { headers: options.headers } : {},
2520
- ...options.timeout !== void 0 ? { timeout: options.timeout } : {},
2521
- ...options.signal ? { signal: options.signal } : {},
2522
- ...options.httpSettings ? { http: options.httpSettings(remote.url) } : {},
2523
- ...options.credentialHelper ? { credentialHelper: options.credentialHelper } : {}
2524
- };
2525
- }
2526
- /**
2527
- * A native session whose stream closes once: the connection opened over it closes the stream
2528
- * (`closeDuplex`), and {@link withRemoteSession} closes it again for a `run` that opened none
2529
- * or failed before; the second close does nothing.
2530
- */
2531
- function closingOnce(session) {
2532
- if (session.kind !== "native") return session;
2533
- const inner = session.duplex;
2534
- let closing;
2535
- const duplex = {
2536
- [Symbol.asyncIterator]: () => inner[Symbol.asyncIterator](),
2537
- write: (data) => inner.write(data),
2538
- ...inner.end ? { end: () => inner.end?.() ?? Promise.resolve() } : {},
2539
- close: () => {
2540
- closing ??= inner.close?.() ?? Promise.resolve();
2541
- return closing;
2542
- }
2543
- };
2544
- return {
2545
- ...session,
2546
- duplex
2547
- };
2548
- }
2549
- /**
2550
- * Runs `run` over a session the remote's connector opens for `service` (the request's
2551
- * protocol version as git_connect asks for it: v0 for receive-pack when v2 is configured); a
2552
- * native session's stream is closed afterwards, once, whether or not `run` closed it.
2553
- */
2554
- async function withRemoteSession(remote, service, options, run) {
2555
- const request = connectRequest(remote, service, options);
2556
- const session = closingOnce(await remote.connector.connect(request));
2557
- try {
2558
- return await run(session, request);
2559
- } finally {
2560
- if (session.kind === "native") await session.duplex.close?.().catch(() => void 0);
2561
- }
2562
- }
2563
- /**
2564
- * Runs `run` over a connection to upload-pack of a remote: in process for a local one
2565
- * (`withLocalUploadPack`, protocol v2 unless `protocol.version` says otherwise), else over
2566
- * the session its connector opens (`openUploadPack`).
2567
- */
2568
- async function withRemoteUploadPack(remote, options, run) {
2569
- if (remote.kind === "local") return withLocalUploadPack(remote.repository, run, { protocolVersion: options.protocolVersion });
2570
- if (remote.kind === "bundle") return withBundleUploadPack(remote.remote, createDuplexPair, run);
2571
- return withRemoteSession(remote, "git-upload-pack", options, async (session, request) => {
2572
- const connection = await openUploadPack(session, request, {
2573
- ...options.gzipRequests !== void 0 ? { gzipRequests: options.gzipRequests } : {},
2574
- ...options.alternateAllowed ? { alternateAllowed: options.alternateAllowed } : {},
2575
- ...options.smartHttp === false ? { smartHttp: false } : {}
2576
- });
2577
- try {
2578
- return await run(connection);
2579
- } finally {
2580
- await connection.close();
2581
- }
2582
- });
2583
- }
2584
- /**
2585
- * Runs `run` over a connection to receive-pack of a remote: in process for a local one
2586
- * (`withLocalReceivePack`, with the remote repository's hooks), else over the session its
2587
- * connector opens (`openReceivePack`).
2588
- */
2589
- async function withRemoteReceivePack(remote, options, run, hooks, transactionHooks, local = {}) {
2590
- if (remote.kind === "bundle") throw new TransportError$1(`error: failed to push some refs to '${remote.url}'`, void 0, { exitCode: 1 });
2591
- if (remote.kind === "local") return withLocalReceivePack(remote.repository, run, hooks, transactionHooks, {
2592
- protocolVersion: options.protocolVersion,
2593
- ...local
2594
- });
2595
- return withRemoteSession(remote, "git-receive-pack", options, async (session, request) => {
2596
- const connection = await openReceivePack(session, request, { ...options.streamRequestBody !== void 0 ? { streamRequestBody: options.streamRequestBody } : {} });
2597
- try {
2598
- return await run(connection);
2599
- } finally {
2600
- await connection.close();
2601
- }
2602
- });
2603
- }
2604
- //#endregion
2605
- export { V3_BUNDLE_SIGNATURE as A, WorktreePruneCommand as C, openBundle as D, bundleBytes as E, listBundleRefs as M, parseBundleHeader as N, verifyBundleIn as O, GarbageCollectCommand as S, withBundleUploadPack as T, remoteHookSession as _, protocolVersionOf as a, withReceiveTransactionHook as b, resolveRemote as c, withRemoteUploadPack as d, createDuplexPair as f, receivePackSettingsOf as g, receiveFsckSettingsOf as h, prepareRemote as i, encodeBundleHeader as j, V2_BUNDLE_SIGNATURE as k, withRemoteReceivePack as l, quarantineEnv as m, httpSessionSettings as n, remoteContextOf as o, httpBackendEnv as p, openResolvedRemote as r, remote_transport_exports as s, bundleRemoteOf as t, withRemoteSession as u, servedMaxTreeDepth as v, BundlePrerequisitesError as w, ReadTreeCommand as x, servedUseBitmaps as y };
2141
+ export { WorktreePruneCommand as _, quarantineEnv as a, remoteHookSession as c, withLocalReceivePack as d, withLocalUploadPack as f, GarbageCollectCommand as g, ReadTreeCommand as h, openLocalRemote as i, servedMaxTreeDepth as l, uploadPackHistory as m, httpBackendEnv as n, receiveFsckSettingsOf as o, withReceiveTransactionHook as p, local_transport_exports as r, receivePackSettingsOf as s, createDuplexPair as t, servedUseBitmaps as u };