@statewalker/vcs-commands 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/am/am-command.d.ts.map +1 -1
- package/dist/commands/archive/archive-command.d.ts +81 -7
- package/dist/commands/archive/archive-command.d.ts.map +1 -1
- package/dist/commands/archive/archive-entry.d.ts +48 -5
- package/dist/commands/archive/archive-entry.d.ts.map +1 -1
- package/dist/commands/archive/tar-archive.d.ts +5 -2
- package/dist/commands/archive/tar-archive.d.ts.map +1 -1
- package/dist/commands/archive/zip-archive.d.ts +9 -2
- package/dist/commands/archive/zip-archive.d.ts.map +1 -1
- package/dist/commands/attributes-source.d.ts +5 -0
- package/dist/commands/attributes-source.d.ts.map +1 -1
- package/dist/commands/cat-file/cat-file-command.d.ts +9 -0
- package/dist/commands/cat-file/cat-file-command.d.ts.map +1 -1
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/clone-command.d.ts +9 -0
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/default-branch.d.ts +12 -0
- package/dist/commands/default-branch.d.ts.map +1 -1
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/format-rev-command.d.ts +6 -4
- package/dist/commands/format-rev-command.d.ts.map +1 -1
- package/dist/commands/fsmonitor-ipc.d.ts +30 -0
- package/dist/commands/fsmonitor-ipc.d.ts.map +1 -0
- package/dist/commands/fsmonitor-refresh.d.ts.map +1 -1
- package/dist/commands/http-config.d.ts +4 -2
- package/dist/commands/http-config.d.ts.map +1 -1
- package/dist/commands/index.d.ts +2 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +6 -6
- package/dist/commands/log-output.d.ts +6 -0
- package/dist/commands/log-output.d.ts.map +1 -1
- package/dist/commands/ls-files-command.d.ts.map +1 -1
- package/dist/commands/ls-tree-command.d.ts.map +1 -1
- package/dist/commands/mv-command.d.ts.map +1 -1
- package/dist/commands/pathspec.d.ts.map +1 -1
- package/dist/commands/plumbing-shared.d.ts +72 -0
- package/dist/commands/plumbing-shared.d.ts.map +1 -0
- package/dist/commands/repack-command.d.ts +12 -3
- package/dist/commands/repack-command.d.ts.map +1 -1
- package/dist/commands/replace-command.d.ts.map +1 -1
- package/dist/commands/repo-command.d.ts +28 -6
- package/dist/commands/repo-command.d.ts.map +1 -1
- package/dist/commands/rerere-command.d.ts +12 -0
- package/dist/commands/rerere-command.d.ts.map +1 -1
- package/dist/commands/rerere.d.ts +22 -0
- package/dist/commands/rerere.d.ts.map +1 -1
- package/dist/commands/reset-command.d.ts +19 -2
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/rev-parse-command.d.ts +3 -7
- package/dist/commands/rev-parse-command.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +24 -5
- package/dist/commands/revision-resolver.d.ts.map +1 -1
- package/dist/commands/signing.d.ts +8 -1
- package/dist/commands/signing.d.ts.map +1 -1
- package/dist/commands/status-command.d.ts +14 -1
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/submodule-add-command.d.ts +12 -0
- package/dist/commands/submodule-add-command.d.ts.map +1 -1
- package/dist/commands/submodule-update-command.d.ts +14 -0
- package/dist/commands/submodule-update-command.d.ts.map +1 -1
- package/dist/commands/tag-command.d.ts.map +1 -1
- package/dist/commands/update-index-command.d.ts +21 -0
- package/dist/commands/update-index-command.d.ts.map +1 -1
- package/dist/{commands-Mlo1dxQN.js → commands-C2E51T1z.js} +942 -293
- package/dist/{fsck-CrhVMNIH.js → fsck-BjlxStsM.js} +1 -1
- package/dist/git-command.d.ts +14 -6
- package/dist/git-command.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/{maintenance-run-command-Bw21HEkH.js → maintenance-run-command-G_eWdA8O.js} +48 -17
- package/dist/remote-config/remote-config-store.d.ts +4 -1
- package/dist/remote-config/remote-config-store.d.ts.map +1 -1
- package/dist/{remote-transport-Bu4PGSMD.js → remote-transport-CSgTJ1BH.js} +3 -3
- package/dist/results/index.js +1 -1
- package/dist/{results-ERo9vELd.js → results-Dg1KHG8y.js} +669 -96
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +13 -13
- package/src/commands/am/am-command.ts +30 -14
- package/src/commands/archive/archive-command.ts +395 -59
- package/src/commands/archive/archive-entry.ts +88 -5
- package/src/commands/archive/tar-archive.ts +40 -9
- package/src/commands/archive/zip-archive.ts +72 -21
- package/src/commands/attributes-source.ts +13 -1
- package/src/commands/cat-file/cat-file-command.ts +64 -52
- package/src/commands/checkout-command.ts +22 -1
- package/src/commands/clone-command.ts +41 -2
- package/src/commands/default-branch.ts +19 -0
- package/src/commands/diff-command.ts +19 -1
- package/src/commands/format-rev-command.ts +28 -12
- package/src/commands/fsmonitor-ipc.ts +121 -0
- package/src/commands/fsmonitor-refresh.ts +7 -2
- package/src/commands/http-config.ts +14 -2
- package/src/commands/index.ts +2 -0
- package/src/commands/log-output.ts +11 -0
- package/src/commands/ls-files-command.ts +25 -33
- package/src/commands/ls-tree-command.ts +30 -22
- package/src/commands/mv-command.ts +37 -6
- package/src/commands/pathspec.ts +2 -4
- package/src/commands/plumbing-shared.ts +197 -0
- package/src/commands/repack-command.ts +44 -11
- package/src/commands/replace-command.ts +16 -4
- package/src/commands/repo-command.ts +124 -25
- package/src/commands/rerere-command.ts +17 -0
- package/src/commands/rerere.ts +144 -3
- package/src/commands/reset-command.ts +75 -3
- package/src/commands/rev-parse-command.ts +14 -28
- package/src/commands/revision-resolver.ts +85 -34
- package/src/commands/signing.ts +54 -7
- package/src/commands/status-command.ts +31 -2
- package/src/commands/submodule-add-command.ts +18 -1
- package/src/commands/submodule-update-command.ts +18 -1
- package/src/commands/tag-command.ts +33 -11
- package/src/commands/update-index-command.ts +137 -5
- package/src/git-command.ts +60 -19
- package/src/remote-config/remote-config-store.ts +11 -3
- package/src/transport-command.ts +4 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { E as fsckTree, I as __exportAll, T as fsckTag, _ as UnknownFsckMsgIdError, d as FsckCommand, g as FsckMessageTypes, h as FSCK_MSG_IDS, m as receiveFsckOf, n as VerifyPackCommand, p as fetchFsckOf, v as parseFsckMsgId, w as fsckCommit, x as checkSubmoduleName } from "./fsck-
|
|
1
|
+
import { E as fsckTree, I as __exportAll, T as fsckTag, _ as UnknownFsckMsgIdError, d as FsckCommand, g as FsckMessageTypes, h as FSCK_MSG_IDS, m as receiveFsckOf, n as VerifyPackCommand, p as fetchFsckOf, v as parseFsckMsgId, w as fsckCommit, x as checkSubmoduleName } from "./fsck-BjlxStsM.js";
|
|
2
2
|
import { BranchUsedByWorktreeError, CannotDeleteCurrentBranchError, CheckoutIndexFailedError, CloneCheckoutError, CloneDestinationError, CommitNotFoundError, DescribeError, EmptyCommitError, GitApiError, HookFailedError, IncompatibleOptionsError, IndexLockFailedError, InvalidArgumentError, InvalidConfigError, InvalidMainlineParentError, InvalidMergeHeadsError, InvalidPathError, InvalidRefNameError, InvalidRemoteError, InvalidStashIndexError, InvalidTagNameError, MissingArgumentError, MktagFailedError, MultipleParentsNotAllowedError, MvFailedError, NoFilepatternError, NoHeadError, NoMergeBaseError, NoMessageError, NoRebaseInProgressError, NonFastForwardError, NotACommitError, NotFastForwardError, NotMergedError, PushRejectedException, RebaseTodoMissingError, RefAlreadyExistsError, RefFilterError, RefNotFoundError, RemoteAlreadyExistsError, RemoteNotFoundError, RevisionError, RmFailedError, StashApplyFailedError, StashNotFoundError, StoreNotAvailableError, SwitchRefusedError, TransportError as TransportError$1, UnmergedPathsError, UpdateIndexFailedError, WorktreeError } from "./errors/index.js";
|
|
3
|
-
import { $ as
|
|
4
|
-
import { $ as relativeFilesPath, $t as BisectRunCommand, A as fetchBundleUri, An as pathCheckoutResult, Bt as signatureStart, C as strictUrlOrigin, Ct as shortlogIdent, D as TransportCommand, E as PlumbingError, En as CheckoutCommand, Et as fillAheadBehind, Ft as RefFormat, G as defaultRemoteOf, I as BundleList, It as RefKind, J as lstatKind, Jt as BisectCommand, K as isRelativeSubmoduleUrl, M as BundleListHeadsCommand, Mn as runPathCheckout, N as BundleUnbundleCommand, Nt as sortRefs, Ot as filterAndFormatRefs, P as BundleVerifyCommand, Q as physicalFilesPath, Qt as BisectResetCommand, R as parseBundleListLine, S as guardSubmoduleTransports, St as readShortlogInput, T as PlumbingCommand, U as SubmoduleGitDirError, W as SubmoduleModel, X as parentIsDirectory, Xt as BisectNextCommand, Y as openConfigFile, Yt as BisectLogCommand, Z as parseSubmoduleUpdateStrategy, Zt as BisectReplayCommand, _ as SubmoduleFetchRepository, a as ReflogCommand, at as setInConfigFile, b as submoduleTouchesInRange, bt as parseShortlogGroup, c as GuardedTransportCommand, ct as upPathOf, dt as validateSubmodulePath, en as BisectSkipCommand, ft as worktreeHostPath, g as uriProtocolsOption, gt as commitSubject$1, h as toTrackingRefUpdate, ht as Shortlog, i as RepackCommand, it as safeCreateLeadingDirectories, jt as parseRefSorting, k as fetchBundleList, kn as nonCommitSwitchError, kt as filterRefs, l as FetchCommand, lt as urlIsLocalNotSsh, m as toTagMode, n as MaintenanceRunCommand, nn as BisectStateCommand, nt as resolveFilesLinks, o as inLinkedWorktree, ot as submodulePathConfigOf, pt as BundleCreateCommand, q as joinFilesPath, qt as RevListCommand, rn as BisectTermsCommand, rt as resolveRelativeUrl, s as objectsDirectoryDisplay, st as submoduleUpdateTypeName, tn as BisectStartCommand, tt as remoteFromUrl, ut as validateSubmoduleGitDir, v as findUnpushedSubmodules, vt as inputLines$2, w as clientSessionIdOf, wt as splitIdent, x as createSubmoduleAuthPolicy, xt as parseShortlogWrap, yt as outputEncoderFor } from "./maintenance-run-command-
|
|
5
|
-
import { C as WorktreePruneCommand, S as GarbageCollectCommand, _ as remoteHookSession, b as withReceiveTransactionHook, d as withRemoteUploadPack, f as createDuplexPair, g as receivePackSettingsOf, h as receiveFsckSettingsOf, l as withRemoteReceivePack, p as httpBackendEnv, u as withRemoteSession, v as servedMaxTreeDepth, w as BundlePrerequisitesError, x as ReadTreeCommand, y as servedUseBitmaps } from "./remote-transport-
|
|
3
|
+
import { $i as stripspace, $n as applyMailmapToHeader, $r as trailerLinesOf, $s as reflogMessages, Ac as checkDefaultObjectStorage, Ai as ApplyParser, Al as hookRunnerOf, Ao as rerereRemaining, Ar as combineNotesCatSortUniq, At as AUTOSTASH_SAVED_LINES, Bc as SparseUnpack, Br as amendWithTrailers, Bt as squashMessage, C as patchRevisionOf, Cr as expandNotesRef, Cu as localTimezoneOffset, D as PATCH_MODES, Di as ApplyCommand, Dl as gitFileOf, Dn as readDiffSubmoduleConfig, Do as rerereForget, Dr as readRef, Dt as relativeDate, Du as RemoteConfigStore, Ei as readBlob, El as gitCommitMessageHooks, Eo as rerereEngineOf, Er as initNotes, Eu as moveRefs, Fc as unknownObjectStorageFormat, Fi as latin1ToText, Ft as removeBranchState, G as SubmoduleSummaryCommand, Ga as signPayload, Gc as readSparseCheckoutPatterns, Gi as cleanupWith, Gl as createIdAbbreviator, H as readShowUntrackedFiles, Hc as entryList, Ho as GIT_MAX_SCORE, Ii as pathToLatin1, Il as runPostCheckoutHook, Ir as mailFromHeader, It as removeMergeBranchState, J as StatusPrinter, Jc as sparsePathAdvice, Ji as commitMessageFromOption, Jl as WS_DEFAULT_RULE, Jn as verifyCommitBytes, Jo as strerror, K as readHeadDescription, Ka as signRequestOf, Kc as sparseCheckoutConfig, Ki as commentPrefixOf, Kl as worktreeModeTrust, Ko as readGitlinkHead, Kt as WorkingCopyStashProvider, L as TextconvCaches, Li as textToLatin1, Ll as sequencerPostCommit, Lo as lowLevelMerge, Lr as mailSubjectLine, Lt as resetMerge, M as DiffCommand, Mc as defaultInitialBranch, Mi as cUnquote, Mn as parseGitmodules, Mo as runRerere, Mt as cleanupMessage, Nc as defaultRefFormat, Ni as latin1ToBytes, Nl as isKnownHook, Nr as combineNotesOverwrite, Nt as createAutostash, O as patchModeFor, Oo as rerereGcLocation, Or as updateNotesRef, Os as quoteCStyleBody, Ot as sanitizedSubject, Ou as listRemoteNames, Pc as isValidBranchName$1, Pi as latin1ToPath, Po as MergeDriverFailedError, Pr as readNoteBytes, Pt as moveHeadAsReset, Qi as preparedMessageCleanup, Ql as wsCheckEmit, Qn as GrepPatternError, Qr as trailerConfigOf, Qs as reflogLine, R as StatusCommand, Ra as GitCommand, Ri as newFilePatch, Rl as sequencerPrepareMessage, Rt as resetUnmergedToHead, Sc as removeLegacyRemoteFile, Si as GRAPH_COLUMN_COLORS_ANSI, Sl as commonGitFileOf, So as RerereError, Sr as expandLooseNotesRef, St as loadRefDecorations, Su as formatRfc2822Date, T as runPatchSelection, Ti as ortResultEntries, Tl as gitCommitAfterHooks, To as rerereDiff, Tr as initCopyNotesForRewrite, Tt as parseColorSpec, Tu as deleteRefs, Ui as isMergeSuccessful, Ul as abbrevLengths, Un as readStoredObjectBytes, Uo as isBinaryContent, Ut as StashCreateCommand, Va as SigningFailedError, Vc as cleanTrackedSparseDirectories, Vo as detectRenames, Vr as appendSignoff, Wa as signCommit, Wc as readSparseCheckoutFile, Wl as coreBool, Wo as IndexAdder, Wr as ignoredLogMessageBytes, Xc as updateSparsity, Xi as editorCleanupMode, Xl as isGitSpace, Xn as verifyTagBytes, Xr as signoffLine, Y as formatStatusText, Yc as sparseWarningText, Yi as completeLine$1, Yl as checkBlankAtEof, Yn as verifyMergeSignature, Yr as processTrailers, Za as signingKeyIdOf, Zi as parseCleanupMode, Zl as wsBlankLine, _a as updateIndexCacheTree, _c as readAllBytes, _i as DEFAULT_DATE_MODE, _l as withTreePathRefusal, _n as shortBranchName, _o as verifyFilename, _r as copyNoteForRewrite, aa as indexChanges, ai as matchPathspecSeen, al as statFollowingLinks, an as STASH_REF, ao as guessRemoteBranch, ar as storedBase, au as configValue, b as collapsedSparseDirectories, bc as readMailmapFile, bi as parseDateMode, bn as worktreeAdminWorkingCopy, br as createNotesCommit, bs as formatStat, bu as withoutCrud, ci as pathspecCommonPrefix, co as pushTrackingPlan, cr as forkPointOf, ct as readDiffColorSettings, da as rewriteIndex, dc as promisorRemoteReplyOf, di as pathspecItemMayMatch, dl as planFlatRestore, dn as checkCandidatePath, do as upstreamMissingError, dr as patchIdOfChanges, dt as ConfigValueDeath, du as InvalidIdentError, ea as FlatTreeCache, ei as validateTrailerArgs, eo as ambiguousRemoteAdvice, et as RevParseCommand, fa as storeFlatTree, fi as pathspecName, fn as findLinkedWorktree, fo as worktreeAmbiguityHints, fr as patchIdsOfPatchText, ft as formatConfigValue, fu as authorIdentOf, ga as treeDelta, gc as objectTypeOfMode, gi as untrackedScanPathspec, gl as treePathRefusal, gn as requireWorktrees, go as parseRevisionAndPathArgs, gr as commitNotes, gt as parseGitColor, ha as switchTrees, hc as concatBytes, hi as treePathspec, hn as repositoryPlaceOf, hr as NotesError, ht as normalizeConfigValue, hu as hostEnvironmentOf, i as isRebaseSuccessful, ia as flatTree, ii as matchPathspec, il as removeDirectoryIfEmpty, in as StashApplyCommand, io as endOfSymbolicChain, ir as mergeStoredTrees, iu as configBool$1, ji as bytesToLatin1, jo as rerereStatus, jr as combineNotesConcatenate, jt as applyAutostash, kc as UnsupportedObjectStorageError, ki as ApplyEngine, kl as hookHostOf, ks as quotePath, la as readIndex, li as pathspecErrors, ll as worktreeModified, ln as WorktreeListCommand, lo as trackableStart, lr as PathspecAttributes, ma as subjectOf, mc as SHORT_MAGIC$1, mi as treeEntryInteresting, ml as writeTreeRestorePlan, mn as refuseIfCheckedOut, mr as isFullHexObjectId, mt as gitConfigColorBool, na as conflictsComment, nc as updateHeadExpecting, ni as latin1Bytes$3, nl as pruneEmptyParents, nr as remergeObjectsView, nu as attributesSourceResolver, oa as indexChangesFromTree, oi as parsePathspec, ol as statThroughLeadingLinks, on as StashListCommand, oo as installTracking, or as MergeBaseGraph, ou as conflictStyleOf, pa as storeFlatTreeOver, pc as CorruptTreeError, pi as psEqual, pr as canonicalObjectId, pt as gitConfigBool, pu as committerIdentOf, qa as signTagCompat, qc as sparseDirectoriesOf, qi as commitCleanupMode, qt as ResetCommand, ri as latin1String, rn as PathspecFile, ro as disableHint, rr as mergeBaseTree, rt as textconvRunnerOf, ru as bareAttributesResolver, sc as promisorOf, si as parsePathspecItem, sn as LogCommand, so as planTracking, sr as commitsBaseSource, su as mergeVerbosityOf, ta as OperationState, tc as updateHead, ti as globalPathspecMagic, to as applyRefspecs$1, tt as revisionMergeBases, ua as refsWatched, ui as pathspecItemBytes, ul as checkoutFreshTree, uo as uniqueTrackingName, ur as PatchIds, ut as CONFIG_VALUE_TYPES, uu as InvalidDateError, v as AddCommand, va as writeIndexAsTree, vl as worktreePathRules, vn as useRelativePaths, vo as verifyNonFilename, vr as copyNotesForAmend, w as pathPatchMode, wc as InvalidInitialBranchError, wo as rerereClear, wr as finishCopyNotesForRewrite, wu as parseGitDate, x as sparseIndexAsRead, xc as readRepositoryMailmap, xi as showDate, xn as worktreeUsingBranch, xo as unknownRevisionMessage, xr as defaultNotesRef, xu as approxidateCareful$1, y as SPARSE_INDEX_EXPANDED_HINT, yc as readMailmapBlob, yn as usesBranch, yo as handleRevisionArg, yr as copyNotesForRebase, yt as formatCommitPretty, z as cutLine, za as SIGNING_FAILED_LINES, zl as fsmonitorModeOf, zo as ortConfigOptions, zr as reencodedCommitParts, zt as saveAutostash } from "./results-Dg1KHG8y.js";
|
|
4
|
+
import { $ as relativeFilesPath, $t as BisectRunCommand, A as fetchBundleUri, An as pathCheckoutResult, Bt as signatureStart, C as strictUrlOrigin, Ct as shortlogIdent, D as TransportCommand, E as PlumbingError, En as CheckoutCommand, Et as fillAheadBehind, Ft as RefFormat, G as defaultRemoteOf, I as BundleList, It as RefKind, J as lstatKind, Jt as BisectCommand, K as isRelativeSubmoduleUrl, M as BundleListHeadsCommand, Mn as runPathCheckout, N as BundleUnbundleCommand, Nt as sortRefs, Ot as filterAndFormatRefs, P as BundleVerifyCommand, Q as physicalFilesPath, Qt as BisectResetCommand, R as parseBundleListLine, S as guardSubmoduleTransports, St as readShortlogInput, T as PlumbingCommand, U as SubmoduleGitDirError, W as SubmoduleModel, X as parentIsDirectory, Xt as BisectNextCommand, Y as openConfigFile, Yt as BisectLogCommand, Z as parseSubmoduleUpdateStrategy, Zt as BisectReplayCommand, _ as SubmoduleFetchRepository, a as ReflogCommand, at as setInConfigFile, b as submoduleTouchesInRange, bt as parseShortlogGroup, c as GuardedTransportCommand, ct as upPathOf, dt as validateSubmodulePath, en as BisectSkipCommand, ft as worktreeHostPath, g as uriProtocolsOption, gt as commitSubject$1, h as toTrackingRefUpdate, ht as Shortlog, i as RepackCommand, it as safeCreateLeadingDirectories, jt as parseRefSorting, k as fetchBundleList, kn as nonCommitSwitchError, kt as filterRefs, l as FetchCommand, lt as urlIsLocalNotSsh, m as toTagMode, n as MaintenanceRunCommand, nn as BisectStateCommand, nt as resolveFilesLinks, o as inLinkedWorktree, ot as submodulePathConfigOf, pt as BundleCreateCommand, q as joinFilesPath, qt as RevListCommand, rn as BisectTermsCommand, rt as resolveRelativeUrl, s as objectsDirectoryDisplay, st as submoduleUpdateTypeName, tn as BisectStartCommand, tt as remoteFromUrl, ut as validateSubmoduleGitDir, v as findUnpushedSubmodules, vt as inputLines$2, w as clientSessionIdOf, wt as splitIdent, x as createSubmoduleAuthPolicy, xt as parseShortlogWrap, yt as outputEncoderFor } from "./maintenance-run-command-G_eWdA8O.js";
|
|
5
|
+
import { C as WorktreePruneCommand, S as GarbageCollectCommand, _ as remoteHookSession, b as withReceiveTransactionHook, d as withRemoteUploadPack, f as createDuplexPair, g as receivePackSettingsOf, h as receiveFsckSettingsOf, l as withRemoteReceivePack, p as httpBackendEnv, u as withRemoteSession, v as servedMaxTreeDepth, w as BundlePrerequisitesError, x as ReadTreeCommand, y as servedUseBitmaps } from "./remote-transport-CSgTJ1BH.js";
|
|
6
6
|
import { CorruptObjectError, DEFAULT_BIG_FILE_THRESHOLD, EMPTY_BLOB_ID, EMPTY_TREE_ID, FileMode, InvalidTreeEntryNameError, MemoryRawStorage, ObjectType, RefStorage, bloomFilterContains, bloomKey, collapseRefNameSlashes, collectTagBytes, compareRefNames, countAheadBehind, createGitObjects, createInMemoryFilesApi, createMemoryHistory, decodeTreeBytes, formatPersonIdent, historyWithoutLazyFetch, importPack, isSymbolicRef, isValidBranchName, isValidRefName, isValidTagName, isValidWorktreePath, joinPath, listObjectsWithPrefix, objectFormatOf, overlayMethods, overlayObjects, packNameOf, parseCoreAbbrev, parseGraftFile, parseObjectFilter, parsePersonIdent, rawStorageStaging, readFile, replacementOf, serializeCommit, serializeTag, unpackObjects } from "@statewalker/vcs-core";
|
|
7
7
|
import { compareGitPaths, decodeGitPath, decodeGitPatternFile, encodeGitPath, foldAsciiCase, parseGitBool, parseGitInt, unquoteGitPath } from "@statewalker/vcs-utils/encoding";
|
|
8
|
-
import { AttributesMemo, AttributesSourceError, DIR_COLLECT_KILLED_ONLY, DIR_HIDE_EMPTY_DIRECTORIES, DIR_SHOW_IGNORED, DIR_SHOW_OTHER_DIRECTORIES, FilterDriverError, IndexPathLookup, WorktreeFormatUpgradeError, attributesIndexOf, attributesIndexOfTree, basicStatMatches, cacheTreeOfTree, collectChunks, commandLineExcluded, compareWithWorktree, convAttrsOf, createCommandLineExcludes, createIgnoreNode, createMemoryCheckout, crlfToWorktree, entryStatOf, eolStatsAscii, expandUserPath, getWorktreeEntries, identToWorktree, invalidateCacheTreePath, isIndexUnborn, isValidAttributeName, modeFromWorktree, readConversionSettings, reencode, scanUntracked, smudgeContent, sparseFilterMatcher, sparsePatternsFromCone, sparsePatternsFromLines, splitPatternLines, storeWorktreeFile, unreadableDirectoryWarning, walkUntrackedScanHost, wholeSeconds, wildmatch, withWorktreeEntries, xdgConfigPath } from "@statewalker/vcs-working-tree";
|
|
9
|
-
import { ByteLines, LineInterner, PosixRegexError, SHA1_OBJECT_FORMAT, URL_COMPONENTS, XDF_IGNORE_CR_AT_EOL, XDF_IGNORE_WHITESPACE, XDF_IGNORE_WHITESPACE_AT_EOL, XDF_IGNORE_WHITESPACE_CHANGE, approxidateCareful, compilePosixRegex, decodeGitPath as decodeGitPath$1, encodeGitPath as encodeGitPath$1, formatHunkHeader, funcnameFindFunction, gitStrWidth as gitStrWidth$1, isUrlNormalizeError, mergeLines, normalizeUrl, nullObjectIdLike, objectFormatByName, parseGitBool as parseGitBool$1, parseGitInt as parseGitInt$1, selectUrlMatches, unifiedDiff, unifiedDiffHunks, urlComponent, urlParse, whitespaceFlags, xdiffHunks, xdlHashRecord } from "@statewalker/vcs-utils";
|
|
8
|
+
import { AttributesMemo, AttributesSourceError, DIR_COLLECT_KILLED_ONLY, DIR_HIDE_EMPTY_DIRECTORIES, DIR_SHOW_IGNORED, DIR_SHOW_OTHER_DIRECTORIES, FilterDriverError, FilterDriverRunError, FsmonitorState, IndexPathLookup, WorktreeFormatUpgradeError, attributesIndexOf, attributesIndexOfTree, basicStatMatches, cacheTreeOfTree, collectChunks, commandLineExcluded, compareWithWorktree, convAttrsOf, createCommandLineExcludes, createIgnoreNode, createMemoryCheckout, crlfToWorktree, entryStatOf, eolStatsAscii, expandUserPath, getWorktreeEntries, identToWorktree, invalidateCacheTreePath, isCleanByStat, isIndexUnborn, isValidAttributeName, modeFromWorktree, readConversionSettings, readIndexFileEntries, reencode, scanUntracked, smudgeContent, sparseFilterMatcher, sparsePatternsFromCone, sparsePatternsFromLines, splitPatternLines, storeWorktreeFile, unreadableDirectoryWarning, walkUntrackedScanHost, wholeSeconds, wildmatch, withWorktreeEntries, xdgConfigPath } from "@statewalker/vcs-working-tree";
|
|
9
|
+
import { ByteLines, LineInterner, PosixRegexError, SHA1_OBJECT_FORMAT, URL_COMPONENTS, XDF_IGNORE_CR_AT_EOL, XDF_IGNORE_WHITESPACE, XDF_IGNORE_WHITESPACE_AT_EOL, XDF_IGNORE_WHITESPACE_CHANGE, approxidateCareful, compilePosixRegex, decodeGitPath as decodeGitPath$1, encodeGitPath as encodeGitPath$1, formatHunkHeader, funcnameFindFunction, gitStrWidth as gitStrWidth$1, isUrlNormalizeError, mergeLines, normalizeUrl, nullObjectIdLike, objectFormatByName, parseGitBool as parseGitBool$1, parseGitInt as parseGitInt$1, parseGitUlong, selectUrlMatches, unifiedDiff, unifiedDiffHunks, urlComponent, urlParse, whitespaceFlags, xdiffHunks, xdlHashRecord } from "@statewalker/vcs-utils";
|
|
10
10
|
import { FileMode as FileMode$1, PERM_GROUP, adjustSharedPerm, dirname, joinPath as joinPath$1, normalizePath, parseSharedRepository as parseSharedRepository$1, readFile as readFile$1, sharedRepositoryConfigValue, sharedRepositoryOf, tryReadFile, withSharedPerm } from "@statewalker/vcs-utils/files";
|
|
11
11
|
import { SHA1_OBJECT_FORMAT as SHA1_OBJECT_FORMAT$1, SHA256_OBJECT_FORMAT as SHA256_OBJECT_FORMAT$1, isNullObjectId as isNullObjectId$1 } from "@statewalker/vcs-utils/hash";
|
|
12
|
-
import { CONFIG_REGEX_NONE, ConfigParseError, FileStagingStore, GitWorkingCopyConfig, HostPaths, MissingRootError, RefMigrationError, ReflogExpiryConfigError, computeAlternatePath, configFilesApiOf, createFileWorktree, createGitFilesHistoryFromFiles, createWorkingCopyConfig, hostPathOf, hostRootOf, isAbsoluteGitPath, isGitDirectory, migrateRefStorage, openGitLinkedWorktrees, parseConfigKey, parseExpiryDate, parseGitfile, prepareConfigComment, probeCaseFolding, prune, readConfigFileThroughLinks, readProtectedConfig, readReftableWriteOptions, readRepositoryFormat, refStoreRetirement, renameConfigSectionInFile, rerereGc, resolveLinkedGitDir, retireRefStore, setConfigMultivarInFile, setConfigMultivarText, verifyRefStorage } from "@statewalker/vcs-store-files";
|
|
13
|
-
import { FetchCheckError, ObjectFormatMismatchError, ObjectInfoError, PushCertificateError, PushRefspecError, PushRefusedByHookError, ReceivedObjects, ShallowRemoteRejectedError, anonymizeUrl, bundleUriLines, checkUnpackedObjects, countRefspecMatch, createDefaultTransports, createRepositoryFacade, createTransportRefStore, expandFromDestination, expandFromSource, fetchFromConnection, fetchObjectInfo, formatPushStatus, gitDaemonRequest, lsRefs, mapRefs, mapRejectReason, matchDestination, matchPushRefs, matchSource, missingSources, objectSource, packObjectsHookArgs, parseConfigInt, parseRefSpec, pushToConnection, refPrefixes, repositoryQuarantine, requestRemoteArchive, serveUploadArchive, servedGitFilesOf } from "@statewalker/vcs-transport";
|
|
12
|
+
import { CONFIG_REGEX_NONE, ConfigParseError, FileStagingStore, GitWorkingCopyConfig, HostPaths, MissingRootError, RefMigrationError, ReflogExpiryConfigError, computeAlternatePath, configFilesApiOf, createFileWorktree, createGitFilesHistoryFromFiles, createWorkingCopyConfig, hostPathOf, hostRootOf, isAbsoluteGitPath, isGitDirectory, migrateRefStorage, objectStorageFormatByUri, openGitLinkedWorktrees, parseConfigKey, parseExpiryDate, parseGitfile, prepareConfigComment, probeCaseFolding, prune, readConfigFileThroughLinks, readProtectedConfig, readReftableWriteOptions, readRepositoryFormat, refStoreRetirement, renameConfigSectionInFile, rerereGc, resolveLinkedGitDir, retireRefStore, setConfigMultivarInFile, setConfigMultivarText, setupGitDirectory, verifyRefStorage } from "@statewalker/vcs-store-files";
|
|
13
|
+
import { FetchCheckError, ObjectFormatMismatchError, ObjectInfoError, PushCertificateError, PushRefspecError, PushRefusedByHookError, ReceivedObjects, ShallowRemoteRejectedError, anonymizeUrl, bundleUriLines, checkUnpackedObjects, countRefspecMatch, createByteQueue, createDefaultTransports, createRepositoryFacade, createTransportRefStore, expandFromDestination, expandFromSource, fetchFromConnection, fetchObjectInfo, formatPushStatus, gitDaemonRequest, lsRefs, mapRefs, mapRejectReason, matchDestination, matchPushRefs, matchSource, missingSources, objectSource, packObjectsHookArgs, parseConfigInt, parseRefSpec, pushToConnection, refPrefixes, repositoryQuarantine, requestRemoteArchive, serveUploadArchive, servedGitFilesOf } from "@statewalker/vcs-transport";
|
|
14
14
|
import { MemoryStagingStore } from "@statewalker/vcs-store-mem";
|
|
15
|
-
import { deflateSync } from "@statewalker/vcs-utils/compression";
|
|
16
|
-
import { crc32 } from "@statewalker/vcs-utils/hash/crc32";
|
|
15
|
+
import { createDeflater, deflateSync } from "@statewalker/vcs-utils/compression";
|
|
16
|
+
import { CRC32, crc32 } from "@statewalker/vcs-utils/hash/crc32";
|
|
17
17
|
import { unifiedDiff as unifiedDiff$1, userdiffFindFunction as userdiffFindFunction$1 } from "@statewalker/vcs-utils/diff";
|
|
18
18
|
import { collect } from "@statewalker/vcs-utils/streams";
|
|
19
19
|
import { computeObjectId } from "@statewalker/vcs-utils/pack";
|
|
@@ -2436,13 +2436,26 @@ var AmCommand = class extends GitCommand {
|
|
|
2436
2436
|
let header = "";
|
|
2437
2437
|
if (sign !== void 0) {
|
|
2438
2438
|
const payload = encodeGitPath(head + body);
|
|
2439
|
-
const
|
|
2439
|
+
const signBytes = async (bytes) => latin1ToPath(bytesToLatin1(await this.signOrDie((cwd) => signPayload(this.workingCopy, sign, bytes, {
|
|
2440
2440
|
committer,
|
|
2441
2441
|
tail: [],
|
|
2442
2442
|
...cwd !== void 0 ? { cwd } : {}
|
|
2443
2443
|
}))));
|
|
2444
|
-
const
|
|
2445
|
-
|
|
2444
|
+
const headerOf = (name, signature) => `${name} ${(signature.endsWith("\n") ? signature.slice(0, -1) : signature).split("\n").join("\n ")}\n`;
|
|
2445
|
+
const signatures = [{
|
|
2446
|
+
name: this.objectFormat.signatureHeader,
|
|
2447
|
+
value: await signBytes(payload)
|
|
2448
|
+
}];
|
|
2449
|
+
const compat = objects.compat;
|
|
2450
|
+
if (compat) {
|
|
2451
|
+
const compatPayload = await compat.convertToCompat("commit", payload);
|
|
2452
|
+
signatures.push({
|
|
2453
|
+
name: compat.compat.signatureHeader,
|
|
2454
|
+
value: await signBytes(compatPayload)
|
|
2455
|
+
});
|
|
2456
|
+
signatures.sort((a, b) => a.name === "gpgsig" ? -1 : b.name === "gpgsig" ? 1 : 0);
|
|
2457
|
+
}
|
|
2458
|
+
header = signatures.map((s) => headerOf(s.name, s.value)).join("");
|
|
2446
2459
|
}
|
|
2447
2460
|
id = await objects.putUnsized("commit", [encodeGitPath(head + header + body)]);
|
|
2448
2461
|
} else {
|
|
@@ -3034,6 +3047,55 @@ function createDescriber(source) {
|
|
|
3034
3047
|
}
|
|
3035
3048
|
//#endregion
|
|
3036
3049
|
//#region src/commands/archive/archive-entry.ts
|
|
3050
|
+
/** The size of the chunks a writer sends to its output. */
|
|
3051
|
+
const OUTPUT_CHUNK = 65536;
|
|
3052
|
+
/**
|
|
3053
|
+
* The bytes a writer has written: kept whole, or sent to an {@link ArchiveOutput} in chunks
|
|
3054
|
+
* of about {@link OUTPUT_CHUNK}.
|
|
3055
|
+
*/
|
|
3056
|
+
var ArchiveSink = class {
|
|
3057
|
+
output;
|
|
3058
|
+
buffer;
|
|
3059
|
+
/** The bytes sent to the output so far */
|
|
3060
|
+
sent = 0;
|
|
3061
|
+
constructor(output, capacity = 16384) {
|
|
3062
|
+
this.output = output;
|
|
3063
|
+
this.buffer = new ByteBuffer(output ? OUTPUT_CHUNK * 2 : capacity);
|
|
3064
|
+
}
|
|
3065
|
+
/** The archive's length so far (sent and held). */
|
|
3066
|
+
get position() {
|
|
3067
|
+
return this.sent + this.buffer.length;
|
|
3068
|
+
}
|
|
3069
|
+
/** Sends what is held once it reaches a chunk (`force`: whatever is held). */
|
|
3070
|
+
async flush(force = false) {
|
|
3071
|
+
if (!this.output || this.buffer.length === 0) return;
|
|
3072
|
+
if (!force && this.buffer.length < 65536) return;
|
|
3073
|
+
const chunk = this.buffer.bytes().slice();
|
|
3074
|
+
this.sent += chunk.length;
|
|
3075
|
+
this.buffer.clear();
|
|
3076
|
+
await this.output(chunk);
|
|
3077
|
+
}
|
|
3078
|
+
/** Writes a large piece (a streamed blob's chunk), sent as it is when there is an output. */
|
|
3079
|
+
async write(bytes) {
|
|
3080
|
+
if (!this.output) {
|
|
3081
|
+
this.buffer.push(bytes);
|
|
3082
|
+
return;
|
|
3083
|
+
}
|
|
3084
|
+
if (this.buffer.length + bytes.length < 65536) {
|
|
3085
|
+
this.buffer.push(bytes);
|
|
3086
|
+
return;
|
|
3087
|
+
}
|
|
3088
|
+
await this.flush(true);
|
|
3089
|
+
this.sent += bytes.length;
|
|
3090
|
+
await this.output(bytes.slice());
|
|
3091
|
+
}
|
|
3092
|
+
/** The bytes held whole (no output), or empty once everything was sent. */
|
|
3093
|
+
async finish() {
|
|
3094
|
+
if (!this.output) return this.buffer.bytes();
|
|
3095
|
+
await this.flush(true);
|
|
3096
|
+
return /* @__PURE__ */ new Uint8Array(0);
|
|
3097
|
+
}
|
|
3098
|
+
};
|
|
3037
3099
|
/** A growing byte buffer. */
|
|
3038
3100
|
var ByteBuffer = class {
|
|
3039
3101
|
buf;
|
|
@@ -3059,6 +3121,10 @@ var ByteBuffer = class {
|
|
|
3059
3121
|
this.buf.fill(0, this.length, this.length + n);
|
|
3060
3122
|
this.length += n;
|
|
3061
3123
|
}
|
|
3124
|
+
/** Forgets the bytes written (the capacity kept). */
|
|
3125
|
+
clear() {
|
|
3126
|
+
this.length = 0;
|
|
3127
|
+
}
|
|
3062
3128
|
/** The bytes written (a view: copy before writing more). */
|
|
3063
3129
|
bytes() {
|
|
3064
3130
|
return this.buf.subarray(0, this.length);
|
|
@@ -3138,11 +3204,14 @@ function pathPrefix(path, maxlen) {
|
|
|
3138
3204
|
/** Writes git's tar archive (`git archive --format=tar`). */
|
|
3139
3205
|
var TarArchiveWriter = class {
|
|
3140
3206
|
settings;
|
|
3141
|
-
|
|
3207
|
+
sink;
|
|
3208
|
+
out;
|
|
3142
3209
|
umask;
|
|
3143
3210
|
time;
|
|
3144
3211
|
constructor(settings) {
|
|
3145
3212
|
this.settings = settings;
|
|
3213
|
+
this.sink = new ArchiveSink(settings.output, BLOCKSIZE);
|
|
3214
|
+
this.out = this.sink.buffer;
|
|
3146
3215
|
this.umask = settings.umask ?? 2;
|
|
3147
3216
|
this.time = settings.time;
|
|
3148
3217
|
this.writeGlobalExtendedHeader();
|
|
@@ -3153,6 +3222,23 @@ var TarArchiveWriter = class {
|
|
|
3153
3222
|
const tail = data.length % RECORDSIZE$1;
|
|
3154
3223
|
if (tail) this.out.zeros(RECORDSIZE$1 - tail);
|
|
3155
3224
|
}
|
|
3225
|
+
/** `stream_blocked`: a streamed blob's bytes, padded to a whole record; false when short. */
|
|
3226
|
+
async streamBlocked(stream, size) {
|
|
3227
|
+
let total = 0;
|
|
3228
|
+
try {
|
|
3229
|
+
for await (const chunk of stream) {
|
|
3230
|
+
if (total + chunk.length > size) return false;
|
|
3231
|
+
total += chunk.length;
|
|
3232
|
+
await this.sink.write(chunk);
|
|
3233
|
+
}
|
|
3234
|
+
} catch {
|
|
3235
|
+
return false;
|
|
3236
|
+
}
|
|
3237
|
+
if (total !== size) return false;
|
|
3238
|
+
const tail = size % RECORDSIZE$1;
|
|
3239
|
+
if (tail) this.out.zeros(RECORDSIZE$1 - tail);
|
|
3240
|
+
return true;
|
|
3241
|
+
}
|
|
3156
3242
|
/** `prepare_header`: the numeric fields, owner, magic and checksum. */
|
|
3157
3243
|
prepareHeader(header, mode, size) {
|
|
3158
3244
|
octal$1(header, MODE, 8, mode & 4095);
|
|
@@ -3194,8 +3280,10 @@ var TarArchiveWriter = class {
|
|
|
3194
3280
|
this.writeBlocked(ext);
|
|
3195
3281
|
}
|
|
3196
3282
|
/** `write_tar_entry`. */
|
|
3197
|
-
entry(entry) {
|
|
3283
|
+
async entry(entry) {
|
|
3198
3284
|
const { path, id, content } = entry;
|
|
3285
|
+
const stream = isRegMode(entry.mode) ? entry.stream : void 0;
|
|
3286
|
+
const size = stream ? entry.size ?? 0 : content.length;
|
|
3199
3287
|
let mode = entry.mode;
|
|
3200
3288
|
const header = new Uint8Array(RECORDSIZE$1);
|
|
3201
3289
|
const ext = new ByteBuffer(256);
|
|
@@ -3226,23 +3314,30 @@ var TarArchiveWriter = class {
|
|
|
3226
3314
|
extRecord(ext, "linkpath", content);
|
|
3227
3315
|
} else header.set(content, LINKNAME);
|
|
3228
3316
|
}
|
|
3229
|
-
let sizeInHeader =
|
|
3230
|
-
if (isRegMode(mode) &&
|
|
3317
|
+
let sizeInHeader = size;
|
|
3318
|
+
if (isRegMode(mode) && size > USTAR_MAX) {
|
|
3231
3319
|
sizeInHeader = 0;
|
|
3232
|
-
extRecord(ext, "size", asciiBytes(String(
|
|
3320
|
+
extRecord(ext, "size", asciiBytes(String(size)));
|
|
3233
3321
|
}
|
|
3234
3322
|
this.prepareHeader(header, mode, sizeInHeader);
|
|
3235
3323
|
if (ext.length > 0) this.writeExtendedHeader(id, ext.bytes());
|
|
3236
3324
|
this.writeBlocked(header);
|
|
3237
|
-
if (
|
|
3325
|
+
if (stream) {
|
|
3326
|
+
if (!await this.streamBlocked(stream, size)) return `cannot stream blob ${id}`;
|
|
3327
|
+
} else if (isRegMode(mode) && content.length > 0) {
|
|
3328
|
+
await this.sink.write(content);
|
|
3329
|
+
const tail = content.length % RECORDSIZE$1;
|
|
3330
|
+
if (tail) this.out.zeros(RECORDSIZE$1 - tail);
|
|
3331
|
+
}
|
|
3332
|
+
await this.sink.flush();
|
|
3238
3333
|
}
|
|
3239
3334
|
/** `write_trailer`: the last block filled, another one when fewer than two records remain. */
|
|
3240
|
-
finish() {
|
|
3241
|
-
const offset = this.
|
|
3335
|
+
async finish() {
|
|
3336
|
+
const offset = this.sink.position % BLOCKSIZE;
|
|
3242
3337
|
const tail = BLOCKSIZE - offset;
|
|
3243
3338
|
this.out.zeros(tail);
|
|
3244
3339
|
if (tail < 2 * RECORDSIZE$1) this.out.zeros(BLOCKSIZE);
|
|
3245
|
-
return this.
|
|
3340
|
+
return this.sink.finish();
|
|
3246
3341
|
}
|
|
3247
3342
|
};
|
|
3248
3343
|
//#endregion
|
|
@@ -4090,7 +4185,7 @@ function relativePath$2(path, prefix) {
|
|
|
4090
4185
|
while (k < a.length - 1 && k < b.length && a[k] === b[k]) k++;
|
|
4091
4186
|
return [...b.slice(k).map(() => ".."), ...a.slice(k)].join("/");
|
|
4092
4187
|
}
|
|
4093
|
-
const SHORT_MAGIC
|
|
4188
|
+
const SHORT_MAGIC = /* @__PURE__ */ new Set([..."!\"#%&',-;<=>@_`~^/"]);
|
|
4094
4189
|
/** The pathspec argument read against the prefix (`:(top)` and `:/` from the top). */
|
|
4095
4190
|
function prefixedArg(arg, prefix) {
|
|
4096
4191
|
if (!prefix) return arg;
|
|
@@ -4102,7 +4197,7 @@ function prefixedArg(arg, prefix) {
|
|
|
4102
4197
|
}
|
|
4103
4198
|
if (arg.startsWith(":")) {
|
|
4104
4199
|
let i = 1;
|
|
4105
|
-
while (i < arg.length && arg[i] !== ":" && SHORT_MAGIC
|
|
4200
|
+
while (i < arg.length && arg[i] !== ":" && SHORT_MAGIC.has(arg[i])) i++;
|
|
4106
4201
|
const magic = arg.slice(1, i);
|
|
4107
4202
|
if (arg[i] === ":") i++;
|
|
4108
4203
|
if (magic.includes("/")) return arg;
|
|
@@ -4118,7 +4213,7 @@ function afterMagic(arg) {
|
|
|
4118
4213
|
}
|
|
4119
4214
|
if (arg.startsWith(":")) {
|
|
4120
4215
|
let i = 1;
|
|
4121
|
-
while (i < arg.length && arg[i] !== ":" && SHORT_MAGIC
|
|
4216
|
+
while (i < arg.length && arg[i] !== ":" && SHORT_MAGIC.has(arg[i])) i++;
|
|
4122
4217
|
if (arg[i] === ":") i++;
|
|
4123
4218
|
return arg.slice(i);
|
|
4124
4219
|
}
|
|
@@ -4907,6 +5002,8 @@ const METHOD_DEFLATE = 8;
|
|
|
4907
5002
|
const EXTRA_MTIME_SIZE = 9;
|
|
4908
5003
|
const ZIP64_EXTRA_SIZE = 20;
|
|
4909
5004
|
const MAX32 = 4294967295;
|
|
5005
|
+
/** archive-zip.c's `STREAM_BUFFER_SIZE`: a streamed blob's reads. */
|
|
5006
|
+
const STREAM_BUFFER_SIZE = 16384;
|
|
4910
5007
|
/** Little-endian fields appended to a buffer. */
|
|
4911
5008
|
var LeWriter = class {
|
|
4912
5009
|
out;
|
|
@@ -4957,9 +5054,10 @@ function dosTime(time, localTzOffset = (t) => -(/* @__PURE__ */ new Date(t * 1e3
|
|
|
4957
5054
|
/** Writes git's zip archive (`git archive --format=zip`). */
|
|
4958
5055
|
var ZipArchiveWriter = class {
|
|
4959
5056
|
settings;
|
|
4960
|
-
|
|
5057
|
+
sink;
|
|
5058
|
+
out;
|
|
4961
5059
|
dir = new ByteBuffer(4096);
|
|
4962
|
-
le
|
|
5060
|
+
le;
|
|
4963
5061
|
dirLe = new LeWriter(this.dir);
|
|
4964
5062
|
entries = 0;
|
|
4965
5063
|
maxCreatorVersion = 0;
|
|
@@ -4967,14 +5065,17 @@ var ZipArchiveWriter = class {
|
|
|
4967
5065
|
dosTimeOfDay;
|
|
4968
5066
|
constructor(settings) {
|
|
4969
5067
|
this.settings = settings;
|
|
5068
|
+
this.sink = new ArchiveSink(settings.output, 65536);
|
|
5069
|
+
this.out = this.sink.buffer;
|
|
5070
|
+
this.le = new LeWriter(this.out);
|
|
4970
5071
|
const dos = dosTime(settings.time, settings.localTzOffset);
|
|
4971
5072
|
this.dosDate = dos.date;
|
|
4972
5073
|
this.dosTimeOfDay = dos.time;
|
|
4973
5074
|
}
|
|
4974
5075
|
/** `write_zip_entry`. */
|
|
4975
|
-
entry(entry) {
|
|
5076
|
+
async entry(entry) {
|
|
4976
5077
|
const { path, mode, id } = entry;
|
|
4977
|
-
const offset = this.
|
|
5078
|
+
const offset = this.sink.position;
|
|
4978
5079
|
let flags = 0;
|
|
4979
5080
|
let crc = 0;
|
|
4980
5081
|
let isBinary;
|
|
@@ -4984,8 +5085,8 @@ var ZipArchiveWriter = class {
|
|
|
4984
5085
|
let attr2;
|
|
4985
5086
|
let out;
|
|
4986
5087
|
let compressedSize;
|
|
4987
|
-
const size = entry.content.length;
|
|
4988
5088
|
const streamed = entry.streamed === true && isRegMode(mode);
|
|
5089
|
+
const size = streamed && entry.stream ? entry.size ?? 0 : entry.content.length;
|
|
4989
5090
|
if (!onlyAscii(path)) {
|
|
4990
5091
|
if (isUtf8$1(path)) flags |= ZIP_UTF8;
|
|
4991
5092
|
else this.settings.onWarning?.(`warning: path is not valid UTF-8: ${latin1$6(path)}`);
|
|
@@ -5059,19 +5160,11 @@ var ZipArchiveWriter = class {
|
|
|
5059
5160
|
le.u64(compressedSize);
|
|
5060
5161
|
}
|
|
5061
5162
|
if (streamed) {
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
} else {
|
|
5068
|
-
const deflated = deflateSync([entry.content], {
|
|
5069
|
-
format: "raw",
|
|
5070
|
-
level
|
|
5071
|
-
});
|
|
5072
|
-
this.out.push(deflated);
|
|
5073
|
-
compressedSize = deflated.length;
|
|
5074
|
-
}
|
|
5163
|
+
const streamedOut = await this.writeStreamed(entry, size, method === METHOD_STORE, level);
|
|
5164
|
+
if (!streamedOut) return `cannot stream blob ${id}`;
|
|
5165
|
+
crc = streamedOut.crc;
|
|
5166
|
+
isBinary = streamedOut.isBinary;
|
|
5167
|
+
compressedSize = streamedOut.compressedSize;
|
|
5075
5168
|
le.u32(134695760);
|
|
5076
5169
|
le.u32(crc);
|
|
5077
5170
|
if (size >= MAX32 || compressedSize >= MAX32) {
|
|
@@ -5081,7 +5174,7 @@ var ZipArchiveWriter = class {
|
|
|
5081
5174
|
le.u32(compressedSize);
|
|
5082
5175
|
le.u32(size);
|
|
5083
5176
|
}
|
|
5084
|
-
} else if (compressedSize > 0 && out) this.
|
|
5177
|
+
} else if (compressedSize > 0 && out) await this.sink.write(out);
|
|
5085
5178
|
let zip64DirPayload = 0;
|
|
5086
5179
|
let dirExtraSize = EXTRA_MTIME_SIZE;
|
|
5087
5180
|
if (compressedSize > MAX32 || size > MAX32 || offset > MAX32) {
|
|
@@ -5118,10 +5211,54 @@ var ZipArchiveWriter = class {
|
|
|
5118
5211
|
if (offset >= MAX32) d.u64(offset);
|
|
5119
5212
|
}
|
|
5120
5213
|
this.entries++;
|
|
5214
|
+
await this.sink.flush();
|
|
5215
|
+
}
|
|
5216
|
+
/**
|
|
5217
|
+
* A streamed blob's data (archive-zip.c's `stream` loops): the CRC-32 and the deflate
|
|
5218
|
+
* computed as it is read, `entry_is_binary` asked of its first read (16 KiB); undefined
|
|
5219
|
+
* when it cannot be read whole.
|
|
5220
|
+
*/
|
|
5221
|
+
async writeStreamed(entry, size, store, level) {
|
|
5222
|
+
const crc = new CRC32();
|
|
5223
|
+
const deflater = store ? void 0 : createDeflater({
|
|
5224
|
+
format: "raw",
|
|
5225
|
+
level
|
|
5226
|
+
});
|
|
5227
|
+
const head = new ByteBuffer(STREAM_BUFFER_SIZE);
|
|
5228
|
+
let total = 0;
|
|
5229
|
+
let compressedSize = 0;
|
|
5230
|
+
const emit = async (chunks) => {
|
|
5231
|
+
for (const c of chunks) {
|
|
5232
|
+
compressedSize += c.length;
|
|
5233
|
+
await this.sink.write(c);
|
|
5234
|
+
}
|
|
5235
|
+
};
|
|
5236
|
+
try {
|
|
5237
|
+
for await (const chunk of entry.stream ?? [entry.content]) {
|
|
5238
|
+
if (total + chunk.length > size) return void 0;
|
|
5239
|
+
total += chunk.length;
|
|
5240
|
+
crc.update(chunk);
|
|
5241
|
+
if (head.length < STREAM_BUFFER_SIZE) head.push(chunk.subarray(0, STREAM_BUFFER_SIZE - head.length));
|
|
5242
|
+
if (deflater) await emit(deflater.push(chunk));
|
|
5243
|
+
else {
|
|
5244
|
+
compressedSize += chunk.length;
|
|
5245
|
+
await this.sink.write(chunk);
|
|
5246
|
+
}
|
|
5247
|
+
}
|
|
5248
|
+
} catch {
|
|
5249
|
+
return;
|
|
5250
|
+
}
|
|
5251
|
+
if (total !== size) return void 0;
|
|
5252
|
+
if (deflater) await emit(deflater.finish());
|
|
5253
|
+
return {
|
|
5254
|
+
crc: crc.getValue(),
|
|
5255
|
+
isBinary: entry.binary ?? bufferIsBinary(head.bytes()),
|
|
5256
|
+
compressedSize
|
|
5257
|
+
};
|
|
5121
5258
|
}
|
|
5122
5259
|
/** `write_zip_trailer`. */
|
|
5123
|
-
finish() {
|
|
5124
|
-
const zipOffset = this.
|
|
5260
|
+
async finish() {
|
|
5261
|
+
const zipOffset = this.sink.position;
|
|
5125
5262
|
const dirBytes = this.dir.bytes();
|
|
5126
5263
|
const clamped = this.entries > 65535 || zipOffset > MAX32;
|
|
5127
5264
|
this.out.push(dirBytes);
|
|
@@ -5152,7 +5289,7 @@ var ZipArchiveWriter = class {
|
|
|
5152
5289
|
le.u32(clamp32(zipOffset));
|
|
5153
5290
|
le.u16(commitId ? this.settings.hexLength ?? commitId.length : 0);
|
|
5154
5291
|
if (commitId) this.out.push(asciiBytes(commitId));
|
|
5155
|
-
return this.
|
|
5292
|
+
return this.sink.finish();
|
|
5156
5293
|
}
|
|
5157
5294
|
};
|
|
5158
5295
|
/** Bytes as one character each (git prints paths as their bytes). */
|
|
@@ -5165,6 +5302,8 @@ function latin1$6(bytes) {
|
|
|
5165
5302
|
//#region src/commands/archive/archive-command.ts
|
|
5166
5303
|
/** git's builtin gzip filter (`tar.tgz.command`, `tar.tar.gz.command`). */
|
|
5167
5304
|
const INTERNAL_GZIP_COMMAND = "git archive gzip";
|
|
5305
|
+
/** How many bytes {@link ArchiveCommand.callStream} holds before the writer waits. */
|
|
5306
|
+
const STREAM_HIGH_WATER_MARK = 1 << 20;
|
|
5168
5307
|
const USAGE$11 = "usage: git archive [<options>] <tree-ish> [<path>...]\n or: git archive --list\n or: git archive --remote <repo> [--exec <cmd>] [<options>] <tree-ish> [<path>...]\n or: git archive --remote <repo> [--exec <cmd>] --list";
|
|
5169
5308
|
/** git's default `core.bigFileThreshold` (512 MiB). */
|
|
5170
5309
|
const DEFAULT_BIG_FILE_THRESHOLD$1 = 536870912;
|
|
@@ -5200,6 +5339,8 @@ var ArchiveCommand = class extends GitCommand {
|
|
|
5200
5339
|
worktreeAttributes = false;
|
|
5201
5340
|
currentDirectory = "";
|
|
5202
5341
|
filterRunner;
|
|
5342
|
+
streamFilterRunner;
|
|
5343
|
+
bigFileThreshold;
|
|
5203
5344
|
userUmask = 18;
|
|
5204
5345
|
localTzOffset;
|
|
5205
5346
|
filterDrivers;
|
|
@@ -5235,8 +5376,12 @@ var ArchiveCommand = class extends GitCommand {
|
|
|
5235
5376
|
return this;
|
|
5236
5377
|
}
|
|
5237
5378
|
/**
|
|
5238
|
-
* `--add-file=<file>`: a file
|
|
5239
|
-
*
|
|
5379
|
+
* `--add-file=<file>`: a file added under the current prefix and its base name, read as
|
|
5380
|
+
* git reads it: an absolute path as it stands, a relative one from the worktree's top (and
|
|
5381
|
+
* {@link setCurrentDirectory}), through the host environment (`GitHostEnvironment`'s
|
|
5382
|
+
* `realPath`/`hostFilesOf`: files outside the repository, symbolic links followed as
|
|
5383
|
+
* `stat` follows them), else from the worktree itself; git's `File not found` and `Not a
|
|
5384
|
+
* regular file` deaths. `content` gives its bytes instead.
|
|
5240
5385
|
*/
|
|
5241
5386
|
addFile(path, content, options = {}) {
|
|
5242
5387
|
this.checkCallable();
|
|
@@ -5324,6 +5469,16 @@ var ArchiveCommand = class extends GitCommand {
|
|
|
5324
5469
|
this.filterRunner = runner;
|
|
5325
5470
|
return this;
|
|
5326
5471
|
}
|
|
5472
|
+
/**
|
|
5473
|
+
* Runs the tar filters' commands as pipes, the archive streamed through them (git's
|
|
5474
|
+
* `write_tar_filter_archive`); preferred over {@link setFilterRunner}, which is handed the
|
|
5475
|
+
* whole tar archive.
|
|
5476
|
+
*/
|
|
5477
|
+
setStreamFilterRunner(runner) {
|
|
5478
|
+
this.checkCallable();
|
|
5479
|
+
this.streamFilterRunner = runner;
|
|
5480
|
+
return this;
|
|
5481
|
+
}
|
|
5327
5482
|
/** The umask `tar.umask=user` stands for (default 022). */
|
|
5328
5483
|
setUserUmask(umask) {
|
|
5329
5484
|
this.checkCallable();
|
|
@@ -5352,6 +5507,8 @@ var ArchiveCommand = class extends GitCommand {
|
|
|
5352
5507
|
}
|
|
5353
5508
|
/** `git archive --list`: the formats, as git lists them. */
|
|
5354
5509
|
listFormats() {
|
|
5510
|
+
this.checkTarConfig();
|
|
5511
|
+
if (this.compatibility === "2.43") this.archiveBigFileThreshold();
|
|
5355
5512
|
return this.archivers().map((a) => a.name);
|
|
5356
5513
|
}
|
|
5357
5514
|
/**
|
|
@@ -5413,28 +5570,111 @@ var ArchiveCommand = class extends GitCommand {
|
|
|
5413
5570
|
];
|
|
5414
5571
|
return this.uploadArchive ? all.filter((a) => a.remote) : all;
|
|
5415
5572
|
}
|
|
5416
|
-
/** The `tar.*` variables in configuration order. */
|
|
5573
|
+
/** The `tar.*` variables in configuration order, with where each was read. */
|
|
5417
5574
|
tarConfig() {
|
|
5418
5575
|
return RemoteConfigStore.from(this._workingCopy).entriesWithPrefix("tar.") ?? [];
|
|
5419
5576
|
}
|
|
5420
|
-
/**
|
|
5577
|
+
/**
|
|
5578
|
+
* `init_tar_archiver`'s `git_config(git_tar_config)`, which every `git archive` runs
|
|
5579
|
+
* first (`--list` and zip included): the first variable it refuses, in configuration
|
|
5580
|
+
* order, dies (a `tar.<format>.command` without a value, a `tar.umask` that is no number).
|
|
5581
|
+
*/
|
|
5582
|
+
checkTarConfig() {
|
|
5583
|
+
this.tarUmask();
|
|
5584
|
+
}
|
|
5585
|
+
/** `tar.umask`, the tar config's deaths checked on the way. */
|
|
5421
5586
|
tarUmask() {
|
|
5422
5587
|
let umask = 2;
|
|
5423
|
-
for (const { key, value } of this.tarConfig()) {
|
|
5588
|
+
for (const { key, value, file, line } of this.tarConfig()) {
|
|
5589
|
+
const last = key.lastIndexOf(".");
|
|
5590
|
+
if (last > 4 && key.slice(last + 1) === "command" && value === void 0) {
|
|
5591
|
+
const fatal = file !== void 0 && line !== void 0 ? `fatal: bad config variable '${key}' in file '${file}' at line ${line}` : `fatal: unable to parse '${key}' from command-line config`;
|
|
5592
|
+
throw new GitApiError(`error: missing value for '${key}'\n${fatal}`);
|
|
5593
|
+
}
|
|
5424
5594
|
if (key !== "tar.umask") continue;
|
|
5425
5595
|
if (value === "user") umask = this.userUmask;
|
|
5426
5596
|
else {
|
|
5427
|
-
const n = parseGitInt$1(value);
|
|
5428
|
-
if (n === void 0)
|
|
5597
|
+
const n = parseGitInt$1(value ?? "");
|
|
5598
|
+
if (n === void 0) {
|
|
5599
|
+
const where = file !== void 0 ? ` in file ${file}` : "";
|
|
5600
|
+
throw new GitApiError(`fatal: bad numeric config value '${value ?? ""}' for 'tar.umask'${where}: invalid unit`);
|
|
5601
|
+
}
|
|
5429
5602
|
umask = n;
|
|
5430
5603
|
}
|
|
5431
5604
|
}
|
|
5432
5605
|
return umask;
|
|
5433
5606
|
}
|
|
5607
|
+
/**
|
|
5608
|
+
* `core.bigFileThreshold` (git's `unsigned long`, default 512 MiB): git 2.43 reads it with
|
|
5609
|
+
* the core settings when it starts (every value in order, the first it refuses dying), 2.5x
|
|
5610
|
+
* at the first regular file it archives (the last value only).
|
|
5611
|
+
*
|
|
5612
|
+
* @internal
|
|
5613
|
+
*/
|
|
5614
|
+
archiveBigFileThreshold() {
|
|
5615
|
+
if (this.bigFileThreshold !== void 0) return this.bigFileThreshold;
|
|
5616
|
+
const key = "core.bigfilethreshold";
|
|
5617
|
+
const values = RemoteConfigStore.from(this._workingCopy).valuesWithOrigin(key);
|
|
5618
|
+
let threshold = DEFAULT_BIG_FILE_THRESHOLD$1;
|
|
5619
|
+
const checked = this.compatibility === "2.43" ? values : values.slice(-1);
|
|
5620
|
+
for (const { text, file } of checked) {
|
|
5621
|
+
const n = parseGitUlong(text);
|
|
5622
|
+
if (typeof n !== "number") {
|
|
5623
|
+
const where = file !== void 0 ? ` in file ${file}` : "";
|
|
5624
|
+
throw new GitApiError(`fatal: bad numeric config value '${text ?? ""}' for '${key}'${where}: ${n}`);
|
|
5625
|
+
}
|
|
5626
|
+
threshold = n;
|
|
5627
|
+
}
|
|
5628
|
+
this.bigFileThreshold = threshold;
|
|
5629
|
+
return threshold;
|
|
5630
|
+
}
|
|
5434
5631
|
/** The archive's bytes. */
|
|
5435
5632
|
async call() {
|
|
5436
5633
|
this.checkCallable();
|
|
5437
5634
|
this.setCallable(false);
|
|
5635
|
+
const chunks = [];
|
|
5636
|
+
await this.produce((chunk) => {
|
|
5637
|
+
chunks.push(chunk);
|
|
5638
|
+
});
|
|
5639
|
+
return join$1(chunks);
|
|
5640
|
+
}
|
|
5641
|
+
/**
|
|
5642
|
+
* The archive's bytes as they are written, in chunks of about 64 KiB, the same bytes
|
|
5643
|
+
* {@link call} returns: blobs above `core.bigFileThreshold` are streamed from the store
|
|
5644
|
+
* and never held whole, and a tar filter (the builtin gzip, or a command through
|
|
5645
|
+
* {@link setStreamFilterRunner}) filters as the archive is written. The writer waits while
|
|
5646
|
+
* a mebibyte is unread. Nothing runs until the iteration starts; where git dies the
|
|
5647
|
+
* iteration throws a {@link GitApiError} (after the bytes git would have written).
|
|
5648
|
+
*
|
|
5649
|
+
* @example
|
|
5650
|
+
* ```typescript
|
|
5651
|
+
* for await (const chunk of git.archive().setFormat("zip").setTree("HEAD").callStream()) {
|
|
5652
|
+
* await sink.write(chunk);
|
|
5653
|
+
* }
|
|
5654
|
+
* ```
|
|
5655
|
+
*/
|
|
5656
|
+
callStream() {
|
|
5657
|
+
this.checkCallable();
|
|
5658
|
+
this.setCallable(false);
|
|
5659
|
+
const queue = createByteQueue({
|
|
5660
|
+
highWaterMark: STREAM_HIGH_WATER_MARK,
|
|
5661
|
+
coalesce: 0
|
|
5662
|
+
});
|
|
5663
|
+
let started = false;
|
|
5664
|
+
const start = () => {
|
|
5665
|
+
if (started) return;
|
|
5666
|
+
started = true;
|
|
5667
|
+
this.produce((chunk) => queue.push(chunk)).then(() => queue.end(), (error) => queue.end(error instanceof Error ? error : new Error(String(error))));
|
|
5668
|
+
};
|
|
5669
|
+
return { [Symbol.asyncIterator]() {
|
|
5670
|
+
start();
|
|
5671
|
+
return queue.stream;
|
|
5672
|
+
} };
|
|
5673
|
+
}
|
|
5674
|
+
/** `write_archive`: the archive written to `output`. */
|
|
5675
|
+
async produce(output) {
|
|
5676
|
+
this.checkTarConfig();
|
|
5677
|
+
if (this.compatibility === "2.43") this.archiveBigFileThreshold();
|
|
5438
5678
|
const extras = await this.readExtraFiles();
|
|
5439
5679
|
let format = this.format;
|
|
5440
5680
|
if (format === void 0 && this.outputName !== void 0) format = this.formatFromFilename(this.outputName);
|
|
@@ -5449,11 +5689,13 @@ var ArchiveCommand = class extends GitCommand {
|
|
|
5449
5689
|
if (levelsOk && (this.compressionLevel <= 9 || highOk)) level = this.compressionLevel;
|
|
5450
5690
|
else throw new GitApiError(`fatal: Argument not supported for format '${format}': -${this.compressionLevel}`);
|
|
5451
5691
|
}
|
|
5452
|
-
|
|
5692
|
+
await this.inOneOperation(async () => {
|
|
5453
5693
|
const target = await this.resolveTreeish(this.tree);
|
|
5694
|
+
const filter = archiver.command === void 0 ? void 0 : this.openFilter(archiver.command, level, output);
|
|
5454
5695
|
const settings = {
|
|
5455
5696
|
time: target.time,
|
|
5456
5697
|
compressionLevel: level,
|
|
5698
|
+
output: filter?.input ?? output,
|
|
5457
5699
|
...target.commitId ? { commitId: target.commitId } : {}
|
|
5458
5700
|
};
|
|
5459
5701
|
const writer = archiver.name === "zip" ? new ZipArchiveWriter({
|
|
@@ -5470,60 +5712,168 @@ var ArchiveCommand = class extends GitCommand {
|
|
|
5470
5712
|
await run.prepare();
|
|
5471
5713
|
await run.writeEntries();
|
|
5472
5714
|
}, (refusal) => refusal instanceof InvalidPathError ? new GitApiError(refusal.message, { exitCode: 255 }) : refusal);
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
return this.filter(archiver.command, archive, level);
|
|
5715
|
+
await writer.finish();
|
|
5716
|
+
await filter?.finish();
|
|
5476
5717
|
});
|
|
5477
5718
|
}
|
|
5478
|
-
|
|
5719
|
+
/**
|
|
5720
|
+
* `write_tar_filter_archive`: the tar archive's bytes through the filter (the builtin
|
|
5721
|
+
* gzip, else the command, started before anything is written).
|
|
5722
|
+
*/
|
|
5723
|
+
openFilter(command, level, output) {
|
|
5479
5724
|
if (command === "git archive gzip") {
|
|
5480
5725
|
if (level > 9) throw new GitApiError("fatal: deflateInit2: stream consistency error (no message)");
|
|
5481
|
-
|
|
5726
|
+
const deflater = createDeflater({
|
|
5482
5727
|
format: "gzip",
|
|
5483
5728
|
level
|
|
5484
5729
|
});
|
|
5730
|
+
const send = async (chunks) => {
|
|
5731
|
+
for (const chunk of chunks) await output(chunk);
|
|
5732
|
+
};
|
|
5733
|
+
return {
|
|
5734
|
+
input: (chunk) => send(deflater.push(chunk)),
|
|
5735
|
+
finish: () => send(deflater.finish())
|
|
5736
|
+
};
|
|
5485
5737
|
}
|
|
5486
5738
|
const cmd = level >= 0 ? `${command} -${level}` : command;
|
|
5487
5739
|
if (!cmd) throw new GitApiError("fatal: unable to start '' filter: No such file or directory");
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5740
|
+
const failed = () => new GitApiError(`fatal: '${cmd}' filter reported error`);
|
|
5741
|
+
const streamRunner = this.streamFilterRunner;
|
|
5742
|
+
if (streamRunner) {
|
|
5743
|
+
const queue = createByteQueue({
|
|
5744
|
+
highWaterMark: STREAM_HIGH_WATER_MARK,
|
|
5745
|
+
coalesce: 0
|
|
5746
|
+
});
|
|
5747
|
+
let failure;
|
|
5748
|
+
const pump = (async () => {
|
|
5749
|
+
try {
|
|
5750
|
+
for await (const chunk of streamRunner(cmd, queue.stream)) await output(chunk);
|
|
5751
|
+
} catch {
|
|
5752
|
+
failure = failed();
|
|
5753
|
+
queue.end(failure);
|
|
5754
|
+
}
|
|
5755
|
+
})();
|
|
5756
|
+
return {
|
|
5757
|
+
input: async (chunk) => {
|
|
5758
|
+
if (failure) throw failure;
|
|
5759
|
+
try {
|
|
5760
|
+
await queue.push(chunk);
|
|
5761
|
+
} catch (error) {
|
|
5762
|
+
throw failure ?? error;
|
|
5763
|
+
}
|
|
5764
|
+
},
|
|
5765
|
+
finish: async () => {
|
|
5766
|
+
queue.end();
|
|
5767
|
+
await pump;
|
|
5768
|
+
if (failure) throw failure;
|
|
5769
|
+
}
|
|
5770
|
+
};
|
|
5493
5771
|
}
|
|
5772
|
+
const runner = this.filterRunner;
|
|
5773
|
+
if (!runner) throw new GitApiError(`fatal: unable to start '${cmd}' filter`);
|
|
5774
|
+
const chunks = [];
|
|
5775
|
+
return {
|
|
5776
|
+
input: (chunk) => {
|
|
5777
|
+
chunks.push(chunk);
|
|
5778
|
+
},
|
|
5779
|
+
finish: async () => {
|
|
5780
|
+
let filtered;
|
|
5781
|
+
try {
|
|
5782
|
+
filtered = await runner(cmd, join$1(chunks));
|
|
5783
|
+
} catch {
|
|
5784
|
+
throw failed();
|
|
5785
|
+
}
|
|
5786
|
+
await output(filtered);
|
|
5787
|
+
}
|
|
5788
|
+
};
|
|
5494
5789
|
}
|
|
5495
|
-
/**
|
|
5790
|
+
/**
|
|
5791
|
+
* `--add-file`'s files checked as git stats them while parsing its options (their content
|
|
5792
|
+
* is read when they are written).
|
|
5793
|
+
*/
|
|
5496
5794
|
async readExtraFiles() {
|
|
5497
5795
|
const out = [];
|
|
5498
5796
|
for (const extra of this.extraFiles) {
|
|
5499
|
-
const path = `${this.currentDirectory}${extra.path}`;
|
|
5797
|
+
const path = !extra.virtual && extra.path.startsWith("/") ? extra.path : `${this.currentDirectory}${extra.path}`;
|
|
5500
5798
|
if (extra.content) {
|
|
5799
|
+
const content = extra.content;
|
|
5501
5800
|
out.push({
|
|
5502
5801
|
path,
|
|
5503
5802
|
base: extra.base,
|
|
5504
|
-
|
|
5803
|
+
read: async () => content,
|
|
5505
5804
|
mode: extra.executable ? 33261 : 33188,
|
|
5506
5805
|
virtual: extra.virtual
|
|
5507
5806
|
});
|
|
5508
5807
|
continue;
|
|
5509
5808
|
}
|
|
5809
|
+
const host = await this.hostExtraFile(path);
|
|
5810
|
+
if (host === "missing") throw new GitApiError(`fatal: File not found: ${path}`);
|
|
5811
|
+
if (host === "not-regular") throw new GitApiError(`fatal: Not a regular file: ${path}`);
|
|
5812
|
+
if (host) {
|
|
5813
|
+
out.push({
|
|
5814
|
+
path,
|
|
5815
|
+
base: extra.base,
|
|
5816
|
+
read: host.read,
|
|
5817
|
+
mode: host.mode,
|
|
5818
|
+
virtual: false
|
|
5819
|
+
});
|
|
5820
|
+
continue;
|
|
5821
|
+
}
|
|
5510
5822
|
const worktree = this.worktreeAccess;
|
|
5511
5823
|
const resolved = normalizeWorktreePath(path);
|
|
5512
5824
|
const entry = resolved === void 0 ? void 0 : await worktree?.getEntry(resolved).catch(() => void 0);
|
|
5513
5825
|
if (!entry) throw new GitApiError(`fatal: File not found: ${path}`);
|
|
5514
5826
|
if (entry.isDirectory || (entry.mode & 61440) !== 32768) throw new GitApiError(`fatal: Not a regular file: ${path}`);
|
|
5515
|
-
const chunks = [];
|
|
5516
|
-
for await (const c of worktree.readContent(resolved)) chunks.push(c);
|
|
5517
5827
|
out.push({
|
|
5518
5828
|
path,
|
|
5519
5829
|
base: extra.base,
|
|
5520
|
-
|
|
5830
|
+
read: async () => {
|
|
5831
|
+
const chunks = [];
|
|
5832
|
+
for await (const c of worktree.readContent(resolved)) chunks.push(c);
|
|
5833
|
+
return join$1(chunks);
|
|
5834
|
+
},
|
|
5521
5835
|
mode: entry.mode & 64 ? 33261 : 33188,
|
|
5522
5836
|
virtual: false
|
|
5523
5837
|
});
|
|
5524
5838
|
}
|
|
5525
5839
|
return out;
|
|
5526
5840
|
}
|
|
5841
|
+
/**
|
|
5842
|
+
* `--add-file`'s `stat` through the host environment: the path from the worktree's top
|
|
5843
|
+
* (a bare repository's git directory), links followed (`realPath`), the file read through
|
|
5844
|
+
* `hostFilesOf`; undefined when the host gives no access to its files (the worktree is
|
|
5845
|
+
* read instead).
|
|
5846
|
+
*/
|
|
5847
|
+
async hostExtraFile(path) {
|
|
5848
|
+
const environment = hostEnvironmentOf(this._workingCopy);
|
|
5849
|
+
if (!environment?.hostFilesOf) return void 0;
|
|
5850
|
+
let top;
|
|
5851
|
+
if (!path.startsWith("/")) {
|
|
5852
|
+
top = this.archiveWorktree?.hostPath ?? this._workingCopy.config?.hostGitDir;
|
|
5853
|
+
if (top === void 0) return void 0;
|
|
5854
|
+
}
|
|
5855
|
+
const hostPath = top === void 0 ? path : `${top.replace(/\/+$/, "")}/${path}`;
|
|
5856
|
+
const real = environment.realPath ? await environment.realPath(hostPath).catch(() => void 0) : hostPath;
|
|
5857
|
+
if (real === void 0) return "missing";
|
|
5858
|
+
const location = await environment.hostFilesOf(real).catch(() => void 0);
|
|
5859
|
+
if (!location) return void 0;
|
|
5860
|
+
const stats = (environment.statFile ? await environment.statFile(real).catch(() => void 0) : void 0) ?? await location.files.stats(location.path).catch(() => void 0);
|
|
5861
|
+
if (!stats) return "missing";
|
|
5862
|
+
if (stats.kind !== "file") return "not-regular";
|
|
5863
|
+
const { files, path: inFiles } = location;
|
|
5864
|
+
return {
|
|
5865
|
+
mode: (stats.mode ?? 420) & 64 ? 33261 : 33188,
|
|
5866
|
+
read: async () => {
|
|
5867
|
+
const chunks = [];
|
|
5868
|
+
try {
|
|
5869
|
+
for await (const c of files.read(inFiles)) chunks.push(c);
|
|
5870
|
+
} catch {
|
|
5871
|
+
throw new GitApiError(`error: cannot read '${path}'`, { exitCode: 255 });
|
|
5872
|
+
}
|
|
5873
|
+
return join$1(chunks);
|
|
5874
|
+
}
|
|
5875
|
+
};
|
|
5876
|
+
}
|
|
5527
5877
|
/** `parse_treeish_arg`: the tree, the commit (if any) and the archive's time. */
|
|
5528
5878
|
async resolveTreeish(name) {
|
|
5529
5879
|
const resolver = this.revisionResolver();
|
|
@@ -5534,6 +5884,9 @@ var ArchiveCommand = class extends GitCommand {
|
|
|
5534
5884
|
}
|
|
5535
5885
|
const id = await resolver.resolve(name).catch(() => void 0);
|
|
5536
5886
|
if (id === void 0) throw new GitApiError(`fatal: not a valid object name: ${name}`);
|
|
5887
|
+
const colon = name.indexOf(":");
|
|
5888
|
+
const refName = this.uploadArchive && !this.uploadArchive.allowUnreachable && colon >= 0 ? name.slice(0, colon) : name;
|
|
5889
|
+
const ref = (await resolver.dwimRef(refName).catch(() => []))[0]?.ref;
|
|
5537
5890
|
const peeled = await resolver.peelTags(id);
|
|
5538
5891
|
let commitId;
|
|
5539
5892
|
let time;
|
|
@@ -5555,7 +5908,8 @@ var ArchiveCommand = class extends GitCommand {
|
|
|
5555
5908
|
return {
|
|
5556
5909
|
tree,
|
|
5557
5910
|
time,
|
|
5558
|
-
...commitId ? { commitId } : {}
|
|
5911
|
+
...commitId ? { commitId } : {},
|
|
5912
|
+
...ref ? { ref } : {}
|
|
5559
5913
|
};
|
|
5560
5914
|
}
|
|
5561
5915
|
/** @internal */
|
|
@@ -5577,6 +5931,18 @@ var ArchiveCommand = class extends GitCommand {
|
|
|
5577
5931
|
archiveEntries(id) {
|
|
5578
5932
|
return this.treeEntries(id);
|
|
5579
5933
|
}
|
|
5934
|
+
/** @internal The size of a blob (`oid_object_info`), undefined when it cannot be read. */
|
|
5935
|
+
archiveBlobSize(id) {
|
|
5936
|
+
return this.blobs.size(id).catch(() => void 0);
|
|
5937
|
+
}
|
|
5938
|
+
/** @internal A blob's bytes as the store reads them (`open_istream`). */
|
|
5939
|
+
async archiveBlobStream(id) {
|
|
5940
|
+
return await this.blobs.load(id).catch(() => void 0) ?? void 0;
|
|
5941
|
+
}
|
|
5942
|
+
/** @internal */
|
|
5943
|
+
archiveCompatibility() {
|
|
5944
|
+
return this.compatibility;
|
|
5945
|
+
}
|
|
5580
5946
|
/** @internal */
|
|
5581
5947
|
async archiveBlob(id) {
|
|
5582
5948
|
const content = await this.blobs.load(id).catch(() => void 0);
|
|
@@ -5610,14 +5976,19 @@ var ArchiveCommand = class extends GitCommand {
|
|
|
5610
5976
|
archiveConfig(key) {
|
|
5611
5977
|
return configValue(this._workingCopy, key);
|
|
5612
5978
|
}
|
|
5613
|
-
/**
|
|
5979
|
+
/**
|
|
5980
|
+
* @internal The attributes git reads without a worktree (bare, or `GIT_ATTR_INDEX`). git
|
|
5981
|
+
* 2.43 reads a bare repository's in-tree files from HEAD when no attribute source is set
|
|
5982
|
+
* (2.5x reads none): `--worktree-attributes` in a bare repository sees them there.
|
|
5983
|
+
*/
|
|
5614
5984
|
archiveBareAttributes(indexTree) {
|
|
5615
5985
|
return bareAttributesResolver({
|
|
5616
5986
|
workingCopy: this._workingCopy,
|
|
5617
5987
|
trees: this.trees,
|
|
5618
5988
|
blobs: this.blobs,
|
|
5619
5989
|
revisions: () => this.revisionResolver(),
|
|
5620
|
-
...indexTree ? { indexTree } : {}
|
|
5990
|
+
...indexTree ? { indexTree } : {},
|
|
5991
|
+
...this.compatibility === "2.43" && !("worktree" in this._workingCopy) ? { defaultSource: "HEAD" } : {}
|
|
5621
5992
|
});
|
|
5622
5993
|
}
|
|
5623
5994
|
/** @internal `%h` and friends, `%(describe)`, for `export-subst`. */
|
|
@@ -5655,6 +6026,7 @@ function matchExtension(filename, ext) {
|
|
|
5655
6026
|
}
|
|
5656
6027
|
function join$1(chunks) {
|
|
5657
6028
|
if (chunks.length === 1) return chunks[0];
|
|
6029
|
+
if (chunks.length === 0) return /* @__PURE__ */ new Uint8Array(0);
|
|
5658
6030
|
let size = 0;
|
|
5659
6031
|
for (const c of chunks) size += c.length;
|
|
5660
6032
|
const out = new Uint8Array(size);
|
|
@@ -5711,7 +6083,6 @@ var ArchiveRun = class {
|
|
|
5711
6083
|
attrCache = /* @__PURE__ */ new Map();
|
|
5712
6084
|
bareResolver;
|
|
5713
6085
|
filterContext;
|
|
5714
|
-
bigFileThreshold = DEFAULT_BIG_FILE_THRESHOLD$1;
|
|
5715
6086
|
describeBudget = 1;
|
|
5716
6087
|
conversionSettings;
|
|
5717
6088
|
base;
|
|
@@ -5730,8 +6101,6 @@ var ArchiveRun = class {
|
|
|
5730
6101
|
}
|
|
5731
6102
|
/** `parse_pathspec_arg` and the attribute sources. */
|
|
5732
6103
|
async prepare() {
|
|
5733
|
-
const threshold = parseGitInt$1(this.cmd.archiveConfig("core.bigFileThreshold"));
|
|
5734
|
-
if (threshold !== void 0 && threshold > 0) this.bigFileThreshold = threshold;
|
|
5735
6104
|
const worktree = this.worktree;
|
|
5736
6105
|
if (!this.settings.worktreeAttributes) {
|
|
5737
6106
|
if (worktree?.contentFilter) this.filterContext = {
|
|
@@ -5825,8 +6194,8 @@ var ArchiveRun = class {
|
|
|
5825
6194
|
report(path) {
|
|
5826
6195
|
if (this.settings.verbose) this.settings.messages.push(decodeGitPath(path));
|
|
5827
6196
|
}
|
|
5828
|
-
emit(entry) {
|
|
5829
|
-
const error = this.writer.entry(entry);
|
|
6197
|
+
async emit(entry) {
|
|
6198
|
+
const error = await this.writer.entry(entry);
|
|
5830
6199
|
if (error) throw new GitApiError(`error: ${error}`, { exitCode: 255 });
|
|
5831
6200
|
}
|
|
5832
6201
|
/** `write_archive_entries`. */
|
|
@@ -5837,7 +6206,7 @@ var ArchiveRun = class {
|
|
|
5837
6206
|
while (len > 1 && base[len - 2] === "/") len--;
|
|
5838
6207
|
const path = this.base.subarray(0, encodeGitPath(base.slice(0, len)).length);
|
|
5839
6208
|
this.report(path);
|
|
5840
|
-
this.emit({
|
|
6209
|
+
await this.emit({
|
|
5841
6210
|
path,
|
|
5842
6211
|
mode: 16895,
|
|
5843
6212
|
id: this.target.tree,
|
|
@@ -5856,7 +6225,7 @@ var ArchiveRun = class {
|
|
|
5856
6225
|
path,
|
|
5857
6226
|
mode: extra.mode,
|
|
5858
6227
|
id,
|
|
5859
|
-
content:
|
|
6228
|
+
content: /* @__PURE__ */ new Uint8Array(0)
|
|
5860
6229
|
};
|
|
5861
6230
|
binaries.push(this.binaryOf(decodeGitPath(path.subarray(this.base.length))));
|
|
5862
6231
|
entries.push(entry);
|
|
@@ -5865,7 +6234,8 @@ var ArchiveRun = class {
|
|
|
5865
6234
|
const entry = entries[i];
|
|
5866
6235
|
const binary = await binaries[i];
|
|
5867
6236
|
if (binary !== void 0) entry.binary = binary;
|
|
5868
|
-
this.
|
|
6237
|
+
entry.content = await this.extras[i].read();
|
|
6238
|
+
await this.emit(entry);
|
|
5869
6239
|
}
|
|
5870
6240
|
}
|
|
5871
6241
|
/** `read_tree` with `queue_or_write_archive_entry`. */
|
|
@@ -5913,7 +6283,7 @@ var ArchiveRun = class {
|
|
|
5913
6283
|
const convertPath = rel;
|
|
5914
6284
|
this.report(archivePath);
|
|
5915
6285
|
if (isDir) {
|
|
5916
|
-
this.emit({
|
|
6286
|
+
await this.emit({
|
|
5917
6287
|
path: archivePath,
|
|
5918
6288
|
mode,
|
|
5919
6289
|
id,
|
|
@@ -5921,25 +6291,53 @@ var ArchiveRun = class {
|
|
|
5921
6291
|
});
|
|
5922
6292
|
return;
|
|
5923
6293
|
}
|
|
5924
|
-
let
|
|
5925
|
-
if (
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
6294
|
+
let size;
|
|
6295
|
+
if (isRegMode(mode) && !convert) {
|
|
6296
|
+
const threshold = this.cmd.archiveBigFileThreshold();
|
|
6297
|
+
size = await this.cmd.archiveBlobSize(id);
|
|
6298
|
+
if (size !== void 0 && size <= threshold) size = void 0;
|
|
6299
|
+
}
|
|
6300
|
+
let entry;
|
|
6301
|
+
if (size !== void 0) {
|
|
6302
|
+
const stream = await this.cmd.archiveBlobStream(id);
|
|
6303
|
+
if (!stream) throw new GitApiError(`error: cannot stream blob ${id}`, { exitCode: 255 });
|
|
6304
|
+
entry = {
|
|
6305
|
+
path: archivePath,
|
|
6306
|
+
mode,
|
|
6307
|
+
id,
|
|
6308
|
+
content: /* @__PURE__ */ new Uint8Array(0),
|
|
6309
|
+
streamed: true,
|
|
6310
|
+
stream,
|
|
6311
|
+
size
|
|
6312
|
+
};
|
|
6313
|
+
} else {
|
|
6314
|
+
let content = await this.cmd.archiveBlob(id);
|
|
6315
|
+
if (!content) throw new GitApiError(`error: cannot read '${id}'`, { exitCode: 255 });
|
|
6316
|
+
if (isRegMode(mode)) {
|
|
6317
|
+
content = await this.smudge(convertPath, id, content, mode);
|
|
6318
|
+
if (convert && this.target.commitId) content = await this.substitute(content);
|
|
6319
|
+
}
|
|
6320
|
+
entry = {
|
|
6321
|
+
path: archivePath,
|
|
6322
|
+
mode,
|
|
6323
|
+
id,
|
|
6324
|
+
content
|
|
6325
|
+
};
|
|
5930
6326
|
}
|
|
5931
|
-
const entry = {
|
|
5932
|
-
path: archivePath,
|
|
5933
|
-
mode,
|
|
5934
|
-
id,
|
|
5935
|
-
content
|
|
5936
|
-
};
|
|
5937
|
-
if (streamed) entry.streamed = true;
|
|
5938
6327
|
if (this.writer instanceof ZipArchiveWriter && (isRegMode(mode) || isLinkMode(mode))) {
|
|
5939
6328
|
const binary = await this.binaryOf(convertPath);
|
|
5940
6329
|
if (binary !== void 0) entry.binary = binary;
|
|
5941
6330
|
}
|
|
5942
|
-
this.emit(entry);
|
|
6331
|
+
await this.emit(entry);
|
|
6332
|
+
}
|
|
6333
|
+
/** archive.c's `init_checkout_metadata`: the ref, the commit (else the tree), the blob. */
|
|
6334
|
+
metadata(blob) {
|
|
6335
|
+
const treeish = this.target.commitId ?? this.target.tree;
|
|
6336
|
+
return {
|
|
6337
|
+
...this.target.ref ? { ref: this.target.ref } : {},
|
|
6338
|
+
treeish,
|
|
6339
|
+
blob
|
|
6340
|
+
};
|
|
5943
6341
|
}
|
|
5944
6342
|
/** zip's `entry_is_binary`: the diff driver's `binary`, undefined to look at the content. */
|
|
5945
6343
|
async binaryOf(path) {
|
|
@@ -5966,24 +6364,36 @@ var ArchiveRun = class {
|
|
|
5966
6364
|
else this.settings.messages.push(`error: failed to encode '${path}' from UTF-8 to ${ca.workingTreeEncoding}`);
|
|
5967
6365
|
}
|
|
5968
6366
|
const smudge = ca.driver?.host?.smudge;
|
|
6367
|
+
const command = ca.driver?.smudge;
|
|
5969
6368
|
let filtered;
|
|
5970
|
-
if (smudge
|
|
6369
|
+
if (smudge && command !== "") try {
|
|
6370
|
+
filtered = await smudge.call(ca.driver?.host, out, {
|
|
6371
|
+
path,
|
|
6372
|
+
...command !== void 0 ? { command } : {},
|
|
6373
|
+
metadata: this.metadata(id)
|
|
6374
|
+
});
|
|
6375
|
+
} catch (error) {
|
|
6376
|
+
if (command !== void 0 && !ca.driver?.required) {
|
|
6377
|
+
const own = error instanceof FilterDriverRunError ? error.lines : [];
|
|
6378
|
+
for (const line of [...own, `external filter '${command}' failed`]) this.settings.messages.push(`error: ${line}`);
|
|
6379
|
+
}
|
|
6380
|
+
}
|
|
5971
6381
|
if (filtered === void 0 && ca.driver?.required) throw new GitApiError(`fatal: ${path}: smudge filter ${ca.driver.name} failed`);
|
|
5972
6382
|
return filtered ?? out;
|
|
5973
6383
|
}
|
|
5974
6384
|
const filter = this.worktree?.contentFilter;
|
|
5975
|
-
if (!filter) return content;
|
|
5976
|
-
let out;
|
|
6385
|
+
if (!filter || !isRegMode(mode)) return content;
|
|
5977
6386
|
try {
|
|
5978
|
-
|
|
6387
|
+
const conversion = await filter.checkout(path, this.filterContext);
|
|
6388
|
+
if (!conversion) return content;
|
|
6389
|
+
return await conversion.apply(content, {
|
|
6390
|
+
onWarning: (message) => this.settings.messages.push(message),
|
|
6391
|
+
metadata: this.metadata(id)
|
|
6392
|
+
});
|
|
5979
6393
|
} catch (error) {
|
|
5980
6394
|
if (error instanceof FilterDriverError || isEncodingAttributeError(error)) throw new GitApiError(`fatal: ${error.message}`);
|
|
5981
6395
|
throw error;
|
|
5982
6396
|
}
|
|
5983
|
-
if (out instanceof Uint8Array) return out;
|
|
5984
|
-
const chunks = [];
|
|
5985
|
-
for await (const c of out) chunks.push(c);
|
|
5986
|
-
return join$1(chunks);
|
|
5987
6397
|
}
|
|
5988
6398
|
/** `format_subst`: each `$Format:<fmt>$` expanded for the commit. */
|
|
5989
6399
|
async substitute(content) {
|
|
@@ -11098,19 +11508,6 @@ var RemoteObjectInfoCommand = class extends TransportCommand {
|
|
|
11098
11508
|
};
|
|
11099
11509
|
//#endregion
|
|
11100
11510
|
//#region src/commands/cat-file/cat-file-command.ts
|
|
11101
|
-
/**
|
|
11102
|
-
* `git cat-file` (builtin/cat-file.c): an object's type, size, existence or content, one
|
|
11103
|
-
* object named on the command line (`-t`, `-s`, `-e`, `-p`, `<type> <object>`) or many read
|
|
11104
|
-
* from stdin (`--batch`, `--batch-check`, `--batch-command`, `--batch-all-objects`).
|
|
11105
|
-
*
|
|
11106
|
-
* @example
|
|
11107
|
-
* ```typescript
|
|
11108
|
-
* // git cat-file -p HEAD:README.md
|
|
11109
|
-
* await git.catFile().setMode("pretty").setObject("HEAD:README.md").setStdout(write).call();
|
|
11110
|
-
* // printf 'HEAD\nHEAD:a.txt\n' | git cat-file --batch-check
|
|
11111
|
-
* const { stdout } = await git.catFile().setBatch("info").setStdin("HEAD\nHEAD:a.txt\n").callOutput();
|
|
11112
|
-
* ```
|
|
11113
|
-
*/
|
|
11114
11511
|
const OBJECT_TYPES = /* @__PURE__ */ new Set([
|
|
11115
11512
|
"blob",
|
|
11116
11513
|
"tree",
|
|
@@ -11118,7 +11515,7 @@ const OBJECT_TYPES = /* @__PURE__ */ new Set([
|
|
|
11118
11515
|
"tag"
|
|
11119
11516
|
]);
|
|
11120
11517
|
const S_IFMT$8 = 61440;
|
|
11121
|
-
const S_IFGITLINK$
|
|
11518
|
+
const S_IFGITLINK$5 = 57344;
|
|
11122
11519
|
const encoder$6 = new TextEncoder();
|
|
11123
11520
|
const MAILMAP_HEADERS = [
|
|
11124
11521
|
"author ",
|
|
@@ -11314,7 +11711,7 @@ var CatFileCommand = class extends PlumbingCommand {
|
|
|
11314
11711
|
for await (const c of object.content) chunks.push(c.slice());
|
|
11315
11712
|
return {
|
|
11316
11713
|
type: object.type,
|
|
11317
|
-
bytes:
|
|
11714
|
+
bytes: concatBytes(chunks)
|
|
11318
11715
|
};
|
|
11319
11716
|
}
|
|
11320
11717
|
/** `stream_blob`: the blob's content written chunk by chunk. */
|
|
@@ -11332,17 +11729,20 @@ var CatFileCommand = class extends PlumbingCommand {
|
|
|
11332
11729
|
}
|
|
11333
11730
|
/** cat_one_file */
|
|
11334
11731
|
async catOne(name) {
|
|
11335
|
-
const compat = this.compatObjects;
|
|
11336
|
-
if (compat && name.length === compat.compat.hexLength && /^[0-9a-f]+$/.test(name)) return this.catOneCompat(name, compat);
|
|
11337
11732
|
const resolver = this.revisionResolver();
|
|
11338
11733
|
let id;
|
|
11339
11734
|
try {
|
|
11340
|
-
id = await resolver.resolve(name, {
|
|
11735
|
+
id = await resolver.resolve(name, {
|
|
11736
|
+
onlyToDie: true,
|
|
11737
|
+
hashAny: true
|
|
11738
|
+
});
|
|
11341
11739
|
} finally {
|
|
11342
11740
|
for (const line of resolver.warnings) this.warn(line);
|
|
11343
11741
|
resolver.warnings.length = 0;
|
|
11344
11742
|
}
|
|
11345
11743
|
if (id === void 0) throw new PlumbingError(`fatal: Not a valid object name ${name}`);
|
|
11744
|
+
const compat = this.compatIdOf(id);
|
|
11745
|
+
if (compat) return this.catOneCompat(id, compat);
|
|
11346
11746
|
const couldNotGetInfo = () => new PlumbingError("fatal: git cat-file: could not get object info");
|
|
11347
11747
|
switch (this.mode) {
|
|
11348
11748
|
case "type": {
|
|
@@ -11368,6 +11768,11 @@ var CatFileCommand = class extends PlumbingCommand {
|
|
|
11368
11768
|
default: return this.catTyped(name, id, this.type);
|
|
11369
11769
|
}
|
|
11370
11770
|
}
|
|
11771
|
+
/** The compatibility objects when `id` is an id of the compatibility format (not storage's) */
|
|
11772
|
+
compatIdOf(id) {
|
|
11773
|
+
const compat = this.compatObjects;
|
|
11774
|
+
return compat && id.length !== this.objectFormat.hexLength ? compat : void 0;
|
|
11775
|
+
}
|
|
11371
11776
|
/**
|
|
11372
11777
|
* cat_one_file for an id of the compatibility format: the object read through the map and
|
|
11373
11778
|
* converted (`odb_read_object_info_extended` with an id of the other format).
|
|
@@ -11389,19 +11794,7 @@ var CatFileCommand = class extends PlumbingCommand {
|
|
|
11389
11794
|
return 0;
|
|
11390
11795
|
case "pretty":
|
|
11391
11796
|
if (object.type === "tree") {
|
|
11392
|
-
|
|
11393
|
-
const quoteFully = parseGitBool$1(config.value("core.quotePath")) ?? true;
|
|
11394
|
-
let out = "";
|
|
11395
|
-
for (const entry of decodeTreeBytes(object.content, {
|
|
11396
|
-
idLength: compat.compat.rawLength,
|
|
11397
|
-
checkNames: false
|
|
11398
|
-
})) {
|
|
11399
|
-
const kind = entry.mode & S_IFMT$8;
|
|
11400
|
-
const type = kind === 16384 ? "tree" : kind === S_IFGITLINK$4 ? "commit" : "blob";
|
|
11401
|
-
const mode = entry.mode.toString(8).padStart(6, "0");
|
|
11402
|
-
out += `${mode} ${type} ${entry.id}\t${quotePath(entry.name, quoteFully)}\n`;
|
|
11403
|
-
}
|
|
11404
|
-
await this.write(out);
|
|
11797
|
+
await this.listTree(name);
|
|
11405
11798
|
return 0;
|
|
11406
11799
|
}
|
|
11407
11800
|
await this.write(object.type === "blob" ? object.content : await this.mapIdents(object.content));
|
|
@@ -11447,17 +11840,18 @@ var CatFileCommand = class extends PlumbingCommand {
|
|
|
11447
11840
|
const entries = await this.listedTreeEntries(id);
|
|
11448
11841
|
if (!entries) throw new PlumbingError(`fatal: Cannot read object ${id}`);
|
|
11449
11842
|
let out = "";
|
|
11450
|
-
|
|
11451
|
-
const
|
|
11452
|
-
|
|
11453
|
-
|
|
11454
|
-
|
|
11455
|
-
|
|
11456
|
-
|
|
11457
|
-
|
|
11843
|
+
try {
|
|
11844
|
+
for (const entry of entries) {
|
|
11845
|
+
const mode = entry.mode.toString(8).padStart(6, "0");
|
|
11846
|
+
out += `${mode} ${objectTypeOfMode(entry.mode)} ${entry.id}\t${quotePath(entry.name, quoteFully)}\n`;
|
|
11847
|
+
if (out.length >= 65536) {
|
|
11848
|
+
await this.write(out);
|
|
11849
|
+
out = "";
|
|
11850
|
+
}
|
|
11458
11851
|
}
|
|
11852
|
+
} finally {
|
|
11853
|
+
await this.write(out);
|
|
11459
11854
|
}
|
|
11460
|
-
await this.write(out);
|
|
11461
11855
|
}
|
|
11462
11856
|
/** `<type> <object>` */
|
|
11463
11857
|
async catTyped(name, id, type) {
|
|
@@ -11651,7 +12045,7 @@ var CatFileCommand = class extends PlumbingCommand {
|
|
|
11651
12045
|
async batchOne(state, resolver, name, rest) {
|
|
11652
12046
|
let id;
|
|
11653
12047
|
try {
|
|
11654
|
-
id = await resolver.resolve(name);
|
|
12048
|
+
id = await resolver.resolve(name, { hashAny: true });
|
|
11655
12049
|
} finally {
|
|
11656
12050
|
for (const line of resolver.warnings) this.warn(line);
|
|
11657
12051
|
}
|
|
@@ -11667,13 +12061,37 @@ var CatFileCommand = class extends PlumbingCommand {
|
|
|
11667
12061
|
...rest !== void 0 ? { rest } : {}
|
|
11668
12062
|
});
|
|
11669
12063
|
}
|
|
12064
|
+
/**
|
|
12065
|
+
* batch_object_write for an id of the compatibility format (`GET_OID_HASH_ANY` in
|
|
12066
|
+
* batch_one_object): the object read through the map and converted, so its id, type, size
|
|
12067
|
+
* and content are the compatibility format's. Replace refs are storage ids: they do not
|
|
12068
|
+
* apply to it.
|
|
12069
|
+
*/
|
|
12070
|
+
async batchCompatWrite(state, name, data, compat) {
|
|
12071
|
+
const object = await compat.readAsCompat(data.id);
|
|
12072
|
+
if (!object) {
|
|
12073
|
+
await this.write(`${name ?? data.id} missing${state.delim}`);
|
|
12074
|
+
return;
|
|
12075
|
+
}
|
|
12076
|
+
let content = object.content;
|
|
12077
|
+
if (this.useMailmap && (object.type === "commit" || object.type === "tag")) content = await this.mapIdents(content);
|
|
12078
|
+
data.type = object.type;
|
|
12079
|
+
data.size = content.length;
|
|
12080
|
+
const header = state.plain ? `${data.id} ${data.type} ${data.size}${state.delim}` : `${expandBatchFormat(state.format, data)}${state.delim}`;
|
|
12081
|
+
await this.write(header);
|
|
12082
|
+
if (!state.contents) return;
|
|
12083
|
+
await this.write(content);
|
|
12084
|
+
await this.write(state.delim);
|
|
12085
|
+
}
|
|
11670
12086
|
/** batch_object_write */
|
|
11671
12087
|
async batchObjectWrite(state, name, data) {
|
|
12088
|
+
const compat = this.compatIdOf(data.id);
|
|
12089
|
+
if (compat) return this.batchCompatWrite(state, name, data, compat);
|
|
11672
12090
|
const target = state.replace ? await this.replaced(data.id) : data.id;
|
|
11673
12091
|
const info = await this.info(target);
|
|
11674
12092
|
if (!info) {
|
|
11675
12093
|
if (this.compatibility !== "2.43" && data.mode !== void 0) {
|
|
11676
|
-
if ((data.mode & S_IFMT$8) === S_IFGITLINK$
|
|
12094
|
+
if ((data.mode & S_IFMT$8) === S_IFGITLINK$5) {
|
|
11677
12095
|
await this.write(`${data.id} submodule${state.delim}`);
|
|
11678
12096
|
return;
|
|
11679
12097
|
}
|
|
@@ -11740,18 +12158,6 @@ function splitCmdline(line) {
|
|
|
11740
12158
|
function modeLetter(mode) {
|
|
11741
12159
|
return mode === "type" ? "t" : mode === "size" ? "s" : mode === "exists" ? "e" : "p";
|
|
11742
12160
|
}
|
|
11743
|
-
function concat$10(chunks) {
|
|
11744
|
-
if (chunks.length === 1) return chunks[0];
|
|
11745
|
-
let size = 0;
|
|
11746
|
-
for (const c of chunks) size += c.length;
|
|
11747
|
-
const out = new Uint8Array(size);
|
|
11748
|
-
let at = 0;
|
|
11749
|
-
for (const c of chunks) {
|
|
11750
|
-
out.set(c, at);
|
|
11751
|
-
at += c.length;
|
|
11752
|
-
}
|
|
11753
|
-
return out;
|
|
11754
|
-
}
|
|
11755
12161
|
/**
|
|
11756
12162
|
* `strbuf_getline` (`strbuf_getdelim_strip_crlf`) over the input as it arrives: each record
|
|
11757
12163
|
* without its delimiter, and for newline-terminated input without a CR before it (`-z`'s
|
|
@@ -11773,14 +12179,14 @@ async function* readLines(input, delimiter) {
|
|
|
11773
12179
|
const at = chunk.indexOf(delimiter, start);
|
|
11774
12180
|
if (at < 0) break;
|
|
11775
12181
|
const piece = chunk.subarray(start, at);
|
|
11776
|
-
const line = pending.length > 0 ?
|
|
12182
|
+
const line = pending.length > 0 ? concatBytes([...pending, piece]) : piece;
|
|
11777
12183
|
pending = [];
|
|
11778
12184
|
yield emit(line);
|
|
11779
12185
|
start = at + 1;
|
|
11780
12186
|
}
|
|
11781
12187
|
if (start < chunk.length) pending.push(chunk.slice(start));
|
|
11782
12188
|
}
|
|
11783
|
-
if (pending.length > 0) yield emit(
|
|
12189
|
+
if (pending.length > 0) yield emit(concatBytes(pending));
|
|
11784
12190
|
}
|
|
11785
12191
|
//#endregion
|
|
11786
12192
|
//#region src/commands/git-paths.ts
|
|
@@ -12000,7 +12406,7 @@ const USAGE$10 = "usage: git check-attr [--source <tree-ish>] [-a | --all | <att
|
|
|
12000
12406
|
const S_IFMT$7 = 61440;
|
|
12001
12407
|
const S_IFDIR$5 = 16384;
|
|
12002
12408
|
const S_IFLNK$2 = 40960;
|
|
12003
|
-
const S_IFGITLINK$
|
|
12409
|
+
const S_IFGITLINK$4 = 57344;
|
|
12004
12410
|
/**
|
|
12005
12411
|
* An attributes file's message as git prints it: its `warning()`s (negative patterns, an
|
|
12006
12412
|
* overly long line or large file) prefixed, the others (an invalid name, a macro where none
|
|
@@ -12206,10 +12612,10 @@ var CheckAttrCommand = class extends GitCommand {
|
|
|
12206
12612
|
const entry = await this.worktreeIfAny()?.getEntry(path).catch(() => void 0);
|
|
12207
12613
|
if (!entry) return { error: `unable to stat '${path}': No such file or directory` };
|
|
12208
12614
|
if (entry.isDirectory || (entry.mode & S_IFMT$7) === S_IFDIR$5) {
|
|
12209
|
-
if (indexEntry && (indexEntry.mode & S_IFMT$7) === S_IFGITLINK$
|
|
12210
|
-
return octal((entry.mode & S_IFMT$7) === S_IFGITLINK$
|
|
12615
|
+
if (indexEntry && (indexEntry.mode & S_IFMT$7) === S_IFGITLINK$4) return octal(indexEntry.mode);
|
|
12616
|
+
return octal((entry.mode & S_IFMT$7) === S_IFGITLINK$4 ? S_IFGITLINK$4 : S_IFDIR$5);
|
|
12211
12617
|
}
|
|
12212
|
-
if ((entry.mode & S_IFMT$7) === S_IFGITLINK$
|
|
12618
|
+
if ((entry.mode & S_IFMT$7) === S_IFGITLINK$4) return octal(S_IFGITLINK$4);
|
|
12213
12619
|
if ((entry.mode & S_IFMT$7) === S_IFLNK$2) return octal(S_IFLNK$2);
|
|
12214
12620
|
return octal(entry.mode & 73 ? 33261 : 33188);
|
|
12215
12621
|
}
|
|
@@ -12229,7 +12635,7 @@ var CheckAttrCommand = class extends GitCommand {
|
|
|
12229
12635
|
*/
|
|
12230
12636
|
const S_IFMT$6 = 61440;
|
|
12231
12637
|
const S_IFLNK$1 = 40960;
|
|
12232
|
-
const S_IFGITLINK$
|
|
12638
|
+
const S_IFGITLINK$3 = 57344;
|
|
12233
12639
|
const S_IFDIR$4 = 16384;
|
|
12234
12640
|
/**
|
|
12235
12641
|
* `git check-ignore [-q] [-v [-n]] [--no-index] (<pathname>... | --stdin [-z])`: each path the
|
|
@@ -12336,7 +12742,7 @@ var CheckIgnoreCommand = class extends GitCommand {
|
|
|
12336
12742
|
if (entry && (entry.mode & S_IFMT$6) === S_IFLNK$1) return `pathspec '${original}' is beyond a symbolic link`;
|
|
12337
12743
|
}
|
|
12338
12744
|
if (staging) {
|
|
12339
|
-
for (const e of index) if ((e.mode & S_IFMT$6) === S_IFGITLINK$
|
|
12745
|
+
for (const e of index) if ((e.mode & S_IFMT$6) === S_IFGITLINK$3 && path.startsWith(`${e.path}/`)) return `Pathspec '${original}' is in submodule '${e.path}'`;
|
|
12340
12746
|
}
|
|
12341
12747
|
let match;
|
|
12342
12748
|
if (!staging || !this.seenInIndex(full, index)) {
|
|
@@ -12400,7 +12806,7 @@ var CheckIgnoreCommand = class extends GitCommand {
|
|
|
12400
12806
|
return false;
|
|
12401
12807
|
}
|
|
12402
12808
|
for (const e of index) {
|
|
12403
|
-
const dir = (e.mode & S_IFMT$6) === S_IFGITLINK$
|
|
12809
|
+
const dir = (e.mode & S_IFMT$6) === S_IFGITLINK$3 || (e.mode & S_IFMT$6) === S_IFDIR$4;
|
|
12404
12810
|
if (matchPathspec([item], e.path, dir ? 1 : 0)) return true;
|
|
12405
12811
|
}
|
|
12406
12812
|
return false;
|
|
@@ -33551,6 +33957,7 @@ var SubmoduleUpdateCommand = class SubmoduleUpdateCommand extends SubmoduleComma
|
|
|
33551
33957
|
requireInit = false;
|
|
33552
33958
|
/** `--filter=<spec>` of the clones */
|
|
33553
33959
|
filter;
|
|
33960
|
+
objectStorageFormat;
|
|
33554
33961
|
/** `--[no-]single-branch` of the clones */
|
|
33555
33962
|
singleBranch;
|
|
33556
33963
|
transports;
|
|
@@ -33627,6 +34034,16 @@ var SubmoduleUpdateCommand = class SubmoduleUpdateCommand extends SubmoduleComma
|
|
|
33627
34034
|
this.recommendShallow = recommend;
|
|
33628
34035
|
return this;
|
|
33629
34036
|
}
|
|
34037
|
+
/**
|
|
34038
|
+
* `--object-storage-format=<name>` (git master): the object storage of the submodules
|
|
34039
|
+
* cloned. Only `files` is a name git knows (the repository as always); anything else,
|
|
34040
|
+
* `files://<dir>` included, dies `unknown object storage format '<v>'` before any work.
|
|
34041
|
+
*/
|
|
34042
|
+
setObjectStorageFormat(format) {
|
|
34043
|
+
this.checkCallable();
|
|
34044
|
+
this.objectStorageFormat = format;
|
|
34045
|
+
return this;
|
|
34046
|
+
}
|
|
33630
34047
|
/** `--filter=<spec>`: partial clones of the submodules (`CloneCommand.setFilter`). */
|
|
33631
34048
|
setFilter(spec) {
|
|
33632
34049
|
this.checkCallable();
|
|
@@ -33759,6 +34176,10 @@ var SubmoduleUpdateCommand = class SubmoduleUpdateCommand extends SubmoduleComma
|
|
|
33759
34176
|
}
|
|
33760
34177
|
async call() {
|
|
33761
34178
|
this.start();
|
|
34179
|
+
if (this.objectStorageFormat !== void 0) {
|
|
34180
|
+
const unknown = unknownObjectStorageFormat(this.objectStorageFormat, "name");
|
|
34181
|
+
if (unknown) this.die(unknown);
|
|
34182
|
+
}
|
|
33762
34183
|
if (this.requireInit) this.init = true;
|
|
33763
34184
|
const list = await this.moduleList(this.paths);
|
|
33764
34185
|
if (!list) return this.finish();
|
|
@@ -34322,6 +34743,7 @@ const CLONE_SETTINGS = [
|
|
|
34322
34743
|
"dissociate",
|
|
34323
34744
|
"references",
|
|
34324
34745
|
"recurseSubmodules",
|
|
34746
|
+
"objectStorageFormat",
|
|
34325
34747
|
"shallowSubmodules",
|
|
34326
34748
|
"alsoFilterSubmodules",
|
|
34327
34749
|
"remoteSubmodules",
|
|
@@ -34447,6 +34869,7 @@ var CloneCommand = class CloneCommand extends TransportCommand {
|
|
|
34447
34869
|
references = [];
|
|
34448
34870
|
/** `--recurse-submodules[=<pathspec>]` values, in the order given */
|
|
34449
34871
|
recurseSubmodules = [];
|
|
34872
|
+
objectStorageFormat;
|
|
34450
34873
|
shallowSubmodules = false;
|
|
34451
34874
|
/** `--[no-]also-filter-submodules`; unset: `clone.filterSubmodules` */
|
|
34452
34875
|
alsoFilterSubmodules;
|
|
@@ -34915,6 +35338,18 @@ var CloneCommand = class CloneCommand extends TransportCommand {
|
|
|
34915
35338
|
* `protocol.file.allow=always`. Credentials and headers reach a submodule's URL only as
|
|
34916
35339
|
* `SubmoduleUpdateCommand.setCredentials` allows (the clone's own origin).
|
|
34917
35340
|
*/
|
|
35341
|
+
/**
|
|
35342
|
+
* `--object-storage-format=<format>`: the clone's object storage (git master). `files` is
|
|
35343
|
+
* the repository as always and is passed on to the submodules a recursive clone makes; a
|
|
35344
|
+
* name git does not know dies as git (`unknown object storage format '<v>'`), and
|
|
35345
|
+
* `files://<directory>`, objects outside `objects/`, which we do not read, is refused
|
|
35346
|
+
* before anything is fetched (`UnsupportedObjectStorageError`).
|
|
35347
|
+
*/
|
|
35348
|
+
setObjectStorageFormat(format) {
|
|
35349
|
+
this.checkCallable();
|
|
35350
|
+
this.objectStorageFormat = format;
|
|
35351
|
+
return this;
|
|
35352
|
+
}
|
|
34918
35353
|
setRecurseSubmodules(recurse) {
|
|
34919
35354
|
this.checkCallable();
|
|
34920
35355
|
this.recurseSubmodules = recurse === true ? ["."] : recurse === false ? [] : [...recurse];
|
|
@@ -35001,6 +35436,11 @@ var CloneCommand = class CloneCommand extends TransportCommand {
|
|
|
35001
35436
|
}
|
|
35002
35437
|
async cloneOnce() {
|
|
35003
35438
|
if (!this.uri) throw new InvalidRemoteError("", "URI must be specified for clone");
|
|
35439
|
+
if (this.objectStorageFormat !== void 0) {
|
|
35440
|
+
const unknown = unknownObjectStorageFormat(this.objectStorageFormat, "uri");
|
|
35441
|
+
if (unknown) throw new GitApiError(unknown);
|
|
35442
|
+
if (objectStorageFormatByUri(this.objectStorageFormat)?.payload !== void 0) throw new UnsupportedObjectStorageError(this.objectStorageFormat);
|
|
35443
|
+
}
|
|
35004
35444
|
const submoduleConfig = [];
|
|
35005
35445
|
if (this.recurseSubmodules.length > 0) {
|
|
35006
35446
|
const patterns = [...new Set(this.recurseSubmodules)].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
@@ -35019,10 +35459,15 @@ var CloneCommand = class CloneCommand extends TransportCommand {
|
|
|
35019
35459
|
if (this.bundleUri !== void 0 && (this.depth !== void 0 || this.shallowSince !== void 0 || this.shallowExcludes.length > 0)) throw new GitApiError(compatibility === "2.43" ? "fatal: --bundle-uri is incompatible with --depth, --shallow-since, and --shallow-exclude" : "fatal: options '--bundle-uri' and '--depth/--shallow-since/--shallow-exclude' cannot be used together");
|
|
35020
35460
|
const uri = this.uri;
|
|
35021
35461
|
const worktree = repositoryPlaceOf(this.workingCopy);
|
|
35462
|
+
let formatRefusal;
|
|
35022
35463
|
const isRepositoryPath = await worktree?.openRepository?.(uri, {
|
|
35023
35464
|
checkOwnership: false,
|
|
35024
35465
|
commandLineConfig: false
|
|
35025
|
-
}).then((opened) => opened !== void 0).catch(() =>
|
|
35466
|
+
}).then((opened) => opened !== void 0).catch((error) => {
|
|
35467
|
+
if (error instanceof Error && error.name === "UnsupportedRepositoryFormatError") formatRefusal = error;
|
|
35468
|
+
return false;
|
|
35469
|
+
});
|
|
35470
|
+
if (formatRefusal) throw new TransportError$1(`fatal: ${formatRefusal.message}`);
|
|
35026
35471
|
let bundleFile;
|
|
35027
35472
|
const givenBundle = this.hasGivenBundle(uri);
|
|
35028
35473
|
if (givenBundle) bundleFile = uri;
|
|
@@ -35400,6 +35845,7 @@ var CloneCommand = class CloneCommand extends TransportCommand {
|
|
|
35400
35845
|
if (this.shallowSubmodules) update.setDepth(1);
|
|
35401
35846
|
if (this.remoteSubmodules) update.setRemote(true).setNoFetch(true);
|
|
35402
35847
|
if (filterSubmodules && this.filterSpec !== void 0) update.setFilter(this.filterSpec);
|
|
35848
|
+
if (this.objectStorageFormat !== void 0) update.setObjectStorageFormat("files");
|
|
35403
35849
|
update.setSingleBranch(this.revision !== void 0 ? false : this.singleBranch ?? (this.depth !== void 0 || this.shallowSince !== void 0 || this.shallowExcludes.length > 0));
|
|
35404
35850
|
update.setTransports(this.getTransports());
|
|
35405
35851
|
if (this.credentials) update.setCredentials(this.credentials);
|
|
@@ -37466,7 +37912,7 @@ var DiffTreeCommand = class extends DiffPlumbingCommand {
|
|
|
37466
37912
|
} else if (kind === "commit") out.push(await this.commitOrTree(first, rest.length ? rest : void 0, formats));
|
|
37467
37913
|
}
|
|
37468
37914
|
}
|
|
37469
|
-
return concat$
|
|
37915
|
+
return concat$8(out);
|
|
37470
37916
|
}
|
|
37471
37917
|
/** The tree walk the run asks for (diff_setup_done: a patch or a stat recurses) */
|
|
37472
37918
|
walk(formats) {
|
|
@@ -37597,7 +38043,7 @@ function parseStdinLine(line, hexLength) {
|
|
|
37597
38043
|
}
|
|
37598
38044
|
return ids.length > 0 ? ids : void 0;
|
|
37599
38045
|
}
|
|
37600
|
-
function concat$
|
|
38046
|
+
function concat$8(parts) {
|
|
37601
38047
|
let n = 0;
|
|
37602
38048
|
for (const p of parts) n += p.length;
|
|
37603
38049
|
const out = new Uint8Array(n);
|
|
@@ -37729,7 +38175,7 @@ var DiffPairsCommand = class extends DiffPlumbingCommand {
|
|
|
37729
38175
|
}
|
|
37730
38176
|
}
|
|
37731
38177
|
await flush();
|
|
37732
|
-
return concat$
|
|
38178
|
+
return concat$7(out);
|
|
37733
38179
|
}
|
|
37734
38180
|
};
|
|
37735
38181
|
function fatal(message) {
|
|
@@ -37754,7 +38200,7 @@ function latin1$4(bytes) {
|
|
|
37754
38200
|
for (const b of bytes) s += String.fromCharCode(b);
|
|
37755
38201
|
return s;
|
|
37756
38202
|
}
|
|
37757
|
-
function concat$
|
|
38203
|
+
function concat$7(parts) {
|
|
37758
38204
|
let n = 0;
|
|
37759
38205
|
for (const p of parts) n += p.length;
|
|
37760
38206
|
const out = new Uint8Array(n);
|
|
@@ -38600,7 +39046,7 @@ const S_IFMT$5 = 61440;
|
|
|
38600
39046
|
const S_IFDIR$3 = 16384;
|
|
38601
39047
|
const S_IFREG$1 = 32768;
|
|
38602
39048
|
const S_IFLNK = 40960;
|
|
38603
|
-
const S_IFGITLINK$
|
|
39049
|
+
const S_IFGITLINK$2 = 57344;
|
|
38604
39050
|
const BRANCH_TABLE_SIZE = 1039;
|
|
38605
39051
|
/** fast-import.c's hc_str over the name's bytes as signed chars. */
|
|
38606
39052
|
function hcStr(name) {
|
|
@@ -39341,7 +39787,7 @@ var FastImportCommand = class extends PlumbingCommand {
|
|
|
39341
39787
|
case 33261:
|
|
39342
39788
|
case S_IFLNK:
|
|
39343
39789
|
case S_IFDIR$3:
|
|
39344
|
-
case S_IFGITLINK$
|
|
39790
|
+
case S_IFGITLINK$2: break;
|
|
39345
39791
|
default: this.die(`corrupt mode: ${this.line}`);
|
|
39346
39792
|
}
|
|
39347
39793
|
let id;
|
|
@@ -39370,7 +39816,7 @@ var FastImportCommand = class extends PlumbingCommand {
|
|
|
39370
39816
|
await this.treeRemove(b.root, path, false);
|
|
39371
39817
|
return;
|
|
39372
39818
|
}
|
|
39373
|
-
if (mode === S_IFGITLINK$
|
|
39819
|
+
if (mode === S_IFGITLINK$2) {
|
|
39374
39820
|
if (inline) this.die(`Git links cannot be specified 'inline': ${this.line}`);
|
|
39375
39821
|
if (knownType !== void 0 && knownType !== "commit") this.die(`not a commit (actually a ${knownType}): ${this.line}`);
|
|
39376
39822
|
} else if (inline) {
|
|
@@ -39740,7 +40186,7 @@ var FastImportCommand = class extends PlumbingCommand {
|
|
|
39740
40186
|
return;
|
|
39741
40187
|
}
|
|
39742
40188
|
if (isDir$1(leaf.mode)) await this.storeTree(leaf);
|
|
39743
|
-
const type = leaf.mode === S_IFGITLINK$
|
|
40189
|
+
const type = leaf.mode === S_IFGITLINK$2 ? "commit" : isDir$1(leaf.mode) ? "tree" : "blob";
|
|
39744
40190
|
await this.catBlobWrite(`${leaf.mode.toString(8).padStart(6, "0")} ${type} ${leaf.id}\t${quoted}\n`);
|
|
39745
40191
|
}
|
|
39746
40192
|
async parseAlias() {
|
|
@@ -39872,7 +40318,7 @@ function canonMode(mode) {
|
|
|
39872
40318
|
if ((mode & S_IFMT$5) === S_IFREG$1) return S_IFREG$1 | (mode & 73 ? 493 : 420);
|
|
39873
40319
|
if ((mode & S_IFMT$5) === S_IFLNK) return S_IFLNK;
|
|
39874
40320
|
if ((mode & S_IFMT$5) === S_IFDIR$3) return S_IFDIR$3;
|
|
39875
|
-
return S_IFGITLINK$
|
|
40321
|
+
return S_IFGITLINK$2;
|
|
39876
40322
|
}
|
|
39877
40323
|
/** validate_raw_date */
|
|
39878
40324
|
function validRawDate(text, strict) {
|
|
@@ -41944,7 +42390,7 @@ var FormatPatchCommand = class extends RangeDiffBase {
|
|
|
41944
42390
|
if (cover) {
|
|
41945
42391
|
if (thread) ownId = messageId("cover");
|
|
41946
42392
|
nr = 0;
|
|
41947
|
-
const content = concat$
|
|
42393
|
+
const content = concat$6([
|
|
41948
42394
|
await this.coverLetterText(list, origin, {
|
|
41949
42395
|
subject: subjectOf(),
|
|
41950
42396
|
thread: threadHeaders(),
|
|
@@ -42032,7 +42478,7 @@ Content-Disposition: ${mime.inline ? "inline" : "attachment"}; filename="${part}
|
|
|
42032
42478
|
shownOne = true;
|
|
42033
42479
|
parts.push(bytes, ...diffOfDiff.afterPatch, latin(bases.text), latin(mime ? `\n--${MIME_BOUNDARY_LEADER}${mime.boundary}--\n\n\n` : sig()));
|
|
42034
42480
|
bases.text = "";
|
|
42035
|
-
emit(fileName(subject), concat$
|
|
42481
|
+
emit(fileName(subject), concat$6(parts));
|
|
42036
42482
|
}
|
|
42037
42483
|
if (!this.stdout && this.writeFiles) {
|
|
42038
42484
|
const worktree = this.worktreeAccess;
|
|
@@ -42043,7 +42489,7 @@ Content-Disposition: ${mime.inline ? "inline" : "attachment"}; filename="${part}
|
|
|
42043
42489
|
}
|
|
42044
42490
|
return {
|
|
42045
42491
|
patches,
|
|
42046
|
-
output: this.stdout ? concat$
|
|
42492
|
+
output: this.stdout ? concat$6(stdoutParts) : new TextEncoder().encode(out.join("")),
|
|
42047
42493
|
...this.warnings.length ? { warnings: this.warnings } : {}
|
|
42048
42494
|
};
|
|
42049
42495
|
}
|
|
@@ -42121,7 +42567,7 @@ Content-Disposition: ${mime.inline ? "inline" : "attachment"}; filename="${part}
|
|
|
42121
42567
|
};
|
|
42122
42568
|
return {
|
|
42123
42569
|
...none,
|
|
42124
|
-
commentary: blocks.map((b) => concat$
|
|
42570
|
+
commentary: blocks.map((b) => concat$6([enc.encode(`${b.title}\n`), b.indented]))
|
|
42125
42571
|
};
|
|
42126
42572
|
}
|
|
42127
42573
|
/** The subject for the file name (`%f`). */
|
|
@@ -42372,7 +42818,7 @@ Content-Disposition: ${mime.inline ? "inline" : "attachment"}; filename="${part}
|
|
|
42372
42818
|
text += "\n";
|
|
42373
42819
|
}
|
|
42374
42820
|
parts.push(new TextEncoder().encode(text));
|
|
42375
|
-
return concat$
|
|
42821
|
+
return concat$6(parts);
|
|
42376
42822
|
}
|
|
42377
42823
|
/** The commit as stored (its fields encoded again when the store has no raw bytes). */
|
|
42378
42824
|
async rawCommitBytes(id) {
|
|
@@ -42383,7 +42829,7 @@ Content-Disposition: ${mime.inline ? "inline" : "attachment"}; filename="${part}
|
|
|
42383
42829
|
if (obj.bytes) return obj.bytes;
|
|
42384
42830
|
const chunks = [];
|
|
42385
42831
|
for await (const c of obj.content) chunks.push(c);
|
|
42386
|
-
return concat$
|
|
42832
|
+
return concat$6(chunks);
|
|
42387
42833
|
}
|
|
42388
42834
|
} catch {}
|
|
42389
42835
|
const commit = await this.commits.load(id);
|
|
@@ -42507,7 +42953,7 @@ function cleanMessageId(id) {
|
|
|
42507
42953
|
function latin(text) {
|
|
42508
42954
|
return new TextEncoder().encode(text);
|
|
42509
42955
|
}
|
|
42510
|
-
function concat$
|
|
42956
|
+
function concat$6(parts) {
|
|
42511
42957
|
let size = 0;
|
|
42512
42958
|
for (const p of parts) size += p.length;
|
|
42513
42959
|
const out = new Uint8Array(size);
|
|
@@ -42677,14 +43123,25 @@ var FormatRevCommand = class extends PlumbingCommand {
|
|
|
42677
43123
|
const alias = RemoteConfigStore.from(this.workingCopy).value(`pretty.${format}`);
|
|
42678
43124
|
if (alias !== void 0) return this.prettyOf(alias, depth + 1);
|
|
42679
43125
|
}
|
|
42680
|
-
if (BUILTIN_OTHER.has(format))
|
|
43126
|
+
if (BUILTIN_OTHER.has(format)) return { builtin: format };
|
|
42681
43127
|
throw new PlumbingError(`fatal: invalid --pretty format: ${format}`);
|
|
42682
43128
|
}
|
|
42683
43129
|
/** pretty_print_commit of one commit (with its notes when the format shows `%N`). */
|
|
42684
43130
|
async formatOne(id, pretty) {
|
|
42685
43131
|
const log = new LogCommand(this.workingCopy).setNoWalk([{ id }]).setLogConfig(false);
|
|
42686
|
-
const wantsNotes = /%N/.test(pretty.format);
|
|
42687
43132
|
try {
|
|
43133
|
+
if (pretty.builtin !== void 0) return decodeGitPath(await log.callBytes({
|
|
43134
|
+
pretty: pretty.builtin,
|
|
43135
|
+
prettyOnly: true,
|
|
43136
|
+
notes: false,
|
|
43137
|
+
mailmap: false,
|
|
43138
|
+
date: "default",
|
|
43139
|
+
mail: {
|
|
43140
|
+
subject: () => "Subject: ",
|
|
43141
|
+
encodeHeaders: false
|
|
43142
|
+
}
|
|
43143
|
+
}));
|
|
43144
|
+
const wantsNotes = /%N/.test(pretty.format);
|
|
42688
43145
|
return decodeGitPath(await log.callBytes({
|
|
42689
43146
|
pretty: `format:${pretty.format}`,
|
|
42690
43147
|
...pretty.date ? { date: pretty.date } : {},
|
|
@@ -43525,7 +43982,7 @@ var InterpretTrailersCommand = class extends GitCommand {
|
|
|
43525
43982
|
if (!file || stats?.kind !== "file") throw new GitApiError(`fatal: could not read input file '${name}': ${stats ? "Is a directory" : "No such file or directory"}`, { exitCode: 128 });
|
|
43526
43983
|
const chunks = [];
|
|
43527
43984
|
for await (const chunk of file.files.read(file.path)) chunks.push(chunk);
|
|
43528
|
-
const output = await process(decoder$3.decode(concat$
|
|
43985
|
+
const output = await process(decoder$3.decode(concat$5(chunks)));
|
|
43529
43986
|
if (this.inPlace) await file.files.write(file.path, [encoder$5.encode(output)]);
|
|
43530
43987
|
else stdout += output;
|
|
43531
43988
|
}
|
|
@@ -43535,7 +43992,7 @@ var InterpretTrailersCommand = class extends GitCommand {
|
|
|
43535
43992
|
};
|
|
43536
43993
|
}
|
|
43537
43994
|
};
|
|
43538
|
-
function concat$
|
|
43995
|
+
function concat$5(chunks) {
|
|
43539
43996
|
if (chunks.length === 1) return chunks[0];
|
|
43540
43997
|
const out = new Uint8Array(chunks.reduce((n, c) => n + c.length, 0));
|
|
43541
43998
|
let at = 0;
|
|
@@ -44001,18 +44458,25 @@ var LsFilesCommand = class extends PlumbingCommand {
|
|
|
44001
44458
|
let id;
|
|
44002
44459
|
try {
|
|
44003
44460
|
id = await this.resolveRevision(name);
|
|
44004
|
-
} catch {
|
|
44461
|
+
} catch (e) {
|
|
44462
|
+
if (e instanceof CorruptTreeError) throw e;
|
|
44005
44463
|
throw new PlumbingError(`fatal: tree-ish ${name} not found.`);
|
|
44006
44464
|
}
|
|
44007
44465
|
let tree;
|
|
44008
44466
|
try {
|
|
44009
44467
|
tree = await this.resolveRevision(`${id}^{tree}`);
|
|
44010
|
-
} catch {
|
|
44468
|
+
} catch (e) {
|
|
44469
|
+
if (e instanceof CorruptTreeError) throw e;
|
|
44011
44470
|
throw new PlumbingError(`fatal: bad tree-ish ${name}`);
|
|
44012
44471
|
}
|
|
44013
44472
|
for (const e of list) if (e.stage !== 0) e.stage = 3;
|
|
44014
44473
|
const add = async (treeId, base) => {
|
|
44015
|
-
|
|
44474
|
+
const entries = await this.listedTreeEntries(treeId);
|
|
44475
|
+
if (!entries) {
|
|
44476
|
+
this.warn(`error: Could not read ${treeId}`);
|
|
44477
|
+
throw new PlumbingError(`fatal: unable to read tree entries ${name}`);
|
|
44478
|
+
}
|
|
44479
|
+
for (const entry of entries) {
|
|
44016
44480
|
const path = base + entry.name;
|
|
44017
44481
|
const nameBytes = pathspecName(path);
|
|
44018
44482
|
if ((entry.mode & S_IFMT$4) === 16384) {
|
|
@@ -44097,7 +44561,7 @@ var LsFilesCommand = class extends PlumbingCommand {
|
|
|
44097
44561
|
}
|
|
44098
44562
|
if (!path.startsWith("/") && worktree) {
|
|
44099
44563
|
if (path.startsWith(".git/") && worktree.readGitDirFile) return worktree.readGitDirFile(path.slice(5)).catch(() => void 0);
|
|
44100
|
-
return
|
|
44564
|
+
return readAllBytes(worktree.readContent(path)).catch(() => void 0);
|
|
44101
44565
|
}
|
|
44102
44566
|
};
|
|
44103
44567
|
const files = [];
|
|
@@ -44129,7 +44593,7 @@ var LsFilesCommand = class extends PlumbingCommand {
|
|
|
44129
44593
|
if (worktree) {
|
|
44130
44594
|
const entry = await worktree.getEntry(path).catch(() => void 0);
|
|
44131
44595
|
if (entry && !entry.isDirectory && entry.mode !== FileMode$1.SYMLINK) {
|
|
44132
|
-
const bytes = await
|
|
44596
|
+
const bytes = await readAllBytes(worktree.readContent(path)).catch(() => void 0);
|
|
44133
44597
|
if (bytes) return decodeGitPatternFile(bytes);
|
|
44134
44598
|
}
|
|
44135
44599
|
if (entry) return void 0;
|
|
@@ -44137,7 +44601,7 @@ var LsFilesCommand = class extends PlumbingCommand {
|
|
|
44137
44601
|
const id = skipWorktree.get(path);
|
|
44138
44602
|
if (!id) return void 0;
|
|
44139
44603
|
const content = await this.blobs.load(id).catch(() => void 0);
|
|
44140
|
-
return content ? decodeGitPatternFile(await
|
|
44604
|
+
return content ? decodeGitPatternFile(await readAllBytes(content)) : void 0;
|
|
44141
44605
|
};
|
|
44142
44606
|
return new ExcludeRules(this.excludes.length > 0 ? createCommandLineExcludes(this.excludes) : void 0, files, perDir, coreBool(this.workingCopy, "ignorecase", false), readPerDir);
|
|
44143
44607
|
}
|
|
@@ -44167,7 +44631,7 @@ var LsFilesCommand = class extends PlumbingCommand {
|
|
|
44167
44631
|
}
|
|
44168
44632
|
if (!found) return eolStatsAscii(void 0);
|
|
44169
44633
|
const content = await this.blobs.load(found.objectId).catch(() => void 0);
|
|
44170
|
-
return eolStatsAscii(content ? await
|
|
44634
|
+
return eolStatsAscii(content ? await readAllBytes(content) : void 0);
|
|
44171
44635
|
}
|
|
44172
44636
|
/** show_ce_fmt: one entry through `--format`. */
|
|
44173
44637
|
async formatEntry(e, worktree, list, nameText) {
|
|
@@ -44204,7 +44668,7 @@ var LsFilesCommand = class extends PlumbingCommand {
|
|
|
44204
44668
|
if (end < 0) throw new PlumbingError(`fatal: bad ls-files format: element '${rest}' does not end in ')'`);
|
|
44205
44669
|
const atom = rest.slice(0, end + 1);
|
|
44206
44670
|
i = pct + 1 + atom.length;
|
|
44207
|
-
const type = objectTypeOfMode
|
|
44671
|
+
const type = objectTypeOfMode(e.mode);
|
|
44208
44672
|
switch (atom) {
|
|
44209
44673
|
case "(objectmode)":
|
|
44210
44674
|
out += e.mode.toString(8).padStart(6, "0");
|
|
@@ -44314,12 +44778,6 @@ function lowerTag(tag) {
|
|
|
44314
44778
|
if (c === "?") return `!${tag.slice(1)}`;
|
|
44315
44779
|
return `v${c} `;
|
|
44316
44780
|
}
|
|
44317
|
-
/** object_type of an index mode. */
|
|
44318
|
-
function objectTypeOfMode$1(mode) {
|
|
44319
|
-
if ((mode & S_IFMT$4) === 16384) return "tree";
|
|
44320
|
-
if (mode === FileMode$1.GITLINK) return "commit";
|
|
44321
|
-
return "blob";
|
|
44322
|
-
}
|
|
44323
44781
|
/**
|
|
44324
44782
|
* show_killed_files' test of one walked path: a leading directory of it is an index file, or
|
|
44325
44783
|
* (for the last component) the index has entries below it.
|
|
@@ -44366,25 +44824,9 @@ async function worktreeEolInfo(worktree, path) {
|
|
|
44366
44824
|
if (path.endsWith("/")) return "";
|
|
44367
44825
|
const entry = await worktree.getEntry(path).catch(() => void 0);
|
|
44368
44826
|
if (!entry || entry.isDirectory || entry.mode === FileMode$1.SYMLINK || entry.mode === FileMode$1.GITLINK) return "";
|
|
44369
|
-
const bytes = await
|
|
44827
|
+
const bytes = await readAllBytes(worktree.readContent(path)).catch(() => void 0);
|
|
44370
44828
|
return bytes ? eolStatsAscii(bytes) : "";
|
|
44371
44829
|
}
|
|
44372
|
-
async function readAll$1(content) {
|
|
44373
|
-
const chunks = [];
|
|
44374
|
-
let size = 0;
|
|
44375
|
-
for await (const c of content) {
|
|
44376
|
-
chunks.push(c);
|
|
44377
|
-
size += c.length;
|
|
44378
|
-
}
|
|
44379
|
-
const out = new Uint8Array(size);
|
|
44380
|
-
let at = 0;
|
|
44381
|
-
for (const c of chunks) {
|
|
44382
|
-
out.set(c, at);
|
|
44383
|
-
at += c.length;
|
|
44384
|
-
}
|
|
44385
|
-
return out;
|
|
44386
|
-
}
|
|
44387
|
-
const SHORT_MAGIC$1 = /* @__PURE__ */ new Set([..."!\"#%&',-;<=>@_`~^/"]);
|
|
44388
44830
|
/**
|
|
44389
44831
|
* A pathspec element read against the current directory, as parse_pathspec's
|
|
44390
44832
|
* `prefix_path_gently` reads it (`:(top)` and `:/` from the top; an absolute path against the
|
|
@@ -46266,8 +46708,6 @@ const MAGIC$2 = [
|
|
|
46266
46708
|
mnemonic: ""
|
|
46267
46709
|
}
|
|
46268
46710
|
];
|
|
46269
|
-
/** ctype.c's GIT_PATHSPEC_MAGIC characters (and `/`, `^`) */
|
|
46270
|
-
const SHORT_MAGIC = /* @__PURE__ */ new Set([..."!\"#%&',-;<=>@_`~^/"]);
|
|
46271
46711
|
const FLUSH_AT = 65536;
|
|
46272
46712
|
/**
|
|
46273
46713
|
* `git ls-tree [<options>] <tree-ish> [<path>...]`.
|
|
@@ -46440,7 +46880,7 @@ var LsTreeCommand = class extends PlumbingCommand {
|
|
|
46440
46880
|
const resolver = this.revisionResolver();
|
|
46441
46881
|
let id;
|
|
46442
46882
|
try {
|
|
46443
|
-
id = await resolver.resolve(this.treeish);
|
|
46883
|
+
id = await resolver.resolve(this.treeish, { hashAny: true });
|
|
46444
46884
|
} catch (e) {
|
|
46445
46885
|
if (!(e instanceof RefNotFoundError)) throw e;
|
|
46446
46886
|
}
|
|
@@ -46517,6 +46957,14 @@ var LsTreeCommand = class extends PlumbingCommand {
|
|
|
46517
46957
|
}
|
|
46518
46958
|
/** parse_tree_indirect: a commit's tree, a tag's object peeled, a tree itself. */
|
|
46519
46959
|
async peelToTree(id) {
|
|
46960
|
+
const compat = this.compatObjects;
|
|
46961
|
+
if (compat && id.length !== this.objectFormat.hexLength) {
|
|
46962
|
+
const type = (await compat.readAsCompat(id).catch(() => void 0))?.type;
|
|
46963
|
+
if (type === "tree") return id;
|
|
46964
|
+
if (type === "commit") this.warn(`error: bogus commit object ${id}`);
|
|
46965
|
+
if (type === "blob") this.warn(`error: hash mismatch ${id}`);
|
|
46966
|
+
return;
|
|
46967
|
+
}
|
|
46520
46968
|
const peeled = await this.revisionResolver().peelTags(id);
|
|
46521
46969
|
if (peeled.type === "tree") return peeled.id;
|
|
46522
46970
|
if (peeled.type === "commit") return (await this.commits.load(peeled.id).catch(() => void 0))?.tree;
|
|
@@ -46574,6 +47022,10 @@ var LsTreeCommand = class extends PlumbingCommand {
|
|
|
46574
47022
|
}
|
|
46575
47023
|
async abbreviated(id) {
|
|
46576
47024
|
if (this.abbrev === 0) return id;
|
|
47025
|
+
if (id.length !== this.objectFormat.hexLength) {
|
|
47026
|
+
const min = this.abbrev < 0 ? 7 : Math.max(4, this.abbrev);
|
|
47027
|
+
return id.slice(0, Math.min(min, id.length));
|
|
47028
|
+
}
|
|
46577
47029
|
const hex = this.objectFormat.hexLength;
|
|
46578
47030
|
const min = this.abbrev < 0 ? void 0 : this.abbrev < 4 ? 4 : this.abbrev > hex ? hex : this.abbrev;
|
|
46579
47031
|
const length = (await this.idAbbreviator().lengths([id], min)).get(id) ?? hex;
|
|
@@ -46581,6 +47033,8 @@ var LsTreeCommand = class extends PlumbingCommand {
|
|
|
46581
47033
|
}
|
|
46582
47034
|
/** The blob's size, undefined when it cannot be read. */
|
|
46583
47035
|
async blobSize(id) {
|
|
47036
|
+
const compat = this.compatObjects;
|
|
47037
|
+
if (compat && id.length !== this.objectFormat.hexLength) return (await compat.readAsCompat(id).catch(() => void 0))?.content.length;
|
|
46584
47038
|
const objects = this._workingCopy.history?.objects;
|
|
46585
47039
|
try {
|
|
46586
47040
|
if (objects) {
|
|
@@ -46605,11 +47059,11 @@ var LsTreeCommand = class extends PlumbingCommand {
|
|
|
46605
47059
|
async entryLine(ctx, id, mode, type, path) {
|
|
46606
47060
|
const modeText = mode.toString(8).padStart(6, "0");
|
|
46607
47061
|
switch (ctx.fn) {
|
|
46608
|
-
case "default": return
|
|
47062
|
+
case "default": return concatBytes([latin1Bytes$3(`${modeText} ${type} ${await this.abbreviated(id)}\t`), this.fastPath(ctx, path)]);
|
|
46609
47063
|
case "long": {
|
|
46610
47064
|
let size = "-";
|
|
46611
47065
|
if (type === "blob") size = String(await this.blobSize(id) ?? "BAD");
|
|
46612
|
-
return
|
|
47066
|
+
return concatBytes([latin1Bytes$3(`${modeText} ${type} ${await this.abbreviated(id)} ${size.padStart(7)}\t`), this.fastPath(ctx, path)]);
|
|
46613
47067
|
}
|
|
46614
47068
|
case "name-only": return this.fastPath(ctx, path);
|
|
46615
47069
|
case "object-only": return latin1Bytes$3(`${await this.abbreviated(id)}${this.nul ? "\0" : "\n"}`);
|
|
@@ -46686,18 +47140,6 @@ var LsTreeCommand = class extends PlumbingCommand {
|
|
|
46686
47140
|
return out;
|
|
46687
47141
|
}
|
|
46688
47142
|
};
|
|
46689
|
-
function objectTypeOfMode(mode) {
|
|
46690
|
-
const kind = mode & 61440;
|
|
46691
|
-
if (kind === 16384) return "tree";
|
|
46692
|
-
if (kind === 57344) return "commit";
|
|
46693
|
-
return "blob";
|
|
46694
|
-
}
|
|
46695
|
-
function concat$5(a, b) {
|
|
46696
|
-
const out = new Uint8Array(a.length + b.length);
|
|
46697
|
-
out.set(a);
|
|
46698
|
-
out.set(b, a.length);
|
|
46699
|
-
return out;
|
|
46700
|
-
}
|
|
46701
47143
|
/** A byte string as git prints it in an error message (bytes as they are). */
|
|
46702
47144
|
function decodeLatin1Path(s) {
|
|
46703
47145
|
return new TextDecoder().decode(latin1Bytes$3(s));
|
|
@@ -46751,7 +47193,7 @@ function parseElementMagic(elem) {
|
|
|
46751
47193
|
magic.add("exclude");
|
|
46752
47194
|
continue;
|
|
46753
47195
|
}
|
|
46754
|
-
if (!SHORT_MAGIC.has(ch)) break;
|
|
47196
|
+
if (!SHORT_MAGIC$1.has(ch)) break;
|
|
46755
47197
|
const m = MAGIC$2.find((x) => x.mnemonic === ch);
|
|
46756
47198
|
if (!m) throw new PlumbingError(`fatal: Unimplemented pathspec magic '${ch}' in '${elem}'`);
|
|
46757
47199
|
magic.add(m.name);
|
|
@@ -48011,6 +48453,8 @@ var MvCommand = class extends GitCommand {
|
|
|
48011
48453
|
const adder = await IndexAdder.open(this.staging, this.blobs, trust, { pathRules: worktreePathRules(this.workingCopy) });
|
|
48012
48454
|
const current = /* @__PURE__ */ new Map();
|
|
48013
48455
|
for (const e of cache) if (e.stage === 0) current.set(e.path, e);
|
|
48456
|
+
const fsm = await this.fsmonitorRefresh(this.staging);
|
|
48457
|
+
const validMoves = [];
|
|
48014
48458
|
const dirtyPaths = [];
|
|
48015
48459
|
let gitmodulesModified = false;
|
|
48016
48460
|
let changed = false;
|
|
@@ -48048,13 +48492,22 @@ var MvCommand = class extends GitCommand {
|
|
|
48048
48492
|
...entry,
|
|
48049
48493
|
path: dst
|
|
48050
48494
|
};
|
|
48051
|
-
|
|
48495
|
+
let valid = !!fsm && fsm.state.isValid(entry);
|
|
48496
|
+
if (!entry.skipWorktree && !entry.assumeValid && !valid && !entry.intentToAdd && entry.mode !== FileMode.GITLINK) {
|
|
48052
48497
|
const file = await lstat(dst);
|
|
48053
|
-
if (file &&
|
|
48054
|
-
|
|
48055
|
-
|
|
48056
|
-
|
|
48498
|
+
if (file && isCleanByStat(moved, file, trust, indexTime)) valid = true;
|
|
48499
|
+
else if (file && !await entryModified(worktree, moved, trust, indexTime, true)) {
|
|
48500
|
+
if (basicStatMatches(moved, file, trust)) valid = true;
|
|
48501
|
+
else {
|
|
48502
|
+
moved = {
|
|
48503
|
+
...moved,
|
|
48504
|
+
...entryStatOf(file)
|
|
48505
|
+
};
|
|
48506
|
+
valid = !file.isDirectory && file.mode !== FileMode.SYMLINK;
|
|
48507
|
+
}
|
|
48508
|
+
}
|
|
48057
48509
|
}
|
|
48510
|
+
if (current.has(dst)) valid = false;
|
|
48058
48511
|
let checkout = false;
|
|
48059
48512
|
if (this.sparse && sparseConfig.enabled && sparseConfig.cone) {
|
|
48060
48513
|
if (mode & SPARSE && inSparse(dst)) {
|
|
@@ -48088,6 +48541,7 @@ var MvCommand = class extends GitCommand {
|
|
|
48088
48541
|
const { skipWorktree: _drop, ...rest } = moved;
|
|
48089
48542
|
moved = rest;
|
|
48090
48543
|
}
|
|
48544
|
+
if (fsm && valid) validMoves.push(dst);
|
|
48091
48545
|
current.delete(src);
|
|
48092
48546
|
current.set(dst, moved);
|
|
48093
48547
|
adder.remove(src);
|
|
@@ -48108,7 +48562,12 @@ var MvCommand = class extends GitCommand {
|
|
|
48108
48562
|
result.warnings.push("The following paths have been moved outside the", "sparse-checkout definition but are not sparse due to local", "modifications.", ...dirtyPaths);
|
|
48109
48563
|
if (configBool$1(this.workingCopy, "advice.updateSparsePath", true)) result.warnings.push("hint: To correct the sparsity of these paths, do the following:", "hint: * Use \"git add --sparse <paths>\" to update the index", "hint: * Use \"git sparse-checkout reapply\" to apply the sparsity rules", `hint: Disable this message with "${this.compatibility === "2.43" ? "git config" : "git config set"} advice.updateSparsePath false"`);
|
|
48110
48564
|
}
|
|
48111
|
-
if (changed || gitmodulesModified) await this.writeMoves(adder, worktree, gitmodulesModified)
|
|
48565
|
+
if (changed || gitmodulesModified) await this.writeMoves(adder, worktree, gitmodulesModified, async () => {
|
|
48566
|
+
for (const path of validMoves) {
|
|
48567
|
+
const entry = await this.staging.getEntry(path);
|
|
48568
|
+
if (entry && entry.stage === 0) fsm?.state.markValid(entry);
|
|
48569
|
+
}
|
|
48570
|
+
});
|
|
48112
48571
|
return result;
|
|
48113
48572
|
}
|
|
48114
48573
|
/** The index's entries in its order. */
|
|
@@ -48120,12 +48579,13 @@ var MvCommand = class extends GitCommand {
|
|
|
48120
48579
|
return out;
|
|
48121
48580
|
}
|
|
48122
48581
|
/** `stage_updated_gitmodules` when needed, then the index written. */
|
|
48123
|
-
async writeMoves(adder, worktree, gitmodulesModified) {
|
|
48582
|
+
async writeMoves(adder, worktree, gitmodulesModified, markValid) {
|
|
48124
48583
|
if (gitmodulesModified) {
|
|
48125
48584
|
const entry = await worktree.getEntry(".gitmodules");
|
|
48126
48585
|
if (entry && !entry.isDirectory) await adder.add(worktree, ".gitmodules", entry);
|
|
48127
48586
|
}
|
|
48128
48587
|
await adder.finish();
|
|
48588
|
+
await markValid();
|
|
48129
48589
|
await this.staging.write();
|
|
48130
48590
|
}
|
|
48131
48591
|
/** `checkout_entry` (forced) of the entries moved into the sparse cone. */
|
|
@@ -54083,12 +54543,12 @@ const ERROR = 255;
|
|
|
54083
54543
|
var StepFailed = class extends Error {};
|
|
54084
54544
|
const S_IFMT$2 = 61440;
|
|
54085
54545
|
const S_IFDIR$1 = 16384;
|
|
54086
|
-
const S_IFGITLINK = 57344;
|
|
54546
|
+
const S_IFGITLINK$1 = 57344;
|
|
54087
54547
|
/** git's object_type(mode) */
|
|
54088
54548
|
function modeType(mode) {
|
|
54089
54549
|
const kind = mode & S_IFMT$2;
|
|
54090
54550
|
if (kind === S_IFDIR$1) return "tree";
|
|
54091
|
-
if (kind === S_IFGITLINK) return "commit";
|
|
54551
|
+
if (kind === S_IFGITLINK$1) return "commit";
|
|
54092
54552
|
return "blob";
|
|
54093
54553
|
}
|
|
54094
54554
|
/**
|
|
@@ -54244,7 +54704,9 @@ var ReplaceCommand = class extends PlumbingCommand {
|
|
|
54244
54704
|
}
|
|
54245
54705
|
/** repo_get_oid with replace refs off; undefined when it names nothing. */
|
|
54246
54706
|
async getOid(name) {
|
|
54247
|
-
return this.revisionResolver().resolve(name).catch(() =>
|
|
54707
|
+
return this.revisionResolver().resolve(name).catch((e) => {
|
|
54708
|
+
if (e instanceof CorruptTreeError) throw e;
|
|
54709
|
+
});
|
|
54248
54710
|
}
|
|
54249
54711
|
/** odb_read_object_info: the object's type, undefined when it is missing. */
|
|
54250
54712
|
async typeOf(id) {
|
|
@@ -54408,9 +54870,15 @@ var ReplaceCommand = class extends PlumbingCommand {
|
|
|
54408
54870
|
const entries = await this.listedTreeEntries(id);
|
|
54409
54871
|
if (!entries) this.fail("cat-file reported failure");
|
|
54410
54872
|
let out = "";
|
|
54411
|
-
|
|
54412
|
-
const
|
|
54413
|
-
|
|
54873
|
+
try {
|
|
54874
|
+
for (const entry of entries) {
|
|
54875
|
+
const mode = entry.mode.toString(8).padStart(6, "0");
|
|
54876
|
+
out += `${mode} ${modeType(entry.mode)} ${entry.id}\t${quotePath(entry.name, quoteFully)}\n`;
|
|
54877
|
+
}
|
|
54878
|
+
} catch (e) {
|
|
54879
|
+
if (!(e instanceof CorruptTreeError)) throw e;
|
|
54880
|
+
this.warn(e.message);
|
|
54881
|
+
this.fail("cat-file reported failure");
|
|
54414
54882
|
}
|
|
54415
54883
|
return encodeGitPath(out);
|
|
54416
54884
|
}
|
|
@@ -54469,7 +54937,7 @@ var ReplaceCommand = class extends PlumbingCommand {
|
|
|
54469
54937
|
const oid = id.toLowerCase();
|
|
54470
54938
|
const actual = await this.typeOf(oid);
|
|
54471
54939
|
if (actual === void 0) {
|
|
54472
|
-
if ((mode & S_IFMT$2) !== S_IFGITLINK) die(`entry '${path}' object ${oid} is unavailable`);
|
|
54940
|
+
if ((mode & S_IFMT$2) !== S_IFGITLINK$1) die(`entry '${path}' object ${oid} is unavailable`);
|
|
54473
54941
|
} else if (actual !== expected) die(`entry '${path}' object ${oid} is a ${actual} but specified type was (${expected})`);
|
|
54474
54942
|
if (path.includes("/")) die(`path ${path} contains slash`);
|
|
54475
54943
|
entries.push({
|
|
@@ -55313,7 +55781,7 @@ function gitRelativePath(input, prefix) {
|
|
|
55313
55781
|
}
|
|
55314
55782
|
const relativeTo = (facts, path) => {
|
|
55315
55783
|
if (path === void 0) return "";
|
|
55316
|
-
const base = facts.workTree ?? facts.gitDir ?? "";
|
|
55784
|
+
const base = facts.setupDirectory ?? facts.workTree ?? facts.gitDir ?? "";
|
|
55317
55785
|
return gitRelativePath(path, facts.prefix ? `${base}/${facts.prefix}` : base);
|
|
55318
55786
|
};
|
|
55319
55787
|
const COMMON_FIELDS = [
|
|
@@ -55362,11 +55830,19 @@ function hostPathOf$1(files, path) {
|
|
|
55362
55830
|
* `git repo info [--format=(lines|nul) | -z] [--all | <key>...]` and `git repo info --keys`.
|
|
55363
55831
|
*
|
|
55364
55832
|
* Paths are host paths: the FilesApi's root directory joined with its paths, resolved through
|
|
55365
|
-
* the host's `realPath`; without a root directory the path keys are empty.
|
|
55366
|
-
*
|
|
55367
|
-
*
|
|
55368
|
-
*
|
|
55369
|
-
*
|
|
55833
|
+
* the host's `realPath`; without a root directory the path keys are empty. The git directory
|
|
55834
|
+
* and worktree are the working copy's: open it where git's setup puts them
|
|
55835
|
+
* (`openRepositoryFromEnvironment` for `$GIT_DIR`/`$GIT_WORK_TREE`) and pass its `prefix` to
|
|
55836
|
+
* {@link setCurrentDirectory}, and the setup's current directory (`setup.cwd`, as a host path)
|
|
55837
|
+
* to {@link setSetupDirectory}; `$GIT_COMMON_DIR` and `$GIT_INDEX_FILE` are read from the host
|
|
55838
|
+
* environment. Relative keys are relative to the setup directory plus the prefix, and a relative
|
|
55839
|
+
* `$GIT_INDEX_FILE` is read in the setup directory (the worktree top, else where git started:
|
|
55840
|
+
* outside the worktree, or with a bare `$GIT_DIR`). Without a setup directory git is taken to
|
|
55841
|
+
* have gone to the worktree top (the git directory when bare), and a relative index is the
|
|
55842
|
+
* file the working copy's staging opened.
|
|
55843
|
+
* `path.superprojectworkingtree.*` is submodule.c's `get_superproject_working_tree`: the
|
|
55844
|
+
* repository of the worktree's parent directory (reached through `hostFilesOf`, else the
|
|
55845
|
+
* FilesApi) must hold a gitlink at the worktree's path in its index.
|
|
55370
55846
|
*/
|
|
55371
55847
|
var RepoInfoCommand = class extends PlumbingCommand {
|
|
55372
55848
|
format = "lines";
|
|
@@ -55375,6 +55851,7 @@ var RepoInfoCommand = class extends PlumbingCommand {
|
|
|
55375
55851
|
keys = [];
|
|
55376
55852
|
compatibility = "2.57";
|
|
55377
55853
|
currentDirectory = "";
|
|
55854
|
+
setupDirectory;
|
|
55378
55855
|
/** `--format=<format>` (`lines`, `nul`; `table` is refused when printing values) */
|
|
55379
55856
|
setFormat(format) {
|
|
55380
55857
|
this.checkCallable();
|
|
@@ -55420,6 +55897,15 @@ var RepoInfoCommand = class extends PlumbingCommand {
|
|
|
55420
55897
|
this.currentDirectory = path.replace(/^\/+|\/+$/g, "");
|
|
55421
55898
|
return this;
|
|
55422
55899
|
}
|
|
55900
|
+
/**
|
|
55901
|
+
* The directory git's setup went to, as a host path (`setupGitDirectory`'s `cwd` joined to
|
|
55902
|
+
* the FilesApi's root): the worktree top when git started inside it, else where it started.
|
|
55903
|
+
*/
|
|
55904
|
+
setSetupDirectory(hostPath) {
|
|
55905
|
+
this.checkCallable();
|
|
55906
|
+
this.setupDirectory = hostPath === void 0 ? void 0 : hostPath.replace(/(.)\/+$/, "$1");
|
|
55907
|
+
return this;
|
|
55908
|
+
}
|
|
55423
55909
|
async run() {
|
|
55424
55910
|
const format = parseFormat(this.format.replace(/^!/, ""));
|
|
55425
55911
|
const fields = infoFields(this.compatibility);
|
|
@@ -55467,7 +55953,8 @@ var RepoInfoCommand = class extends PlumbingCommand {
|
|
|
55467
55953
|
shallow: shallow.length > 0,
|
|
55468
55954
|
objectFormat: this.objectFormat.name,
|
|
55469
55955
|
refStorage,
|
|
55470
|
-
prefix: this.currentDirectory ? `${this.currentDirectory}/` : ""
|
|
55956
|
+
prefix: this.currentDirectory ? `${this.currentDirectory}/` : "",
|
|
55957
|
+
setupDirectory: await real(this.setupDirectory)
|
|
55471
55958
|
};
|
|
55472
55959
|
if (!layout) return facts;
|
|
55473
55960
|
const files = layout.files;
|
|
@@ -55476,27 +55963,77 @@ var RepoInfoCommand = class extends PlumbingCommand {
|
|
|
55476
55963
|
const named = commondirFile ? new TextDecoder().decode(commondirFile).trim() : void 0;
|
|
55477
55964
|
facts.commonDir = environment?.commonDir ? await real(environment.commonDir) : named ? await real(named.startsWith("/") ? named : `${facts.gitDir}/${named}`) : facts.gitDir;
|
|
55478
55965
|
const indexFile = environment?.indexFile;
|
|
55479
|
-
|
|
55966
|
+
const location = indexFile && !indexFile.startsWith("/") && facts.setupDirectory === void 0 ? this.indexLocation() : void 0;
|
|
55967
|
+
facts.index = indexFile === void 0 ? facts.gitDir ? `${facts.gitDir}/index` : void 0 : indexFile.startsWith("/") ? indexFile : facts.setupDirectory !== void 0 ? `${facts.setupDirectory.replace(/\/$/, "")}/${indexFile}` : await real(location ? hostPathOf$1(location.files, location.path) : `${hostPathOf$1(files, layout.bare ? layout.gitDir : layout.top) ?? ""}/${indexFile}`);
|
|
55480
55968
|
if (!layout.bare) {
|
|
55481
55969
|
facts.workTree = await real(hostPathOf$1(files, layout.top));
|
|
55482
|
-
facts.superproject = await this.superprojectOf(
|
|
55970
|
+
facts.superproject = await this.superprojectOf(files, layout.top, facts.workTree);
|
|
55483
55971
|
}
|
|
55484
55972
|
return facts;
|
|
55485
55973
|
}
|
|
55486
|
-
/**
|
|
55487
|
-
|
|
55488
|
-
|
|
55489
|
-
|
|
55490
|
-
|
|
55491
|
-
|
|
55492
|
-
|
|
55974
|
+
/** The index file of the working copy's staging; undefined without one (bare, memory). */
|
|
55975
|
+
indexLocation() {
|
|
55976
|
+
try {
|
|
55977
|
+
return this.resolveStaging().indexLocation?.();
|
|
55978
|
+
} catch {
|
|
55979
|
+
return;
|
|
55980
|
+
}
|
|
55981
|
+
}
|
|
55982
|
+
/**
|
|
55983
|
+
* submodule.c's `get_superproject_working_tree`: the repository found from the directory
|
|
55984
|
+
* above the worktree (discovered as git's child `git -C <parent> ls-files` discovers it,
|
|
55985
|
+
* the repository variables cleared) must hold a gitlink at the worktree's path in its
|
|
55986
|
+
* index; the superproject is the worktree less that path. Whatever the submodule's git
|
|
55987
|
+
* directory is (embedded `.git`, `.git/modules/<name>`, a linked worktree's modules).
|
|
55988
|
+
*/
|
|
55989
|
+
async superprojectOf(files, top, workTree) {
|
|
55990
|
+
if (!workTree) return void 0;
|
|
55493
55991
|
const environment = hostEnvironmentOf(this.workingCopy);
|
|
55494
|
-
|
|
55495
|
-
|
|
55992
|
+
const real = async (path) => await environment?.realPath?.(path).catch(() => void 0) ?? path;
|
|
55993
|
+
const oneUp = await real(parentHostPath(workTree));
|
|
55994
|
+
const subpath = gitRelativePath(workTree, oneUp).replace(/\/$/, "");
|
|
55995
|
+
if (!subpath || subpath === "./" || subpath.startsWith("../")) return void 0;
|
|
55996
|
+
const host = await environment?.hostFilesOf?.(oneUp).catch(() => void 0);
|
|
55997
|
+
const parent = host ? {
|
|
55998
|
+
files: host.files,
|
|
55999
|
+
cwd: host.path
|
|
56000
|
+
} : top ? {
|
|
56001
|
+
files,
|
|
56002
|
+
cwd: normalizePath(top.slice(0, Math.max(0, top.lastIndexOf("/"))))
|
|
56003
|
+
} : void 0;
|
|
56004
|
+
if (!parent) return void 0;
|
|
56005
|
+
const { gitDir: _gitDir, workTree: _workTree, commonDir: _commonDir, indexFile: _indexFile, objectDirectory: _objectDirectory, implicitWorkTree: _implicitWorkTree, ...childEnvironment } = environment ?? {};
|
|
56006
|
+
let setup;
|
|
56007
|
+
try {
|
|
56008
|
+
setup = await setupGitDirectory({
|
|
56009
|
+
files: parent.files,
|
|
56010
|
+
cwd: parent.cwd,
|
|
56011
|
+
...environment ? { environment: childEnvironment } : {}
|
|
56012
|
+
});
|
|
56013
|
+
} catch {
|
|
56014
|
+
return;
|
|
55496
56015
|
}
|
|
55497
|
-
return
|
|
56016
|
+
if (setup.workTree === void 0) return void 0;
|
|
56017
|
+
const format = await readRepositoryFormat(parent.files, setup.commonDir).catch(() => void 0);
|
|
56018
|
+
const index = await readIndexFileEntries(parent.files, setup.indexFile, {
|
|
56019
|
+
gitDir: setup.gitDir,
|
|
56020
|
+
...format ? { objectFormat: format.objectFormat } : {}
|
|
56021
|
+
}).catch(() => void 0);
|
|
56022
|
+
if (!index) return void 0;
|
|
56023
|
+
const fullName = `${setup.prefix ?? ""}${subpath}`;
|
|
56024
|
+
const first = index.entries.find((e) => e.path === fullName || e.path.startsWith(`${fullName}/`));
|
|
56025
|
+
if (!first || first.mode !== S_IFGITLINK) return void 0;
|
|
56026
|
+
if (!workTree.endsWith(`/${fullName}`)) return void 0;
|
|
56027
|
+
return real(workTree.slice(0, workTree.length - fullName.length - 1) || "/");
|
|
55498
56028
|
}
|
|
55499
56029
|
};
|
|
56030
|
+
const S_IFGITLINK = 57344;
|
|
56031
|
+
/** The host directory holding `path` (`/a/b` → `/a`). */
|
|
56032
|
+
function parentHostPath(path) {
|
|
56033
|
+
const trimmed = path.replace(/\/+$/, "");
|
|
56034
|
+
const at = trimmed.lastIndexOf("/");
|
|
56035
|
+
return at <= 0 ? "/" : trimmed.slice(0, at);
|
|
56036
|
+
}
|
|
55500
56037
|
const emptyValues = () => ({
|
|
55501
56038
|
commits: 0,
|
|
55502
56039
|
trees: 0,
|
|
@@ -56736,6 +57273,20 @@ var RerereCommand = class extends GitCommand {
|
|
|
56736
57273
|
this.autoUpdate = value;
|
|
56737
57274
|
return this;
|
|
56738
57275
|
}
|
|
57276
|
+
/**
|
|
57277
|
+
* git's rerere for a resolution store (vcs-store-files `GitResolutionStore`): its records
|
|
57278
|
+
* written and replayed as `git rerere` does ({@link rerereEngineOf}); undefined without a
|
|
57279
|
+
* worktree. Give the store the index this command reads (`workingCopy.checkout.staging`).
|
|
57280
|
+
*
|
|
57281
|
+
* @example
|
|
57282
|
+
* ```typescript
|
|
57283
|
+
* const store = createResolutionStore(files, staging, blobs, ".git", "", git.rerere().engine());
|
|
57284
|
+
* ```
|
|
57285
|
+
*/
|
|
57286
|
+
engine() {
|
|
57287
|
+
const host = this.rerereHost();
|
|
57288
|
+
return host && rerereEngineOf(host);
|
|
57289
|
+
}
|
|
56739
57290
|
async call() {
|
|
56740
57291
|
this.checkCallable();
|
|
56741
57292
|
this.setCallable(false);
|
|
@@ -60610,6 +61161,7 @@ var SubmoduleAddCommand = class extends SubmoduleCommandBase {
|
|
|
60610
61161
|
force = false;
|
|
60611
61162
|
reference;
|
|
60612
61163
|
depth;
|
|
61164
|
+
objectStorageFormat;
|
|
60613
61165
|
transports;
|
|
60614
61166
|
credentialHelper;
|
|
60615
61167
|
warningCallback;
|
|
@@ -60649,6 +61201,16 @@ var SubmoduleAddCommand = class extends SubmoduleCommandBase {
|
|
|
60649
61201
|
this.reference = reference;
|
|
60650
61202
|
return this;
|
|
60651
61203
|
}
|
|
61204
|
+
/**
|
|
61205
|
+
* `--object-storage-format=<name>` (git master): the object storage of the submodules
|
|
61206
|
+
* cloned. Only `files` is a name git knows (the repository as always); anything else,
|
|
61207
|
+
* `files://<dir>` included, dies `unknown object storage format '<v>'` before any work.
|
|
61208
|
+
*/
|
|
61209
|
+
setObjectStorageFormat(format) {
|
|
61210
|
+
this.checkCallable();
|
|
61211
|
+
this.objectStorageFormat = format;
|
|
61212
|
+
return this;
|
|
61213
|
+
}
|
|
60652
61214
|
/** `--depth <n>`: a shallow clone (ignored, with git's warning, for a local path). */
|
|
60653
61215
|
setDepth(depth) {
|
|
60654
61216
|
this.checkCallable();
|
|
@@ -60678,6 +61240,10 @@ var SubmoduleAddCommand = class extends SubmoduleCommandBase {
|
|
|
60678
61240
|
}
|
|
60679
61241
|
async call() {
|
|
60680
61242
|
this.start();
|
|
61243
|
+
if (this.objectStorageFormat !== void 0) {
|
|
61244
|
+
const unknown = unknownObjectStorageFormat(this.objectStorageFormat, "name");
|
|
61245
|
+
if (unknown) this.die(unknown);
|
|
61246
|
+
}
|
|
60681
61247
|
if (!await this.writingGitmodulesOk()) this.die("fatal: please make sure that the .gitmodules file is in the working tree");
|
|
60682
61248
|
if (this.uri === void 0) this.die(ADD_USAGE, 129);
|
|
60683
61249
|
const repo = this.uri;
|
|
@@ -61543,8 +62109,13 @@ var TagCommand = class extends GitCommand {
|
|
|
61543
62109
|
message
|
|
61544
62110
|
};
|
|
61545
62111
|
if (sign) {
|
|
61546
|
-
const
|
|
61547
|
-
|
|
62112
|
+
const payload = await collectTagBytes(tag);
|
|
62113
|
+
const signature = await this.signTag(payload, tagger, compatibility, warnings);
|
|
62114
|
+
if (signature) {
|
|
62115
|
+
tag.message = `${message}${new TextDecoder().decode(signature)}`;
|
|
62116
|
+
const compatSignature = await this.signTag(payload, tagger, compatibility, warnings, { compat: true });
|
|
62117
|
+
if (compatSignature) tag.compatSignature = compatSignature;
|
|
62118
|
+
}
|
|
61548
62119
|
}
|
|
61549
62120
|
tagObjectId = await this.tagsStore.storeTag(tag);
|
|
61550
62121
|
} else tagObjectId = targetId;
|
|
@@ -61633,28 +62204,20 @@ var TagCommand = class extends GitCommand {
|
|
|
61633
62204
|
const message = (await this.tagsStore?.loadTag(prev).catch(() => void 0))?.message ?? "";
|
|
61634
62205
|
return message.slice(0, signatureStart(message));
|
|
61635
62206
|
}
|
|
61636
|
-
|
|
61637
|
-
* builtin/tag.c's `do_sign`: `payload` (the tag object without a signature) signed with the
|
|
61638
|
-
* `-u` key, else `user.signingKey`, else the format's default (`get_signing_key`: ssh's
|
|
61639
|
-
* `gpg.ssh.defaultKeyCommand`, openpgp's and x509's the committer as `Name <email>`), the
|
|
61640
|
-
* program run in the worktree top. A failure is create_tag's: the signer's lines, `error:
|
|
61641
|
-
* unable to sign the tag` and where the message was left (`TAG_EDITMSG` in the git
|
|
61642
|
-
* directory, named as git names it from the top of the worktree: `.git/TAG_EDITMSG`),
|
|
61643
|
-
* exit 128; a death of the signing (ssh without a key) only its `fatal:` line. Under 2.43
|
|
61644
|
-
* an ssh-keygen that ran and failed leaves the tag unsigned, its error in `warnings`
|
|
61645
|
-
* (undefined returned).
|
|
61646
|
-
*/
|
|
61647
|
-
async signTag(payload, tagger, compatibility, warnings) {
|
|
62207
|
+
async signTag(payload, tagger, compatibility, warnings, options) {
|
|
61648
62208
|
const gitDir = (await this.hooks.hostGitDir({ real: false }).catch(() => void 0))?.replace(/\/+$/, "");
|
|
61649
62209
|
const top = (await this.hostWorkingDir())?.replace(/\/+$/, "");
|
|
61650
62210
|
const path = gitDir === void 0 ? ".git/TAG_EDITMSG" : top !== void 0 && gitDir.startsWith(`${top}/`) ? `${gitDir.slice(top.length + 1)}/TAG_EDITMSG` : `${gitDir}/TAG_EDITMSG`;
|
|
61651
62211
|
const cwd = await this.hooks.hostWorkingDirectory().catch(() => void 0);
|
|
61652
62212
|
try {
|
|
61653
|
-
|
|
62213
|
+
const signOptions = {
|
|
61654
62214
|
committer: tagger,
|
|
61655
62215
|
...cwd !== void 0 ? { cwd } : {},
|
|
61656
62216
|
tail: ["error: unable to sign the tag", `The tag message has been left in ${path}`]
|
|
61657
|
-
}
|
|
62217
|
+
};
|
|
62218
|
+
const key = this.signingKey ?? "";
|
|
62219
|
+
if (options?.compat) return await signTagCompat(this.workingCopy, key, payload, signOptions);
|
|
62220
|
+
return await signPayload(this.workingCopy, key, payload, signOptions);
|
|
61658
62221
|
} catch (e) {
|
|
61659
62222
|
if (!(e instanceof SigningFailedError)) throw e;
|
|
61660
62223
|
if (compatibility === "2.43" && (e.programExitCode ?? 0) > 0) {
|
|
@@ -62302,6 +62865,10 @@ function dryRunTarget(objects) {
|
|
|
62302
62865
|
*
|
|
62303
62866
|
* // git update-index --refresh
|
|
62304
62867
|
* const { output, exitCode } = await git.updateIndex().refresh().call();
|
|
62868
|
+
*
|
|
62869
|
+
* // git update-index --fsmonitor, then --fsmonitor-valid a
|
|
62870
|
+
* await git.updateIndex().setFsmonitor(true).call();
|
|
62871
|
+
* await git.updateIndex().setFsmonitorValid(true).addPath("a").call();
|
|
62305
62872
|
* ```
|
|
62306
62873
|
*/
|
|
62307
62874
|
/** A death (`die()`): git's message, without the `fatal: ` prefix. */
|
|
@@ -62350,6 +62917,7 @@ var UpdateIndexCommand = class extends GitCommand {
|
|
|
62350
62917
|
indexVersion;
|
|
62351
62918
|
showIndexVersion = false;
|
|
62352
62919
|
forceWrite = false;
|
|
62920
|
+
fsmonitor;
|
|
62353
62921
|
set(apply) {
|
|
62354
62922
|
this.checkCallable();
|
|
62355
62923
|
this.steps.push({
|
|
@@ -62412,6 +62980,26 @@ var UpdateIndexCommand = class extends GitCommand {
|
|
|
62412
62980
|
s.markSkipWorktree = mark;
|
|
62413
62981
|
});
|
|
62414
62982
|
}
|
|
62983
|
+
/**
|
|
62984
|
+
* `--fsmonitor-valid` (true) / `--no-fsmonitor-valid` (false) for the paths after it: the
|
|
62985
|
+
* entry's fsmonitor valid bit (`CE_FSMONITOR_VALID`) set or cleared.
|
|
62986
|
+
*/
|
|
62987
|
+
setFsmonitorValid(mark) {
|
|
62988
|
+
return this.set((s) => {
|
|
62989
|
+
s.markFsmonitor = mark;
|
|
62990
|
+
});
|
|
62991
|
+
}
|
|
62992
|
+
/**
|
|
62993
|
+
* `--fsmonitor` (true) / `--no-fsmonitor` (false), applied after the paths, as git does:
|
|
62994
|
+
* the index's `FSMN` extension added (`add_fsmonitor`; a warning when `core.fsmonitor` is
|
|
62995
|
+
* unset; git's death in a bare repository with `core.fsmonitor` set) or removed (a warning
|
|
62996
|
+
* when `core.fsmonitor` is set).
|
|
62997
|
+
*/
|
|
62998
|
+
setFsmonitor(enable) {
|
|
62999
|
+
this.checkCallable();
|
|
63000
|
+
this.fsmonitor = enable;
|
|
63001
|
+
return this;
|
|
63002
|
+
}
|
|
62415
63003
|
/** `--ignore-skip-worktree-entries`: `--remove` leaves skip-worktree entries alone. */
|
|
62416
63004
|
setIgnoreSkipWorktreeEntries(ignore = true) {
|
|
62417
63005
|
return this.set((s) => {
|
|
@@ -62523,8 +63111,14 @@ var UpdateIndexCommand = class extends GitCommand {
|
|
|
62523
63111
|
async call() {
|
|
62524
63112
|
this.checkCallable();
|
|
62525
63113
|
this.setCallable(false);
|
|
62526
|
-
|
|
62527
|
-
|
|
63114
|
+
if (this.fsmonitor && !this.hasWorktree()) {
|
|
63115
|
+
if (fsmonitorModeOf(RemoteConfigStore.from(this.workingCopy).value("core.fsmonitor")).kind !== "disabled") throw new UpdateIndexFailedError(`fatal: bare repository '${await this.currentDirectory()}' is incompatible with fsmonitor`);
|
|
63116
|
+
}
|
|
63117
|
+
await this.readCurrentIndex(true, false);
|
|
63118
|
+
const hadFsmonitor = !!this.staging.getFsmonitor?.();
|
|
63119
|
+
const fsm = await this.fsmonitorRefresh(this.staging);
|
|
63120
|
+
const run = new UpdateIndexRun(this.context(fsm?.state));
|
|
63121
|
+
for (const warning of fsm?.warnings ?? []) run.stderr.push(`warning: ${warning}`);
|
|
62528
63122
|
try {
|
|
62529
63123
|
await this.inOneOperation(async () => {
|
|
62530
63124
|
for (const step of this.steps) await run.step(step);
|
|
@@ -62536,12 +63130,15 @@ var UpdateIndexCommand = class extends GitCommand {
|
|
|
62536
63130
|
};
|
|
62537
63131
|
for (const path of inputPaths(this.stdinPaths, this.nulTerminated, badlyQuoted)) await run.updateOne(path);
|
|
62538
63132
|
}
|
|
63133
|
+
await this.applyFsmonitor(run);
|
|
62539
63134
|
});
|
|
62540
63135
|
} catch (error) {
|
|
62541
63136
|
if (error instanceof Death) throw new UpdateIndexFailedError([...run.stderr, `fatal: ${error.message}`].join("\n"), run.stdout.join(""));
|
|
62542
63137
|
throw error;
|
|
62543
63138
|
}
|
|
62544
|
-
|
|
63139
|
+
const fsmonitorNow = this.staging.getFsmonitor?.();
|
|
63140
|
+
const fsmonitorChanged = !!fsmonitorNow?.changed || hadFsmonitor && !fsmonitorNow;
|
|
63141
|
+
if (run.changed || this.forceWrite || fsmonitorChanged) try {
|
|
62545
63142
|
await run.write();
|
|
62546
63143
|
} catch (error) {
|
|
62547
63144
|
if (error instanceof Death) throw new UpdateIndexFailedError([...run.stderr, `fatal: ${error.message}`].join("\n"), run.stdout.join(""));
|
|
@@ -62553,6 +63150,37 @@ var UpdateIndexCommand = class extends GitCommand {
|
|
|
62553
63150
|
exitCode: run.hasErrors ? 1 : 0
|
|
62554
63151
|
};
|
|
62555
63152
|
}
|
|
63153
|
+
/** `--[no-]fsmonitor`: `add_fsmonitor` / `remove_fsmonitor` and their warnings. */
|
|
63154
|
+
async applyFsmonitor(run) {
|
|
63155
|
+
if (this.fsmonitor === void 0) return;
|
|
63156
|
+
const mode = fsmonitorModeOf(RemoteConfigStore.from(this.workingCopy).value("core.fsmonitor"));
|
|
63157
|
+
const staging = this.staging;
|
|
63158
|
+
if (this.fsmonitor) {
|
|
63159
|
+
if (mode.kind === "disabled") run.stderr.push("warning: core.fsmonitor is unset; set it if you really want to enable fsmonitor");
|
|
63160
|
+
if (!staging.getFsmonitor?.() && staging.setFsmonitor) {
|
|
63161
|
+
const state = new FsmonitorState(String(BigInt(Date.now()) * 1000000n));
|
|
63162
|
+
state.changed = true;
|
|
63163
|
+
state.writtenWhileDisabled = mode.kind === "disabled";
|
|
63164
|
+
staging.setFsmonitor(state);
|
|
63165
|
+
}
|
|
63166
|
+
run.report("fsmonitor enabled");
|
|
63167
|
+
} else {
|
|
63168
|
+
if (mode.kind !== "disabled" && this.hasWorktree()) run.stderr.push("warning: core.fsmonitor is set; remove it if you really want to disable fsmonitor");
|
|
63169
|
+
staging.setFsmonitor?.(void 0);
|
|
63170
|
+
run.report("fsmonitor disabled");
|
|
63171
|
+
}
|
|
63172
|
+
}
|
|
63173
|
+
/** git's `xgetcwd()` for a bare repository: the git directory's host path. */
|
|
63174
|
+
async currentDirectory() {
|
|
63175
|
+
const layout = await hookHostOf(this.workingCopy).layout();
|
|
63176
|
+
if (!layout) return ".";
|
|
63177
|
+
const root = layout.files.rootDirectory;
|
|
63178
|
+
if (!root) return layout.gitDir;
|
|
63179
|
+
const base = root.replace(/\/+$/, "");
|
|
63180
|
+
const rest = layout.gitDir.replace(/^\.?\/*|\/+$/g, "");
|
|
63181
|
+
const path = rest ? `${base}/${rest}` : base || "/";
|
|
63182
|
+
return await hostEnvironmentOf(this.workingCopy)?.realPath?.(path).catch(() => void 0) ?? path;
|
|
63183
|
+
}
|
|
62556
63184
|
applyIndexVersion(run) {
|
|
62557
63185
|
const staging = this.staging;
|
|
62558
63186
|
const current = staging._getVersion?.() ?? 2;
|
|
@@ -62565,9 +63193,10 @@ var UpdateIndexCommand = class extends GitCommand {
|
|
|
62565
63193
|
run.version = wanted;
|
|
62566
63194
|
if (staging._setVersion) run.setVersion = (v) => staging._setVersion?.(v);
|
|
62567
63195
|
}
|
|
62568
|
-
context() {
|
|
63196
|
+
context(fsmonitor) {
|
|
62569
63197
|
const worktree = this.worktreeAccess;
|
|
62570
63198
|
return {
|
|
63199
|
+
fsmonitor,
|
|
62571
63200
|
staging: this.staging,
|
|
62572
63201
|
worktree,
|
|
62573
63202
|
blobs: this.blobs,
|
|
@@ -62770,7 +63399,7 @@ var UpdateIndexRun = class {
|
|
|
62770
63399
|
async updateOne(path) {
|
|
62771
63400
|
await this.load();
|
|
62772
63401
|
const s = this.state;
|
|
62773
|
-
const markOnly = s.markValid !== void 0 || s.markSkipWorktree !== void 0;
|
|
63402
|
+
const markOnly = s.markValid !== void 0 || s.markSkipWorktree !== void 0 || s.markFsmonitor !== void 0;
|
|
62774
63403
|
let current;
|
|
62775
63404
|
let missing = false;
|
|
62776
63405
|
let mode = 0;
|
|
@@ -62791,6 +63420,10 @@ var UpdateIndexRun = class {
|
|
|
62791
63420
|
if (!this.markFlags(path, "skipWorktree", s.markSkipWorktree)) throw new Death(`Unable to mark file ${path}`);
|
|
62792
63421
|
return this.chmodAfter(path);
|
|
62793
63422
|
}
|
|
63423
|
+
if (s.markFsmonitor !== void 0) {
|
|
63424
|
+
if (!this.markFsmonitor(path, s.markFsmonitor)) throw new Death(`Unable to mark file ${path}`);
|
|
63425
|
+
return this.chmodAfter(path);
|
|
63426
|
+
}
|
|
62794
63427
|
if (s.forceRemove) {
|
|
62795
63428
|
this.removeFile(path);
|
|
62796
63429
|
this.report(`remove '${path}'`);
|
|
@@ -62829,6 +63462,20 @@ var UpdateIndexRun = class {
|
|
|
62829
63462
|
this.changed = true;
|
|
62830
63463
|
return true;
|
|
62831
63464
|
}
|
|
63465
|
+
/** `mark_ce_flags` with `CE_FSMONITOR_VALID`: false when the path has no stage-0 entry. */
|
|
63466
|
+
markFsmonitor(path, mark) {
|
|
63467
|
+
const pos = this.namePos(path);
|
|
63468
|
+
if (pos < 0) return false;
|
|
63469
|
+
const ce = this.entries[pos];
|
|
63470
|
+
const state = this.ctx.fsmonitor;
|
|
63471
|
+
if (state) {
|
|
63472
|
+
state.markInvalid(ce);
|
|
63473
|
+
if (mark) state.markValid(ce, { gitlinks: true });
|
|
63474
|
+
}
|
|
63475
|
+
this.invalidate(path);
|
|
63476
|
+
this.changed = true;
|
|
63477
|
+
return true;
|
|
63478
|
+
}
|
|
62832
63479
|
/** `remove_one_path`. */
|
|
62833
63480
|
removeOnePath(path) {
|
|
62834
63481
|
if (!this.state.remove) {
|
|
@@ -63016,6 +63663,7 @@ var UpdateIndexRun = class {
|
|
|
63016
63663
|
const worktree = this.ctx.worktree;
|
|
63017
63664
|
if (!worktree) return;
|
|
63018
63665
|
const trust = this.ctx.trust;
|
|
63666
|
+
const fsmonitor = this.ctx.fsmonitor;
|
|
63019
63667
|
for (let i = 0; i < this.entries.length; i++) {
|
|
63020
63668
|
const ce = this.entries[i];
|
|
63021
63669
|
if (s.ignoreSubmodules && ce.mode === FileMode.GITLINK) continue;
|
|
@@ -63029,6 +63677,7 @@ var UpdateIndexRun = class {
|
|
|
63029
63677
|
}
|
|
63030
63678
|
if (ce.skipWorktree) continue;
|
|
63031
63679
|
if (!really && ce.assumeValid) continue;
|
|
63680
|
+
if (fsmonitor?.isValid(ce)) continue;
|
|
63032
63681
|
const current = await worktree.getEntry(ce.path).catch(() => void 0);
|
|
63033
63682
|
if (!current && s.ignoreMissing) continue;
|
|
63034
63683
|
let changed;
|
|
@@ -63062,7 +63711,7 @@ var UpdateIndexRun = class {
|
|
|
63062
63711
|
if (fresh && !sameStat(fresh, ce)) {
|
|
63063
63712
|
this.entries[i] = fresh;
|
|
63064
63713
|
this.changed = true;
|
|
63065
|
-
}
|
|
63714
|
+
} else fsmonitor?.markValid(ce);
|
|
63066
63715
|
}
|
|
63067
63716
|
for (const ce of this.entries) {
|
|
63068
63717
|
if (ce.stage !== 0) continue;
|