@gitkraken/core-gitlens 0.37.1 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/CHANGELOG.md +60 -1
  2. package/dist/git/cache.d.ts +128 -8
  3. package/dist/git/cache.js +425 -46
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/features.d.ts +1 -1
  6. package/dist/git/features.js +3 -0
  7. package/dist/git/features.js.map +1 -1
  8. package/dist/git/providers/branches.d.ts +42 -1
  9. package/dist/git/providers/diff.d.ts +17 -0
  10. package/dist/git/providers/provider.d.ts +7 -0
  11. package/dist/git/providers/shared/remotes.js +8 -4
  12. package/dist/git/providers/shared/remotes.js.map +1 -1
  13. package/dist/git/remotes/matcher.js +2 -2
  14. package/dist/git/remotes/matcher.js.map +1 -1
  15. package/dist/git/repositoryService.d.ts +16 -1
  16. package/dist/git/repositoryService.js +51 -3
  17. package/dist/git/repositoryService.js.map +1 -1
  18. package/dist/git/run.types.d.ts +1 -0
  19. package/dist/git/service.js +6 -2
  20. package/dist/git/service.js.map +1 -1
  21. package/dist/git/utils/fileStatus.utils.d.ts +5 -0
  22. package/dist/git/utils/fileStatus.utils.js +18 -1
  23. package/dist/git/utils/fileStatus.utils.js.map +1 -1
  24. package/dist/git/watching/changeEvent.d.ts +13 -3
  25. package/dist/git/watching/changeEvent.js +15 -4
  26. package/dist/git/watching/changeEvent.js.map +1 -1
  27. package/dist/git/watching/changeOrdinal.d.ts +9 -0
  28. package/dist/git/watching/changeOrdinal.js +14 -0
  29. package/dist/git/watching/changeOrdinal.js.map +1 -0
  30. package/dist/git/watching/unwatchedCacheValidator.d.ts +38 -5
  31. package/dist/git/watching/unwatchedCacheValidator.js +180 -36
  32. package/dist/git/watching/unwatchedCacheValidator.js.map +1 -1
  33. package/dist/git/watching/watchGroup.d.ts +63 -14
  34. package/dist/git/watching/watchGroup.js +213 -74
  35. package/dist/git/watching/watchGroup.js.map +1 -1
  36. package/dist/git/watching/watchService.js +4 -3
  37. package/dist/git/watching/watchService.js.map +1 -1
  38. package/dist/git/watching/watchSession.d.ts +10 -2
  39. package/dist/git/watching/watchSession.js +18 -4
  40. package/dist/git/watching/watchSession.js.map +1 -1
  41. package/dist/git/watching/watcherPatterns.d.ts +18 -4
  42. package/dist/git/watching/watcherPatterns.js +39 -8
  43. package/dist/git/watching/watcherPatterns.js.map +1 -1
  44. package/dist/git/watching/worktreeSummary.d.ts +23 -12
  45. package/dist/git/watching/worktreeSummary.js +164 -41
  46. package/dist/git/watching/worktreeSummary.js.map +1 -1
  47. package/dist/git-cli/cliGitProvider.d.ts +1 -0
  48. package/dist/git-cli/cliGitProvider.js +11 -2
  49. package/dist/git-cli/cliGitProvider.js.map +1 -1
  50. package/dist/git-cli/exec/git.d.ts +7 -2
  51. package/dist/git-cli/exec/git.js +46 -10
  52. package/dist/git-cli/exec/git.js.map +1 -1
  53. package/dist/git-cli/exec/headState.d.ts +24 -0
  54. package/dist/git-cli/exec/headState.js +46 -6
  55. package/dist/git-cli/exec/headState.js.map +1 -1
  56. package/dist/git-cli/parsers/logParser.js +6 -3
  57. package/dist/git-cli/parsers/logParser.js.map +1 -1
  58. package/dist/git-cli/providers/branches.d.ts +135 -10
  59. package/dist/git-cli/providers/branches.js +622 -80
  60. package/dist/git-cli/providers/branches.js.map +1 -1
  61. package/dist/git-cli/providers/commits.d.ts +16 -0
  62. package/dist/git-cli/providers/commits.js +80 -28
  63. package/dist/git-cli/providers/commits.js.map +1 -1
  64. package/dist/git-cli/providers/config.d.ts +10 -0
  65. package/dist/git-cli/providers/config.js +50 -12
  66. package/dist/git-cli/providers/config.js.map +1 -1
  67. package/dist/git-cli/providers/contributors.js +11 -7
  68. package/dist/git-cli/providers/contributors.js.map +1 -1
  69. package/dist/git-cli/providers/diff.d.ts +12 -0
  70. package/dist/git-cli/providers/diff.js +107 -15
  71. package/dist/git-cli/providers/diff.js.map +1 -1
  72. package/dist/git-cli/providers/graph.js +32 -25
  73. package/dist/git-cli/providers/graph.js.map +1 -1
  74. package/dist/git-cli/providers/operations.d.ts +37 -3
  75. package/dist/git-cli/providers/operations.js +124 -46
  76. package/dist/git-cli/providers/operations.js.map +1 -1
  77. package/dist/git-cli/providers/patch.js +1 -1
  78. package/dist/git-cli/providers/patch.js.map +1 -1
  79. package/dist/git-cli/providers/refs.d.ts +1 -1
  80. package/dist/git-cli/providers/refs.js +10 -11
  81. package/dist/git-cli/providers/refs.js.map +1 -1
  82. package/dist/git-cli/providers/status.d.ts +4 -5
  83. package/dist/git-cli/providers/status.js +36 -33
  84. package/dist/git-cli/providers/status.js.map +1 -1
  85. package/dist/git-cli/providers/tags.d.ts +8 -0
  86. package/dist/git-cli/providers/tags.js +53 -34
  87. package/dist/git-cli/providers/tags.js.map +1 -1
  88. package/dist/git-cli/service.d.ts +15 -0
  89. package/dist/git-cli/service.js +19 -1
  90. package/dist/git-cli/service.js.map +1 -1
  91. package/dist/plus/git-github/providers/github/diff.d.ts +1 -0
  92. package/dist/plus/git-github/providers/github/diff.js +6 -1
  93. package/dist/plus/git-github/providers/github/diff.js.map +1 -1
  94. package/dist/plus/integrations/integrationService.js +9 -0
  95. package/dist/plus/integrations/integrationService.js.map +1 -1
  96. package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
  97. package/dist/plus/integrations/providers/jira-server.js +1 -1
  98. package/dist/plus/integrations/providers/jira-server.js.map +1 -1
  99. package/dist/plus/integrations/providers/jira.d.ts +38 -6
  100. package/dist/plus/integrations/providers/jira.js +111 -69
  101. package/dist/plus/integrations/providers/jira.js.map +1 -1
  102. package/dist/plus/integrations/providers/linear.d.ts +31 -3
  103. package/dist/plus/integrations/providers/linear.js +77 -18
  104. package/dist/plus/integrations/providers/linear.js.map +1 -1
  105. package/dist/plus/integrations/providers/utils/discoveryCache.d.ts +41 -4
  106. package/dist/plus/integrations/providers/utils/discoveryCache.js +50 -11
  107. package/dist/plus/integrations/providers/utils/discoveryCache.js.map +1 -1
  108. package/dist/plus/integrations/reads/drains.d.ts +1 -0
  109. package/dist/utils/env/node/exec.d.ts +5 -4
  110. package/dist/utils/env/node/exec.js +52 -9
  111. package/dist/utils/env/node/exec.js.map +1 -1
  112. package/dist/utils/holdOffMap.d.ts +23 -0
  113. package/dist/utils/holdOffMap.js +43 -0
  114. package/dist/utils/holdOffMap.js.map +1 -0
  115. package/dist/utils/promiseCache.d.ts +15 -2
  116. package/dist/utils/promiseCache.js +34 -4
  117. package/dist/utils/promiseCache.js.map +1 -1
  118. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"operations.js","names":[],"sources":["../../../../git-cli/src/providers/operations.ts"],"sourcesContent":["import * as l10n from '@vscode/l10n';\nimport type { Cache } from '@gitlens/git/cache.js';\nimport type { GitConflictCommand, GitServiceContext } from '@gitlens/git/context.js';\nimport {\n\tCheckoutError,\n\tCherryPickError,\n\tCommitError,\n\tFetchError,\n\tMergeError,\n\tPullError,\n\tPushError,\n\tRebaseError,\n\tResetError,\n\tRevertError,\n\tSigningError,\n} from '@gitlens/git/errors.js';\nimport type { GitBranchReference, GitReference } from '@gitlens/git/models/reference.js';\nimport type { RepositoryChange } from '@gitlens/git/models/repository.js';\nimport type { SigningFormat } from '@gitlens/git/models/signature.js';\nimport type { GitConflictFile } from '@gitlens/git/models/staging.js';\nimport type {\n\tGitOperationResult,\n\tGitOperationRunOptions,\n\tGitOperationsSubProvider,\n} from '@gitlens/git/providers/operations.js';\nimport { isBranchReference } from '@gitlens/git/utils/reference.utils.js';\nimport { getRefChangeKind } from '@gitlens/git/watching/changeEvent.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { sequentialize } from '@gitlens/utils/decorators/sequentialize.js';\nimport { chunkByStringLength } from '@gitlens/utils/iterable.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { normalizePath, splitPath } from '@gitlens/utils/path.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport { mayWriteTracking } from '../exec/commandClassifier.js';\nimport type { Git, PushForceOptions } from '../exec/git.js';\nimport {\n\tclassifySigningError,\n\tgetGitCommandError,\n\tgitConfigsPull,\n\tGitErrors,\n\tinferSigningFormatFromError,\n\tisRunHookFailure,\n\tmaxGitCliLength,\n} from '../exec/git.js';\nimport type { HeadState } from '../exec/headState.js';\nimport { getMovedHead, readHeadState } from '../exec/headState.js';\nimport type { IndexRefresher } from '../exec/indexRefresh.js';\nimport { refreshIndexAfter } from '../exec/indexRefresh.js';\nimport { resolveBranchRemote } from './branchRemote.js';\nimport { parseGitBoolean } from './config.js';\n\n/** The remotes a fetch read with their configured refspecs: one named remote, all of them, or a bare fetch's default */\ntype FetchedRemotes = { remote: string } | 'all' | 'default';\n\n/** The ref kinds a fetch can move, in the order its announcement lists them */\nconst fetchRefChangeKinds: readonly RepositoryChange[] = ['remotes', 'heads', 'tags', 'stash'];\n\n/** The destinations a fetch's snapshot covers when the remotes' configured refspecs can't be read */\nconst broadFetchDestinations: readonly string[] = ['refs/heads', 'refs/remotes'];\n\n/**\n * The ref a fetch refspec stores into, qualified as git's fetch does — `heads/`, `tags/` and `remotes/` get `refs/`,\n * and any other unqualified name is a local branch — or `undefined` when it stores nothing (no `:`, or nothing after\n * it). A glob destination keeps its glob.\n */\nfunction getRefspecDestination(refspec: string): string | undefined {\n\tconst stripped = refspec.startsWith('+') ? refspec.slice(1) : refspec;\n\tconst colonIndex = stripped.indexOf(':');\n\tif (colonIndex === -1) return undefined;\n\n\tconst destination = stripped.slice(colonIndex + 1);\n\tif (!destination) return undefined;\n\tif (destination.startsWith('refs/')) return destination;\n\n\treturn /^(?:heads|tags|remotes)\\//.test(destination) ? `refs/${destination}` : `refs/heads/${destination}`;\n}\n\n/**\n * The for-each-ref patterns covering `destinations` (the refs a fetch may store into) and tags, which a fetch follows\n * into what it fetched. A pattern's `*` doesn't match across `/`, so a glob destination is widened to the directory\n * above its first glob.\n */\nfunction getFetchSnapshotPatterns(destinations: Iterable<string>): string[] {\n\tconst patterns = ['refs/tags'];\n\tfor (let destination of destinations) {\n\t\tconst globIndex = destination.search(/[*?[]/);\n\t\tif (globIndex !== -1) {\n\t\t\tdestination = destination.substring(0, destination.lastIndexOf('/', globIndex));\n\t\t}\n\t\tif (patterns.some(p => destination === p || destination.startsWith(`${p}/`))) continue;\n\n\t\tpatterns.push(destination);\n\t}\n\treturn patterns;\n}\n\n/** The refs created, moved, retargeted or deleted between two snapshots */\nfunction getMovedRefs(before: ReadonlyMap<string, string>, after: ReadonlyMap<string, string>): string[] {\n\tconst moved: string[] = [];\n\tfor (const [ref, sha] of after) {\n\t\tif (before.get(ref) !== sha) {\n\t\t\tmoved.push(ref);\n\t\t}\n\t}\n\tfor (const ref of before.keys()) {\n\t\tif (!after.has(ref)) {\n\t\t\tmoved.push(ref);\n\t\t}\n\t}\n\treturn moved;\n}\n\nexport class OperationsGitSubProvider implements GitOperationsSubProvider {\n\t/** The `commonPath\\0remote` pairs {@link followRemoteHeads} has handled */\n\tprivate readonly followedRemoteHeads = new Set<string>();\n\n\tconstructor(\n\t\tprivate readonly context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t\tprivate readonly indexRefresher?: IndexRefresher,\n\t) {}\n\n\tscheduleIndexRefresh(repoPath: string): void {\n\t\tthis.indexRefresher?.schedule(repoPath);\n\t}\n\n\t@debug()\n\tasync checkout(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: { createBranch?: string; noTracking?: boolean },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst params = ['checkout'];\n\t\tif (options?.createBranch) {\n\t\t\tparams.push('-b', options.createBranch);\n\t\t\tif (options.noTracking) {\n\t\t\t\tparams.push('--no-track');\n\t\t\t}\n\t\t\tparams.push(ref, '--');\n\t\t} else {\n\t\t\tparams.push(ref, '--');\n\t\t}\n\n\t\ttry {\n\t\t\tawait refreshIndexAfter(this.indexRefresher, repoPath, () =>\n\t\t\t\tthis.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...params),\n\t\t\t);\n\t\t\tif (options?.createBranch) {\n\t\t\t\t// Evict the cached base only — see `createBranch` on why the persisted keys stay.\n\t\t\t\tthis.cache.deleteBaseBranchName(repoPath, options.createBranch);\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'checkout',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew CheckoutError(\n\t\t\t\t\t\t{ reason: reason ?? 'other', ref: ref, gitCommand: { repoPath: repoPath, args: params } },\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t} finally {\n\t\t\t// `-b` moves only the branch it creates, and writes tracking to that branch's own config section\n\t\t\tthis.announceHeadChanged(\n\t\t\t\trepoPath,\n\t\t\t\toptions?.createBranch ? { branch: `refs/heads/${options.createBranch}` } : undefined,\n\t\t\t\tBoolean(options?.createBranch) && mayWriteTracking(ref, options?.noTracking),\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\t}\n\n\t@sequentialize({ getQueueKey: rp => rp })\n\t@debug()\n\tasync cherryPick(\n\t\trepoPath: string,\n\t\trevs: string[],\n\t\toptions?: { edit?: boolean; noCommit?: boolean; source?: unknown },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<GitOperationResult> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst args = ['cherry-pick'];\n\t\tif (options?.edit) {\n\t\t\targs.push('-e');\n\t\t}\n\t\tif (options?.noCommit) {\n\t\t\targs.push('-n');\n\t\t}\n\n\t\tif (revs.length > 1) {\n\t\t\t// Sort commits in topological order (oldest ancestor first) so cherry-pick applies them correctly.\n\t\t\t// This is a local read-only pre-flight, not the user-initiated op — don't subject it to caller env/timeout.\n\t\t\tconst revsSet = new Set(revs);\n\t\t\tconst result = await this.git.run({ cwd: repoPath }, 'rev-list', '--topo-order', '--reverse', ...revs);\n\n\t\t\tconst ordered: string[] = [];\n\t\t\tfor (const sha of result.stdout.trim().split('\\n')) {\n\t\t\t\tif (sha && revsSet.has(sha)) {\n\t\t\t\t\tordered.push(sha);\n\t\t\t\t\tif (ordered.length === revs.length) break; // Early exit once we have all\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (ordered.length === revs.length) {\n\t\t\t\trevs = ordered;\n\t\t\t}\n\t\t\t// If we didn't get all commits (shouldn't happen), keep original order\n\t\t}\n\n\t\targs.push(...revs);\n\n\t\ttry {\n\t\t\tawait this.runMovingHeadBranch(repoPath, () =>\n\t\t\t\trefreshIndexAfter(this.indexRefresher, repoPath, () =>\n\t\t\t\t\tthis.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...args),\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn { conflicted: false };\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tawait this.throwIfSigningError(repoPath, args, ex, options?.source);\n\t\t\tconst mapped = getGitCommandError(\n\t\t\t\t'cherry-pick',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew CherryPickError(\n\t\t\t\t\t\t{ reason: reason ?? 'other', revs: revs, gitCommand: { repoPath: repoPath, args: args } },\n\t\t\t\t\t\tex as Error,\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tif (CherryPickError.is(mapped, 'conflicts')) {\n\t\t\t\treturn this.createConflictResult(repoPath, 'cherry-pick');\n\t\t\t}\n\t\t\tthrow mapped;\n\t\t}\n\t}\n\n\t@sequentialize({ getQueueKey: rp => rp })\n\t@debug()\n\tasync commit(\n\t\trepoPath: string,\n\t\tmessage: string,\n\t\toptions?: {\n\t\t\tall?: boolean;\n\t\t\tallowEmpty?: boolean;\n\t\t\tamend?: boolean;\n\t\t\tauthor?: string;\n\t\t\tdate?: string;\n\t\t\tsignoff?: boolean;\n\t\t\tsource?: unknown;\n\t\t},\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst params = ['commit'];\n\t\tif (options?.all) {\n\t\t\tparams.push('--all');\n\t\t}\n\t\tif (options?.allowEmpty) {\n\t\t\tparams.push('--allow-empty');\n\t\t}\n\t\tif (options?.amend) {\n\t\t\tparams.push('--amend');\n\t\t}\n\t\tif (options?.signoff) {\n\t\t\tparams.push('--signoff');\n\t\t}\n\t\tif (options?.author) {\n\t\t\tparams.push(`--author=${options.author}`);\n\t\t}\n\t\tif (options?.date) {\n\t\t\tparams.push(`--date=${options.date}`);\n\t\t}\n\t\t// Host-level override (e.g. VS Code's `git.enableCommitSigning`) — request signing explicitly\n\t\t// via `-S`. Implicit repo-config signing (`commit.gpgsign=true`) needs no flag, and `-S`\n\t\t// alongside it is harmless, so the override can only enable signing, never force it off.\n\t\tconst sign = this.context.config?.signing?.enabled === true;\n\t\tif (sign) {\n\t\t\tparams.push('-S');\n\t\t}\n\t\t// Read commit message from stdin via -F - to avoid shell escaping issues\n\t\tparams.push('-F', '-');\n\n\t\ttry {\n\t\t\t// A commit refused by a hook can still have restaged files, which the announcement covers too\n\t\t\tawait this.runMovingHeadBranch(repoPath, () =>\n\t\t\t\tthis.git.run(\n\t\t\t\t\t{ cwd: repoPath, stdin: message, stdinEncoding: 'utf8', errors: 'throw', ...runOptions },\n\t\t\t\t\t...params,\n\t\t\t\t),\n\t\t\t);\n\t\t\tif (sign) {\n\t\t\t\t// `-S` was passed and the commit succeeded, so signing is confirmed — fire the\n\t\t\t\t// explicit-sign hook (same contract as the patch provider's `commit-tree -S` path).\n\t\t\t\tlet format: SigningFormat | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tformat = (await this.provider.config.getSigningConfig?.(repoPath))?.format;\n\t\t\t\t} catch {}\n\t\t\t\tthis.context.hooks?.commits?.onSigned?.(format ?? 'gpg', options?.source);\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tawait this.throwIfSigningError(repoPath, params, ex, options?.source);\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'commit',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew CommitError(\n\t\t\t\t\t\t{ reason: reason ?? 'other', gitCommand: { repoPath: repoPath, args: params } },\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t@sequentialize({ getQueueKey: rp => rp })\n\t@debug()\n\tasync fetch(\n\t\trepoPath: string,\n\t\toptions?:\n\t\t\t| {\n\t\t\t\t\tall?: boolean;\n\t\t\t\t\tbranch?: GitBranchReference;\n\t\t\t\t\tprune?: boolean;\n\t\t\t\t\tpull?: boolean;\n\t\t\t\t\tremote?: string;\n\t\t\t\t\trefspecs?: undefined;\n\t\t\t\t\tpreserveFetchHead?: boolean;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tall?: undefined;\n\t\t\t\t\tbranch?: undefined;\n\t\t\t\t\tprune?: boolean;\n\t\t\t\t\tpull?: undefined;\n\t\t\t\t\tremote: string;\n\t\t\t\t\trefspecs: readonly string[];\n\t\t\t\t\tpreserveFetchHead?: boolean;\n\t\t\t },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst { branch, ...opts } = options ?? {};\n\t\tlet ran = false;\n\t\tlet fetched: FetchedRemotes | undefined;\n\t\tlet snapshot: { patterns: string[]; before: Map<string, string> | undefined } | undefined;\n\t\ttry {\n\t\t\tif (isBranchReference(branch)) {\n\t\t\t\tconst resolved = await resolveBranchRemote(this.provider, repoPath, branch, runOptions?.cancellation);\n\t\t\t\tif (resolved.remote == null) return;\n\n\t\t\t\t// A pull fetch stores the upstream into the local branch (see `fetchCore`)\n\t\t\t\tconst patterns = await this.getFetchSnapshotPatterns(\n\t\t\t\t\trepoPath,\n\t\t\t\t\tresolved.remote,\n\t\t\t\t\toptions?.pull ? [`${resolved.upstream}:${resolved.name}`] : undefined,\n\t\t\t\t);\n\t\t\t\tsnapshot = { patterns: patterns, before: await this.snapshotRefs(repoPath, patterns) };\n\t\t\t\tran = true;\n\t\t\t\tawait this.fetchCore(\n\t\t\t\t\trepoPath,\n\t\t\t\t\t{\n\t\t\t\t\t\tbranch: resolved.name,\n\t\t\t\t\t\tremote: resolved.remote,\n\t\t\t\t\t\tupstream: resolved.upstream!,\n\t\t\t\t\t\tpull: options?.pull,\n\t\t\t\t\t\tpreserveFetchHead: options?.preserveFetchHead,\n\t\t\t\t\t},\n\t\t\t\t\trunOptions,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// A bare fetch reads its default remote, or all of them: every remote's refspecs cover either\n\t\t\t\tconst patterns = await this.getFetchSnapshotPatterns(repoPath, opts.remote, opts.refspecs);\n\t\t\t\tsnapshot = { patterns: patterns, before: await this.snapshotRefs(repoPath, patterns) };\n\t\t\t\tran = true;\n\t\t\t\tawait this.fetchCore(repoPath, opts, runOptions);\n\t\t\t\tif (!opts.refspecs?.length) {\n\t\t\t\t\tfetched = opts.remote != null ? { remote: opts.remote } : opts.all ? 'all' : 'default';\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tthrow ex;\n\t\t} finally {\n\t\t\t// A rejected fetch may have stored some of its refs before it failed\n\t\t\tif (ran) {\n\t\t\t\tawait this.announceFetch(repoPath, snapshot, () => this.getFetchChanges(branch, options));\n\t\t\t}\n\t\t\tif (fetched != null) {\n\t\t\t\tvoid this.followRemoteHeads(repoPath, fetched);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Writes the missing `refs/remotes/<remote>/HEAD` (the default branch the base reads) of each remote a fetch just\n\t * read with its configured refspecs, once per remote, on git < 2.48 — newer git's fetch creates it itself. A bare\n\t * fetch/pull reads every remote when `fetch.all` is set (git 2.44+), else its default remote. Right after the\n\t * fetch, so the credentials it used are still cached. Never awaited; never rejects, failures not retried.\n\t */\n\tprivate async followRemoteHeads(repoPath: string, fetched: FetchedRemotes): Promise<void> {\n\t\ttry {\n\t\t\tif (await this.git.supports('git:fetch:follow-remote-head')) return;\n\n\t\t\tconst commonPath = this.cache.getCommonPath(repoPath);\n\t\t\tconst pending = (names: string[]): string[] =>\n\t\t\t\tnames.filter(r => !this.followedRemoteHeads.has(`${commonPath}\\0${r}`));\n\n\t\t\t// One cached read for everything that picks the remotes\n\t\t\tconst config = await this.provider.config.getConfigRegex(\n\t\t\t\trepoPath,\n\t\t\t\t'^(fetch\\\\.all|remote\\\\..+\\\\.skipfetchall|branch\\\\..+\\\\.remote)$',\n\t\t\t);\n\n\t\t\tif (\n\t\t\t\tfetched === 'default' &&\n\t\t\t\tparseGitBoolean(config.get('fetch.all')) &&\n\t\t\t\t(await this.git.supports('git:fetch:all-config'))\n\t\t\t) {\n\t\t\t\tfetched = 'all';\n\t\t\t}\n\n\t\t\tlet remotes: string[];\n\t\t\tif (fetched === 'all') {\n\t\t\t\t// `fetch --all` skips the remotes marked `skipFetchAll`\n\t\t\t\tremotes = pending(\n\t\t\t\t\t(await this.provider.remotes.getRemotes(repoPath))\n\t\t\t\t\t\t.map(r => r.name)\n\t\t\t\t\t\t.filter(r => !parseGitBoolean(config.get(`remote.${r}.skipfetchall`))),\n\t\t\t\t);\n\t\t\t} else if (fetched === 'default') {\n\t\t\t\tconst remote = await this.getDefaultFetchRemote(repoPath, config);\n\t\t\t\tremotes = pending(remote != null ? [remote] : []);\n\t\t\t} else {\n\t\t\t\tremotes = pending([fetched.remote]);\n\t\t\t}\n\t\t\tif (!remotes.length) return;\n\n\t\t\tfor (const remote of remotes) {\n\t\t\t\tthis.followedRemoteHeads.add(`${commonPath}\\0${remote}`);\n\t\t\t}\n\t\t\tfor (const remote of remotes) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.provider.branches.setRemoteHeadIfMissing(repoPath, remote);\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t} catch {}\n\t}\n\n\t/**\n\t * The remote a bare `fetch`/`pull` reads: the current branch's `branch.<name>.remote` (none for `.`, the local\n\t * repository), else the sole remote, else `origin`\n\t */\n\tprivate async getDefaultFetchRemote(repoPath: string, config: Map<string, string>): Promise<string | undefined> {\n\t\tconst current = await this.provider.branches.getBranch(repoPath);\n\t\tconst configured = current != null ? config.get(`branch.${current.name}.remote`) : undefined;\n\t\tif (configured) return configured === '.' ? undefined : configured;\n\n\t\tconst remotes = await this.provider.remotes.getRemotes(repoPath);\n\t\treturn remotes.length === 1 ? remotes[0].name : 'origin';\n\t}\n\n\t/**\n\t * The for-each-ref patterns covering every ref a fetch from `remote` (`undefined`: from any remote) may write: the\n\t * destinations of `refspecs`, those of the remote's configured `remote.<name>.fetch` refspecs (which a fetch of\n\t * explicit refspecs still updates opportunistically, and which may store into local branches, as a mirror's do),\n\t * and tags. A `remote` with no refspecs of its own may be a remote group (`remotes.<group>`), which fetches each of\n\t * its remotes, so every remote's destinations stand for it. When the configuration can't be read, all local and\n\t * remote-tracking branches stand for the configured destinations.\n\t */\n\tprivate async getFetchSnapshotPatterns(\n\t\trepoPath: string,\n\t\tremote: string | undefined,\n\t\trefspecs: readonly string[] | undefined,\n\t): Promise<string[]> {\n\t\tconst destinations: string[] = [];\n\t\tconst add = (refspec: string): void => {\n\t\t\tconst destination = getRefspecDestination(refspec);\n\t\t\tif (destination != null) {\n\t\t\t\tdestinations.push(destination);\n\t\t\t}\n\t\t};\n\n\t\tfor (const refspec of refspecs ?? []) {\n\t\t\tadd(refspec);\n\t\t}\n\n\t\tlet configured: Map<string, string[]> | undefined;\n\t\ttry {\n\t\t\tconfigured = await this.provider.config.getConfigRegexAll(repoPath, '^remote\\\\..+\\\\.fetch$');\n\t\t} catch {\n\t\t\tdestinations.unshift(...broadFetchDestinations);\n\t\t}\n\t\tconst ownKey = remote != null ? `remote.${remote}.fetch` : undefined;\n\t\tconst onlyKey = ownKey != null && configured?.has(ownKey) ? ownKey : undefined;\n\t\tfor (const [key, values] of configured ?? []) {\n\t\t\tif (onlyKey != null && key !== onlyKey) continue;\n\n\t\t\tfor (const refspec of values) {\n\t\t\t\tadd(refspec);\n\t\t\t}\n\t\t}\n\t\treturn getFetchSnapshotPatterns(destinations);\n\t}\n\n\t/**\n\t * Announces what a fetch moved. Its refs are compared with the snapshot taken before it ran, so a fetch that\n\t * brought nothing new announces nothing (and resets nothing), and one that did names exactly the refs it moved,\n\t * letting every worktree that doesn't track them skip its refresh. When either snapshot is missing, it announces\n\t * `fallback()`'s kinds unnamed, as if every ref of them may have moved; when a ref moved outside the kinds an\n\t * announcement can name (`refs/notes/*`), the kinds it did see, together with `fallback()`'s, unnamed.\n\t */\n\tprivate async announceFetch(\n\t\trepoPath: string,\n\t\tsnapshot: { patterns: string[]; before: Map<string, string> | undefined } | undefined,\n\t\tfallback: () => RepositoryChange[],\n\t): Promise<void> {\n\t\tconst after = snapshot?.before != null ? await this.snapshotRefs(repoPath, snapshot.patterns) : undefined;\n\n\t\tlet changes: RepositoryChange[] | undefined;\n\t\tlet moved: string[] | undefined;\n\t\tif (snapshot?.before != null && after != null) {\n\t\t\tmoved = getMovedRefs(snapshot.before, after);\n\t\t\tif (!moved.length) return;\n\n\t\t\tconst kinds = new Set<RepositoryChange>();\n\t\t\tlet unnameable = false;\n\t\t\tfor (const ref of moved) {\n\t\t\t\tconst kind = ref.startsWith('refs/') ? getRefChangeKind(ref) : undefined;\n\t\t\t\tif (kind != null) {\n\t\t\t\t\tkinds.add(kind);\n\t\t\t\t} else {\n\t\t\t\t\tunnameable = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (unnameable) {\n\t\t\t\tfor (const kind of fallback()) {\n\t\t\t\t\tkinds.add(kind);\n\t\t\t\t}\n\t\t\t\tmoved = undefined;\n\t\t\t}\n\t\t\tchanges = fetchRefChangeKinds.filter(k => kinds.has(k));\n\t\t}\n\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'tags');\n\t\tif (changes != null && moved != null) {\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, changes, moved);\n\t\t} else {\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, changes ?? fallback());\n\t\t}\n\t}\n\n\t/**\n\t * Each ref under `patterns` (for-each-ref patterns) with its object and, for a symbolic ref, its target (a remote's\n\t * `HEAD` can move to another branch at the same commit), or `undefined` when git couldn't answer. A read, so it\n\t * announces nothing.\n\t */\n\tprivate async snapshotRefs(\n\t\trepoPath: string,\n\t\tpatterns: readonly string[],\n\t): Promise<Map<string, string> | undefined> {\n\t\ttry {\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, errors: 'ignore' },\n\t\t\t\t'for-each-ref',\n\t\t\t\t'--format=%(refname)%00%(objectname)%00%(symref)',\n\t\t\t\t...patterns,\n\t\t\t);\n\t\t\t// `errors: 'ignore'` resolves a failed read empty, which would read as every ref deleted\n\t\t\tif (result.completion.status !== 'exited' || result.exitCode !== 0) return undefined;\n\n\t\t\tconst refs = new Map<string, string>();\n\t\t\tfor (const line of result.stdout.split('\\n')) {\n\t\t\t\tconst index = line.indexOf('\\0');\n\t\t\t\tif (index === -1) continue;\n\n\t\t\t\trefs.set(line.substring(0, index), line.substring(index + 1).trim());\n\t\t\t}\n\t\t\treturn refs;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/** `remotes`, plus `heads`/`tags` for any local branch or tag the fetch writes — a `pull` fetch writes `<upstream>:<branch>` */\n\tprivate getFetchChanges(\n\t\tbranch: GitBranchReference | undefined,\n\t\toptions: { pull?: boolean; refspecs?: readonly string[] } | undefined,\n\t): RepositoryChange[] {\n\t\tif (isBranchReference(branch)) {\n\t\t\treturn options?.pull ? ['heads', 'remotes'] : ['remotes'];\n\t\t}\n\t\tif (!options?.refspecs?.length) return ['remotes'];\n\n\t\tconst changes: RepositoryChange[] = ['remotes'];\n\t\tfor (const refspec of options.refspecs) {\n\t\t\tconst destination = getRefspecDestination(refspec);\n\t\t\tif (destination == null) continue;\n\n\t\t\tif (destination.startsWith('refs/tags/')) {\n\t\t\t\tif (!changes.includes('tags')) {\n\t\t\t\t\tchanges.push('tags');\n\t\t\t\t}\n\t\t\t} else if (destination.startsWith('refs/heads/')) {\n\t\t\t\tif (!changes.includes('heads')) {\n\t\t\t\t\tchanges.push('heads');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn changes;\n\t}\n\n\tprivate async fetchCore(\n\t\trepoPath: string,\n\t\toptions:\n\t\t\t| {\n\t\t\t\t\tall?: boolean;\n\t\t\t\t\tbranch?: undefined;\n\t\t\t\t\tprune?: boolean;\n\t\t\t\t\tpull?: boolean;\n\t\t\t\t\tremote?: string;\n\t\t\t\t\trefspecs?: undefined;\n\t\t\t\t\tpreserveFetchHead?: boolean;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tall?: undefined;\n\t\t\t\t\tbranch: string;\n\t\t\t\t\tprune?: undefined;\n\t\t\t\t\tpull?: boolean;\n\t\t\t\t\tremote: string;\n\t\t\t\t\tupstream: string;\n\t\t\t\t\t/**\n\t\t\t\t\t * `-u` (`--update-head-ok`, the default) lets a `pull` fetch move a branch even where it is\n\t\t\t\t\t * checked out; `false` keeps git's own refusal as a guard against a stale worktree lookup.\n\t\t\t\t\t */\n\t\t\t\t\tupdateHeadOk?: boolean;\n\t\t\t\t\trefspecs?: undefined;\n\t\t\t\t\tpreserveFetchHead?: boolean;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tall?: undefined;\n\t\t\t\t\tbranch?: undefined;\n\t\t\t\t\tprune?: boolean;\n\t\t\t\t\tpull?: undefined;\n\t\t\t\t\tremote: string;\n\t\t\t\t\trefspecs: readonly string[];\n\t\t\t\t\tpreserveFetchHead?: boolean;\n\t\t\t },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst params = ['fetch'];\n\n\t\tif (options.prune) {\n\t\t\tparams.push('--prune');\n\t\t}\n\n\t\tif (options.preserveFetchHead && (await this.git.supports('git:fetch:no-write-fetch-head'))) {\n\t\t\tparams.push('--no-write-fetch-head');\n\t\t}\n\n\t\tif (options.branch && options.remote) {\n\t\t\tif (options.upstream && options.pull) {\n\t\t\t\tif (options.updateHeadOk !== false) {\n\t\t\t\t\tparams.push('-u');\n\t\t\t\t}\n\t\t\t\tparams.push(options.remote, `${options.upstream}:${options.branch}`);\n\t\t\t} else {\n\t\t\t\tparams.push(options.remote, options.upstream || options.branch);\n\t\t\t}\n\t\t} else if (options.refspecs?.length) {\n\t\t\tparams.push(options.remote, ...options.refspecs);\n\t\t} else if (options.remote) {\n\t\t\tparams.push(options.remote);\n\t\t} else if (options.all) {\n\t\t\tparams.push('--all');\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...params);\n\t\t} catch (ex) {\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'fetch',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew FetchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\tbranch: options?.branch,\n\t\t\t\t\t\t\tremote: options?.remote,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: params },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t@sequentialize({ getQueueKey: rp => rp })\n\t@debug()\n\tasync merge(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: { fastForward?: boolean | 'only'; noCommit?: boolean; squash?: boolean; source?: unknown },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<GitOperationResult> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst args = ['merge'];\n\n\t\tif (options?.fastForward === 'only') {\n\t\t\targs.push('--ff-only');\n\t\t} else if (options?.fastForward === true) {\n\t\t\targs.push('--ff');\n\t\t} else if (options?.fastForward === false) {\n\t\t\targs.push('--no-ff');\n\t\t}\n\t\tif (options?.squash) {\n\t\t\targs.push('--squash');\n\t\t}\n\t\tif (options?.noCommit) {\n\t\t\targs.push('--no-commit');\n\t\t}\n\n\t\targs.push(ref);\n\n\t\ttry {\n\t\t\tawait this.runMovingHeadBranch(repoPath, () =>\n\t\t\t\trefreshIndexAfter(this.indexRefresher, repoPath, () =>\n\t\t\t\t\tthis.git.run(\n\t\t\t\t\t\t// Avoid a timeout since merges can take a long time (set to 0 to disable)\n\t\t\t\t\t\t{ cwd: repoPath, errors: 'throw', timeout: 0, ...runOptions },\n\t\t\t\t\t\t...args,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn { conflicted: false };\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tawait this.throwIfSigningError(repoPath, args, ex, options?.source);\n\t\t\tconst mapped = getGitCommandError(\n\t\t\t\t'merge',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew MergeError(\n\t\t\t\t\t\t{ reason: reason ?? 'other', ref: ref, gitCommand: { repoPath: repoPath, args: args } },\n\t\t\t\t\t\tex as Error,\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tif (MergeError.is(mapped, 'conflicts')) {\n\t\t\t\treturn this.createConflictResult(repoPath, 'merge');\n\t\t\t}\n\t\t\tthrow mapped;\n\t\t}\n\t}\n\n\t@sequentialize({ getQueueKey: rp => rp })\n\t@debug()\n\tasync pull(\n\t\trepoPath: string,\n\t\toptions?: {\n\t\t\tbranch?: GitBranchReference;\n\t\t\tfastForward?: 'only';\n\t\t\trebase?: boolean;\n\t\t\ttags?: boolean;\n\t\t\tsource?: unknown;\n\t\t},\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\t// Set once a git command is about to run, so a pull that fails partway (a merge or rebase stopping on a\n\t\t// conflict, a fetch that stored some refs) announces what it changed the way a finished one does\n\t\tlet announce: (() => void) | undefined;\n\t\t// A `pull` with no arguments fetches the branch's remote with its configured refspecs\n\t\tlet fetched: { repoPath: string; remotes: FetchedRemotes } | undefined;\n\t\ttry {\n\t\t\tif (isBranchReference(options?.branch)) {\n\t\t\t\tconst branch = options.branch;\n\t\t\t\t// Find the worktree where this branch is checked out (if any)\n\t\t\t\tconst worktree = await this.provider.worktrees?.getWorktree(\n\t\t\t\t\trepoPath,\n\t\t\t\t\twt => wt.branchName === branch.name,\n\t\t\t\t);\n\t\t\t\tif (worktree != null) {\n\t\t\t\t\t// Branch is checked out in a worktree — run git pull in that worktree's directory\n\t\t\t\t\t// Any rebase state (e.g. from `pull.rebase=true`) appears under the worktree path\n\t\t\t\t\tconst worktreePath = normalizePath(worktree.uri.fsPath);\n\t\t\t\t\t// Its HEAD, index and any paused merge or rebase belong to that worktree, not to `repoPath`\n\t\t\t\t\tannounce = () => {\n\t\t\t\t\t\tthis.announcePull(repoPath);\n\t\t\t\t\t\tif (worktreePath !== normalizePath(repoPath)) {\n\t\t\t\t\t\t\tthis.announcePull(worktreePath);\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\tthis.context.hooks?.operations?.onRebaseCapableOperation?.(worktreePath, 'pull', 'started');\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.pullCore(\n\t\t\t\t\t\t\tworktreePath,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfastForward: options?.fastForward,\n\t\t\t\t\t\t\t\trebase: options?.rebase,\n\t\t\t\t\t\t\t\ttags: options?.tags,\n\t\t\t\t\t\t\t\tsource: options?.source,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\trunOptions,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tfetched = { repoPath: worktreePath, remotes: 'default' };\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tthis.context.hooks?.operations?.onRebaseCapableOperation?.(worktreePath, 'pull', 'ended');\n\t\t\t\t\t}\n\t\t\t\t} else if (options?.fastForward === 'only') {\n\t\t\t\t\t// Not checked out anywhere, so there is no working tree to merge into — but a fast-forward\n\t\t\t\t\t// needs none: fetching `<upstream>:<branch>` advances the local branch, and git refuses that\n\t\t\t\t\t// non-forced refspec unless it fast-forwards. A plain fetch would leave the branch unmoved\n\t\t\t\t\t// and report success.\n\t\t\t\t\t// Fetched without `-u`: the worktree lookup above is cached and can miss a worktree added\n\t\t\t\t\t// outside core, and then git's own refusal is what keeps a checked-out branch from moving.\n\t\t\t\t\tconst {\n\t\t\t\t\t\tname: branchName,\n\t\t\t\t\t\tremote: remoteName,\n\t\t\t\t\t\tupstream,\n\t\t\t\t\t} = await resolveBranchRemote(this.provider, repoPath, branch, runOptions?.cancellation);\n\t\t\t\t\tif (remoteName == null || upstream == null) {\n\t\t\t\t\t\tthrow new PullError({\n\t\t\t\t\t\t\treason: 'noUpstream',\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: ['pull', '--ff-only', branch.name] },\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\t// A `pull` fetch writes `<upstream>:<branch>`, moving the local branch too — same\n\t\t\t\t\t// hooks `fetch()` fires for a pull fetch with a branch reference.\n\t\t\t\t\tannounce = () => {\n\t\t\t\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'tags');\n\t\t\t\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['heads', 'remotes']);\n\t\t\t\t\t};\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.fetchCore(\n\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbranch: branchName,\n\t\t\t\t\t\t\t\tremote: remoteName,\n\t\t\t\t\t\t\t\tupstream: upstream,\n\t\t\t\t\t\t\t\tpull: true,\n\t\t\t\t\t\t\t\tupdateHeadOk: false,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\trunOptions,\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tif (FetchError.is(ex, 'noFastForward')) {\n\t\t\t\t\t\t\tthrow new PullError(\n\t\t\t\t\t\t\t\t{ reason: 'noFastForward', gitCommand: ex.details.gitCommand },\n\t\t\t\t\t\t\t\tex.original,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow ex;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Branch is not checked out anywhere — can only fetch (no working tree to merge into)\n\t\t\t\t\tawait this.fetch(repoPath, { branch: branch }, runOptions);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tannounce = () => this.announcePull(repoPath);\n\t\t\tthis.context.hooks?.operations?.onRebaseCapableOperation?.(repoPath, 'pull', 'started');\n\t\t\ttry {\n\t\t\t\tawait this.pullCore(\n\t\t\t\t\trepoPath,\n\t\t\t\t\t{\n\t\t\t\t\t\tfastForward: options?.fastForward,\n\t\t\t\t\t\trebase: options?.rebase,\n\t\t\t\t\t\ttags: options?.tags,\n\t\t\t\t\t\tsource: options?.source,\n\t\t\t\t\t},\n\t\t\t\t\trunOptions,\n\t\t\t\t);\n\t\t\t\tfetched = { repoPath: repoPath, remotes: 'default' };\n\t\t\t} finally {\n\t\t\t\tthis.context.hooks?.operations?.onRebaseCapableOperation?.(repoPath, 'pull', 'ended');\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tthrow ex;\n\t\t} finally {\n\t\t\tannounce?.();\n\t\t\tif (fetched != null) {\n\t\t\t\tvoid this.followRemoteHeads(fetched.repoPath, fetched.remotes);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate announcePull(repoPath: string): void {\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status', 'tags');\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'remotes', 'index']);\n\t}\n\n\tprivate async pullCore(\n\t\trepoPath: string,\n\t\toptions: { fastForward?: 'only'; rebase?: boolean; tags?: boolean; source?: unknown },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst params = ['pull'];\n\n\t\tif (options.tags) {\n\t\t\tparams.push('--tags');\n\t\t}\n\n\t\tif (options.rebase) {\n\t\t\tparams.push('-r');\n\t\t}\n\n\t\tif (options.fastForward === 'only') {\n\t\t\tparams.push('--ff-only');\n\t\t}\n\n\t\ttry {\n\t\t\tawait refreshIndexAfter(this.indexRefresher, repoPath, () =>\n\t\t\t\tthis.git.run({ cwd: repoPath, configs: gitConfigsPull, errors: 'throw', ...runOptions }, ...params),\n\t\t\t);\n\t\t} catch (ex) {\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tawait this.throwIfSigningError(repoPath, params, ex, options.source);\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'pull',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew PullError({ reason: reason ?? 'other', gitCommand: { repoPath: repoPath, args: params } }, ex),\n\t\t\t);\n\t\t}\n\t}\n\n\t@sequentialize({ getQueueKey: rp => rp })\n\t@debug()\n\tasync push(\n\t\trepoPath: string,\n\t\toptions?: { reference?: GitReference; force?: boolean; publish?: { remote: string } },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\tlet branchName: string;\n\t\tlet remoteName: string | undefined;\n\t\tlet upstreamName: string | undefined;\n\t\t// Whether the push itself writes `branch.<n>.remote/merge` (`-u`): only when it establishes tracking,\n\t\t// never to rewrite what a branch with a live upstream already has\n\t\tlet trackUpstream = options?.publish != null;\n\t\tlet setUpstream:\n\t\t\t| {\n\t\t\t\t\tbranch: string;\n\t\t\t\t\tremote: string;\n\t\t\t\t\tremoteBranch: string;\n\t\t\t }\n\t\t\t| undefined;\n\n\t\tif (isBranchReference(options?.reference)) {\n\t\t\tconst resolved = await resolveBranchRemote(\n\t\t\t\tthis.provider,\n\t\t\t\trepoPath,\n\t\t\t\toptions.reference,\n\t\t\t\trunOptions?.cancellation,\n\t\t\t);\n\t\t\tif (options.publish != null) {\n\t\t\t\tbranchName = options.reference.name;\n\t\t\t\tremoteName = options.publish.remote;\n\t\t\t} else {\n\t\t\t\tbranchName = resolved.name;\n\t\t\t\tremoteName = resolved.remote;\n\t\t\t}\n\t\t\t// A local upstream names a branch in this repository, never a branch on the remote being published to\n\t\t\tupstreamName = options.publish != null && resolved.local ? undefined : resolved.upstream;\n\t\t\ttrackUpstream ||= options.reference.upstream?.missing === true;\n\n\t\t\t// Without a remote, a bare `git push` would follow `push.default` somewhere the caller didn't pick\n\t\t\tif (options.publish == null && remoteName == null) {\n\t\t\t\tthrow new PushError({ reason: 'noUpstream', branch: options.reference.name });\n\t\t\t}\n\t\t} else {\n\t\t\tconst branch = await this.provider.branches.getBranch(repoPath);\n\t\t\tif (branch == null) return;\n\n\t\t\tconst resolved = await resolveBranchRemote(this.provider, repoPath, branch, runOptions?.cancellation);\n\t\t\tif (options?.reference != null) {\n\t\t\t\t// Onto the upstream's remote-side name, which a custom fetch refspec or a renamed upstream can make differ\n\t\t\t\tbranchName = `${options.reference.ref}:${\n\t\t\t\t\toptions?.publish != null ? `refs/heads/${resolved.name}` : (resolved.upstream ?? resolved.name)\n\t\t\t\t}`;\n\t\t\t} else {\n\t\t\t\tconst tracking = options?.publish == null ? resolved.upstream : undefined;\n\t\t\t\tbranchName =\n\t\t\t\t\ttracking != null && tracking !== resolved.name ? `${branch.name}:${tracking}` : branch.name;\n\t\t\t}\n\t\t\tremoteName = resolved.remote ?? options?.publish?.remote;\n\t\t\tif (options?.publish == null && remoteName == null) {\n\t\t\t\tthrow new PushError({ reason: 'noUpstream', branch: branch.name });\n\t\t\t}\n\n\t\t\tupstreamName = options?.reference == null && options?.publish != null ? branch.name : undefined;\n\n\t\t\t// Git can't setup upstream tracking when publishing a new branch to a specific commit, so we'll need to do it after the push\n\t\t\tif (options?.publish?.remote != null && options?.reference != null) {\n\t\t\t\tsetUpstream = {\n\t\t\t\t\tbranch: resolved.name,\n\t\t\t\t\tremote: remoteName!,\n\t\t\t\t\tremoteBranch: resolved.name,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tlet forceOpts: PushForceOptions | undefined;\n\t\tif (options?.force) {\n\t\t\t// Honor the host's force-push preferences (e.g. VS Code's `git.useForcePushWithLease` /\n\t\t\t// `git.useForcePushIfIncludes`); fall back to the safer `--force-with-lease` behavior.\n\t\t\tconst useForceWithLease = this.context.config?.push?.useForceWithLease ?? true;\n\t\t\tforceOpts = useForceWithLease\n\t\t\t\t? { withLease: true, ifIncludes: this.context.config?.push?.useForceIfIncludes ?? true }\n\t\t\t\t: { withLease: false };\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.pushCore(\n\t\t\t\trepoPath,\n\t\t\t\t{\n\t\t\t\t\tbranch: branchName,\n\t\t\t\t\tremote: remoteName,\n\t\t\t\t\tupstream: upstreamName,\n\t\t\t\t\tforce: forceOpts,\n\t\t\t\t\tsetUpstream: trackUpstream,\n\t\t\t\t},\n\t\t\t\trunOptions,\n\t\t\t);\n\n\t\t\t// Since Git can't setup upstream tracking when publishing a new branch to a specific commit, do it now.\n\t\t\t// Soft-fail: the push already succeeded, so don't let a local upstream-tracking failure (cancellation\n\t\t\t// arriving mid-spawn, transient git error) suppress the post-push hook fan-out below.\n\t\t\tif (setUpstream != null) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, ...runOptions },\n\t\t\t\t\t\t'branch',\n\t\t\t\t\t\t'--set-upstream-to',\n\t\t\t\t\t\t`${setUpstream.remote}/${setUpstream.remoteBranch}`,\n\t\t\t\t\t\tsetUpstream.branch,\n\t\t\t\t\t);\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tscope?.error(ex, 'Unable to set upstream tracking after publish');\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tthrow ex;\n\t\t} finally {\n\t\t\t// A rejected push may have updated some of its remote-tracking refs before it failed\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tconst changes: RepositoryChange[] = [];\n\t\t\tif (trackUpstream || setUpstream != null) {\n\t\t\t\tchanges.push('config');\n\t\t\t}\n\t\t\tif (options?.publish != null) {\n\t\t\t\tchanges.push('heads');\n\t\t\t}\n\t\t\tchanges.push('remotes');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, changes);\n\t\t}\n\t}\n\n\tprivate async pushCore(\n\t\trepoPath: string,\n\t\toptions: {\n\t\t\tbranch?: string;\n\t\t\tforce?: PushForceOptions;\n\t\t\tsetUpstream?: boolean;\n\t\t\tremote?: string;\n\t\t\tupstream?: string;\n\t\t\tdelete?: { remote: string; branch: string };\n\t\t},\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst params = ['push'];\n\n\t\tif (options.force != null) {\n\t\t\tif (options.force.withLease) {\n\t\t\t\tparams.push('--force-with-lease');\n\t\t\t\tif (options.force.ifIncludes) {\n\t\t\t\t\tif (await this.git.supports('git:push:force-if-includes')) {\n\t\t\t\t\t\tparams.push('--force-if-includes');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tparams.push('--force');\n\t\t\t}\n\t\t}\n\n\t\t// `push` refuses a branch without a remote before reaching here, as this would drop the branch\n\t\tif (options.branch && options.remote) {\n\t\t\tif (options.upstream) {\n\t\t\t\tif (options.setUpstream) {\n\t\t\t\t\tparams.push('-u');\n\t\t\t\t}\n\t\t\t\tparams.push(options.remote, `${options.branch}:${options.upstream}`);\n\t\t\t} else if (options.setUpstream) {\n\t\t\t\tparams.push('--set-upstream', options.remote, options.branch);\n\t\t\t} else {\n\t\t\t\tparams.push(options.remote, options.branch);\n\t\t\t}\n\t\t} else if (options.remote) {\n\t\t\tparams.push(options.remote);\n\t\t} else if (options.delete) {\n\t\t\tparams.push(options.delete.remote, `:${options.delete.branch}`);\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...params);\n\t\t} catch (ex) {\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tconst error = getGitCommandError(\n\t\t\t\t'push',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew PushError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason,\n\t\t\t\t\t\t\tbranch: options?.branch || options?.delete?.branch,\n\t\t\t\t\t\t\tremote: options?.remote || options?.delete?.remote,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: params },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\n\t\t\tif (options?.force?.withLease && error.details.reason === 'rejected') {\n\t\t\t\tif (ex.stderr && /! \\[rejected\\].*\\(stale info\\)/m.test(ex.stderr)) {\n\t\t\t\t\tthrow new PushError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: 'rejectedWithLease',\n\t\t\t\t\t\t\tbranch: options?.branch || options?.delete?.branch,\n\t\t\t\t\t\t\tremote: options?.remote || options?.delete?.remote,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: params },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\toptions.force.ifIncludes &&\n\t\t\t\t\tex.stderr &&\n\t\t\t\t\t/! \\[rejected\\].*\\(remote ref updated since checkout\\)/m.test(ex.stderr)\n\t\t\t\t) {\n\t\t\t\t\tthrow new PushError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: 'rejectedWithLeaseIfIncludes',\n\t\t\t\t\t\t\tbranch: options?.branch || options?.delete?.branch,\n\t\t\t\t\t\t\tremote: options?.remote || options?.delete?.remote,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: params },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (ex.stderr && GitErrors.pushRejectedRefDoesNotExists.test(ex.stderr)) {\n\t\t\t\t\tthrow new PushError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: 'rejectedRefDoesNotExist',\n\t\t\t\t\t\t\tbranch: options?.branch || options?.delete?.branch,\n\t\t\t\t\t\t\tremote: options?.remote || options?.delete?.remote,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: params },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t@sequentialize({ getQueueKey: rp => rp })\n\t@debug()\n\tasync rebase(\n\t\trepoPath: string,\n\t\tupstream: string,\n\t\toptions?: {\n\t\t\tautoStash?: boolean;\n\t\t\tbranch?: string;\n\t\t\teditor?: string;\n\t\t\tinteractive?: boolean;\n\t\t\tprogrammaticEditor?: boolean;\n\t\t\tautosquash?: boolean;\n\t\t\tmessageEditor?: string;\n\t\t\tonto?: string;\n\t\t\tupdateRefs?: boolean;\n\t\t\tsource?: unknown;\n\t\t},\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<GitOperationResult> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst args = ['rebase'];\n\t\tconst configs: string[] = [];\n\n\t\tif (options?.autoStash !== false) {\n\t\t\targs.push('--autostash');\n\t\t}\n\n\t\tif (options?.interactive) {\n\t\t\targs.push('--interactive');\n\n\t\t\tif (options.editor) {\n\t\t\t\tconfigs.push('-c', `sequence.editor=${options.editor}`);\n\t\t\t}\n\n\t\t\t// A script-based sequence editor rewrites the todo by command word + SHA, so git must emit a\n\t\t\t// plain, natural-order todo regardless of the user's rebase config: `rebase.autosquash` would\n\t\t\t// reorder commits and rewrite `pick`→`fixup`, and `rebase.abbreviateCommands` would emit `p`.\n\t\t\tif (options.programmaticEditor) {\n\t\t\t\tconfigs.push('-c', 'rebase.autosquash=false', '-c', 'rebase.abbreviateCommands=false');\n\t\t\t}\n\t\t}\n\n\t\tif (options?.autosquash != null) {\n\t\t\tif (options.autosquash && options.programmaticEditor) {\n\t\t\t\tthrow new Error(l10n.t('rebase: autosquash cannot be combined with programmaticEditor'));\n\t\t\t}\n\n\t\t\t// `--no-autosquash` is passed explicitly when `false` — omitting the flag would let a\n\t\t\t// `rebase.autosquash=true` git config fold fixups anyway.\n\t\t\targs.push(options.autosquash ? '--autosquash' : '--no-autosquash');\n\t\t}\n\n\t\t// Drive per-commit message editing (the combined message a `squash` produces, or a `reword`).\n\t\t// `GIT_EDITOR` (not `core.editor`) is what git's interactive-rebase backend honors for the `reword`\n\t\t// amend step, so set it on the environment; also set `core.editor` config as a fallback.\n\t\tlet env = runOptions?.env;\n\t\tif (options?.messageEditor) {\n\t\t\tconfigs.push('-c', `core.editor=${options.messageEditor}`);\n\t\t\tenv = { ...env, GIT_EDITOR: options.messageEditor };\n\t\t}\n\n\t\tif (options?.updateRefs === true) {\n\t\t\targs.push('--update-refs');\n\t\t} else if (options?.updateRefs === false) {\n\t\t\targs.push('--no-update-refs');\n\t\t}\n\n\t\tif (options?.onto) {\n\t\t\targs.push('--onto', options.onto);\n\t\t}\n\n\t\targs.push(upstream);\n\n\t\tif (options?.branch) {\n\t\t\targs.push(options.branch);\n\t\t}\n\n\t\t// Fired before the process runs — `git rebase` exits 0 when stopping at `edit`/`break`,\n\t\t// so the result can't be used to detect that a rebase started\n\t\tthis.context.hooks?.operations?.onRebaseCapableOperation?.(repoPath, 'rebase', 'started');\n\t\ttry {\n\t\t\ttry {\n\t\t\t\tawait refreshIndexAfter(this.indexRefresher, repoPath, () =>\n\t\t\t\t\tthis.git.run(\n\t\t\t\t\t\t// Avoid a timeout since rebases can take a long time (set to 0 to disable)\n\t\t\t\t\t\t{ cwd: repoPath, errors: 'throw', configs: configs, timeout: 0, ...runOptions, env: env },\n\t\t\t\t\t\t...args,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} finally {\n\t\t\t\tthis.announceHeadChanged(repoPath, undefined, undefined, true);\n\t\t\t}\n\t\t\treturn { conflicted: false };\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tawait this.throwIfSigningError(repoPath, args, ex, options?.source);\n\t\t\tconst mapped = getGitCommandError(\n\t\t\t\t'rebase',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew RebaseError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\tupstream: upstream,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex as Error,\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tif (RebaseError.is(mapped, 'conflicts')) {\n\t\t\t\treturn await this.createConflictResult(repoPath, 'rebase');\n\t\t\t}\n\t\t\tthrow mapped;\n\t\t} finally {\n\t\t\t// The command exited (success, pause, or failure) — any rebase it left behind is on disk now\n\t\t\tthis.context.hooks?.operations?.onRebaseCapableOperation?.(repoPath, 'rebase', 'ended');\n\t\t}\n\t}\n\n\t@debug()\n\tasync reset(\n\t\trepoPath: string,\n\t\trev: string,\n\t\toptions?: { mode?: 'hard' | 'keep' | 'merge' | 'mixed' | 'soft' },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tawait this.runMovingHeadBranch(repoPath, () => this.resetCore(repoPath, rev, options?.mode, runOptions));\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\tprivate async resetCore(\n\t\trepoPath: string,\n\t\trev: string,\n\t\tmode?: 'hard' | 'keep' | 'merge' | 'mixed' | 'soft',\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst params = ['reset', '-q'];\n\t\tif (mode) {\n\t\t\tparams.push(`--${mode}`);\n\t\t}\n\t\tparams.push(rev, '--');\n\n\t\ttry {\n\t\t\tawait refreshIndexAfter(this.indexRefresher, repoPath, () =>\n\t\t\t\tthis.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...params),\n\t\t\t);\n\t\t} catch (ex) {\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'reset',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew ResetError({ reason: reason ?? 'other', gitCommand: { repoPath: repoPath, args: params } }, ex),\n\t\t\t);\n\t\t}\n\t}\n\n\t@sequentialize({ getQueueKey: rp => rp })\n\t@debug()\n\tasync restore(\n\t\trepoPath: string,\n\t\tpath: string | string[],\n\t\toptions?: { ref?: string; side?: 'ours' | 'theirs' },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst paths = Array.isArray(path) ? path : [path];\n\t\tif (!paths.length) return;\n\n\t\tconst scope = getScopedLogger();\n\t\tconst normalized = paths.map(p => splitPath(p, repoPath, true)[0]);\n\n\t\t// `side` and `ref` are mutually exclusive in git (--ours/--theirs apply during conflict\n\t\t// resolution and take no source ref); side takes precedence if both are somehow supplied.\n\t\t// Use a truthy check on `ref` so an empty string falls through to index-restore rather than\n\t\t// producing a malformed `git checkout '' -- …`. Implemented via `checkout` rather than\n\t\t// `git restore` for compatibility with the minimum supported git (2.7.2); `git restore`\n\t\t// only landed in 2.23.\n\t\tconst selector = options?.side != null ? `--${options.side}` : options?.ref || undefined;\n\t\tconst prefix = selector != null ? ['checkout', selector, '--'] : ['checkout', '--'];\n\n\t\tlet ran = false;\n\t\ttry {\n\t\t\tif (await this.git.supports('git:checkout:pathspec-from-file')) {\n\t\t\t\t// Git ≥ 2.26: stream all pathspecs via stdin (NUL-separated) in a single invocation —\n\t\t\t\t// no CLI-length limit (so no batching), and robust for paths with spaces/newlines.\n\t\t\t\t// Pathspecs come from the file rather than argv, so `--` isn't used.\n\t\t\t\tconst args = ['checkout'];\n\t\t\t\tif (selector != null) {\n\t\t\t\t\targs.push(selector);\n\t\t\t\t}\n\t\t\t\targs.push('--pathspec-from-file=-', '--pathspec-file-nul');\n\t\t\t\tran = true;\n\t\t\t\tawait refreshIndexAfter(this.indexRefresher, repoPath, () =>\n\t\t\t\t\tthis.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, errors: 'throw', ...runOptions, stdin: normalized.join('\\0') },\n\t\t\t\t\t\t...args,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// Older git: pass pathspecs as args, one git invocation per chunk (collapsing N\n\t\t\t\t// path-mode checkouts into ⌈N / chunk⌉ spawns). Reserve the command prefix length and\n\t\t\t\t// a per-arg overhead (separator + possible quoting) so the assembled command line\n\t\t\t\t// can't exceed the OS limit even with many short paths.\n\t\t\t\tconst perArgOverhead = 3;\n\t\t\t\tconst prefixLength = prefix.reduce((sum, arg) => sum + arg.length + perArgOverhead, 0);\n\t\t\t\tawait refreshIndexAfter(this.indexRefresher, repoPath, async () => {\n\t\t\t\t\tfor (const batch of chunkByStringLength(\n\t\t\t\t\t\tnormalized,\n\t\t\t\t\t\tmaxGitCliLength - prefixLength,\n\t\t\t\t\t\tperArgOverhead,\n\t\t\t\t\t)) {\n\t\t\t\t\t\tran = true;\n\t\t\t\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...prefix, ...batch);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'checkout',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew CheckoutError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\tref: options?.side ?? options?.ref,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: [...prefix, ...normalized] },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t} finally {\n\t\t\tif (ran) {\n\t\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'status');\n\t\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['index']);\n\t\t\t}\n\t\t}\n\t}\n\n\t@sequentialize({ getQueueKey: rp => rp })\n\t@debug()\n\tasync revert(\n\t\trepoPath: string,\n\t\trefs: string[],\n\t\toptions?: { editMessage?: boolean; source?: unknown },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<GitOperationResult> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst args = ['revert'];\n\n\t\tif (options?.editMessage === true) {\n\t\t\targs.push('--edit');\n\t\t} else if (options?.editMessage === false) {\n\t\t\targs.push('--no-edit');\n\t\t}\n\n\t\targs.push(...refs);\n\n\t\ttry {\n\t\t\tawait this.runMovingHeadBranch(repoPath, () =>\n\t\t\t\trefreshIndexAfter(this.indexRefresher, repoPath, () =>\n\t\t\t\t\tthis.git.run(\n\t\t\t\t\t\t// Avoid a timeout since reverts can take a long time (set to 0 to disable)\n\t\t\t\t\t\t{ cwd: repoPath, errors: 'throw', timeout: 0, ...runOptions },\n\t\t\t\t\t\t...args,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn { conflicted: false };\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tawait this.throwIfSigningError(repoPath, args, ex, options?.source);\n\n\t\t\tconst mapped = getGitCommandError(\n\t\t\t\t'revert',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew RevertError(\n\t\t\t\t\t\t{ reason: reason ?? 'other', refs: refs, gitCommand: { repoPath: repoPath, args: args } },\n\t\t\t\t\t\tex as Error,\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tif (RevertError.is(mapped, 'conflicts')) {\n\t\t\t\treturn this.createConflictResult(repoPath, 'revert');\n\t\t\t}\n\t\t\tthrow mapped;\n\t\t}\n\t}\n\n\t/**\n\t * Classifies `ex` as a signing failure; if so, fires the `commits.onSigningFailed`\n\t * hook and throws a typed {@link SigningError}. Callers should invoke this first\n\t * in their catch blocks, before falling through to command-specific error mapping\n\t * via {@link getGitCommandError}.\n\t *\n\t * `SigningFormat` is read opportunistically from `config.getSigningConfig`, with\n\t * {@link inferSigningFormatFromError} as a stderr-based fallback and `'gpg'` as\n\t * the final default.\n\t */\n\tprivate async throwIfSigningError(\n\t\trepoPath: string,\n\t\targs: readonly (string | undefined)[],\n\t\tex: unknown,\n\t\tsource?: unknown,\n\t): Promise<void> {\n\t\tconst reason = classifySigningError(ex);\n\t\tif (reason == null) return;\n\n\t\tlet format: SigningFormat | undefined;\n\t\ttry {\n\t\t\tformat = (await this.provider.config.getSigningConfig?.(repoPath))?.format;\n\t\t} catch {\n\t\t\t// Fall through — config read failed; use stderr-inferred format or gpg default\n\t\t}\n\t\tformat ??= inferSigningFormatFromError(ex) ?? 'gpg';\n\n\t\tthis.context.hooks?.commits?.onSigningFailed?.(reason, format, source);\n\t\tthrow new SigningError(\n\t\t\t{ reason: reason, gitCommand: { repoPath: repoPath, args: args } },\n\t\t\tex instanceof Error ? ex : undefined,\n\t\t);\n\t}\n\n\t/**\n\t * Called once git has run, success or not — a rejected write can still have moved HEAD or left state behind.\n\t * `moved` is the one branch the write could have moved, when it knows it, or `'detached'` when it moved a detached\n\t * HEAD and so no branch; `wroteTracking` says it wrote that branch's tracking, to its own config section.\n\t * `rewroteHead` says it rewrote the HEAD file (a checkout or rebase), as a detached HEAD's move always does: every other\n\t * worktree's watcher reports that as `worktreeHead`, so the kind is announced for them to take the report for the\n\t * write's own. A move of HEAD's branch alone (a commit) leaves the file be, and is announced without it.\n\t */\n\tprivate announceHeadChanged(\n\t\trepoPath: string,\n\t\tmoved?: HeadState,\n\t\twroteTracking?: boolean,\n\t\trewroteHead?: boolean,\n\t): void {\n\t\tif (moved === 'detached') {\n\t\t\t// The worktree list carries this worktree's HEAD, which `heads` would otherwise have reset\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status', 'worktrees');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'index', 'worktrees', 'worktreeHead']);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status');\n\n\t\tconst changes: RepositoryChange[] = wroteTracking\n\t\t\t? ['config', 'head', 'heads', 'index']\n\t\t\t: ['head', 'heads', 'index'];\n\t\tif (rewroteHead) {\n\t\t\tchanges.push('worktrees', 'worktreeHead');\n\t\t}\n\t\tif (moved == null) {\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, changes);\n\t\t} else if (wroteTracking) {\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, changes, [moved.branch], {\n\t\t\t\tconfigConfinedToRefs: true,\n\t\t\t});\n\t\t} else {\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, changes, [moved.branch]);\n\t\t}\n\t}\n\n\t/**\n\t * Runs a write that moves only the branch HEAD is on (or no branch, on a detached HEAD), then announces it, success\n\t * or not. HEAD is read on both sides of the run: a hook or an outside `git switch` that moves it meanwhile leaves the\n\t * moved branch unknown, so then none is named.\n\t */\n\tprivate async runMovingHeadBranch<T>(repoPath: string, write: () => Promise<T>): Promise<T> {\n\t\tconst before = await readHeadState(repoPath, this.context.fs, this.cache);\n\t\ttry {\n\t\t\treturn await write();\n\t\t} finally {\n\t\t\tthis.announceHeadChanged(\n\t\t\t\trepoPath,\n\t\t\t\tgetMovedHead(before, await readHeadState(repoPath, this.context.fs, this.cache)),\n\t\t\t);\n\t\t}\n\t}\n\n\t/** The caller has already announced the change — the conflict is what the failed run left behind */\n\tprivate async createConflictResult(repoPath: string, command: GitConflictCommand): Promise<GitOperationResult> {\n\t\tlet conflicts: GitConflictFile[] | undefined;\n\t\ttry {\n\t\t\tconflicts = await this.provider.status.getConflictingFiles(repoPath);\n\t\t} catch (ex) {\n\t\t\t// Don't let a secondary status-read failure mask the original conflict signal\n\t\t\tLogger.warn(`Unable to read conflicting files after ${command}: ${ex}`);\n\t\t}\n\t\tthis.context.hooks?.operations?.onConflicted?.(command, conflicts);\n\t\treturn { conflicted: true, conflicts: conflicts };\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwDA,MAAM,sBAAmD;CAAC;CAAW;CAAS;CAAQ;AAAO;;AAG7F,MAAM,yBAA4C,CAAC,cAAc,cAAc;;;;;;AAO/E,SAAS,sBAAsB,SAAqC;CACnE,MAAM,WAAW,QAAQ,WAAW,GAAG,IAAI,QAAQ,MAAM,CAAC,IAAI;CAC9D,MAAM,aAAa,SAAS,QAAQ,GAAG;CACvC,IAAI,eAAe,IAAI,OAAO,KAAA;CAE9B,MAAM,cAAc,SAAS,MAAM,aAAa,CAAC;CACjD,IAAI,CAAC,aAAa,OAAO,KAAA;CACzB,IAAI,YAAY,WAAW,OAAO,GAAG,OAAO;CAE5C,OAAO,4BAA4B,KAAK,WAAW,IAAI,QAAQ,gBAAgB,cAAc;AAC9F;;;;;;AAOA,SAAS,yBAAyB,cAA0C;CAC3E,MAAM,WAAW,CAAC,WAAW;CAC7B,KAAK,IAAI,eAAe,cAAc;EACrC,MAAM,YAAY,YAAY,OAAO,OAAO;EAC5C,IAAI,cAAc,IACjB,cAAc,YAAY,UAAU,GAAG,YAAY,YAAY,KAAK,SAAS,CAAC;EAE/E,IAAI,SAAS,MAAK,MAAK,gBAAgB,KAAK,YAAY,WAAW,GAAG,EAAE,EAAE,CAAC,GAAG;EAE9E,SAAS,KAAK,WAAW;CAC1B;CACA,OAAO;A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AAA,IAAA;AAyHN,WAAA,CAAA,MAAM,CAAA,GAAA,yBAAA,WAAA,SAAA,IAAA;AA6CN,WAAA,CAAA,cAAc,EAAE,cAAa,OAAM,GAAG,CAAC,GACvC,MAAM,CAAA,GAAA,yBAAA,WAAA,WAAA,IAAA;AAmFN,WAAA,CAAA,cAAc,EAAE,cAAa,OAAM,GAAG,CAAC,GACvC,MAAM,CAAA,GAAA,yBAAA,WAAA,UAAA,IAAA"}
1
+ {"version":3,"file":"operations.js","names":[],"sources":["../../../../git-cli/src/providers/operations.ts"],"sourcesContent":["import * as l10n from '@vscode/l10n';\nimport type { Cache } from '@gitlens/git/cache.js';\nimport type { GitConflictCommand, GitServiceContext } from '@gitlens/git/context.js';\nimport {\n\tCheckoutError,\n\tCherryPickError,\n\tCommitError,\n\tFetchError,\n\tMergeError,\n\tPullError,\n\tPushError,\n\tRebaseError,\n\tResetError,\n\tRevertError,\n\tSigningError,\n} from '@gitlens/git/errors.js';\nimport type { GitBranchReference, GitReference } from '@gitlens/git/models/reference.js';\nimport type { RepositoryChange } from '@gitlens/git/models/repository.js';\nimport type { SigningFormat } from '@gitlens/git/models/signature.js';\nimport type { GitConflictFile } from '@gitlens/git/models/staging.js';\nimport type {\n\tGitOperationResult,\n\tGitOperationRunOptions,\n\tGitOperationsSubProvider,\n} from '@gitlens/git/providers/operations.js';\nimport { isBranchReference } from '@gitlens/git/utils/reference.utils.js';\nimport { getRefChangeKind } from '@gitlens/git/watching/changeEvent.js';\nimport { getScopedCounter } from '@gitlens/utils/counter.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { sequentialize } from '@gitlens/utils/decorators/sequentialize.js';\nimport { chunkByStringLength } from '@gitlens/utils/iterable.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { normalizePath, splitPath } from '@gitlens/utils/path.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport { mayWriteTracking } from '../exec/commandClassifier.js';\nimport type { Git, PushForceOptions } from '../exec/git.js';\nimport {\n\tclassifySigningError,\n\tgetGitCommandError,\n\tgitConfigsPull,\n\tGitErrors,\n\tinferSigningFormatFromError,\n\tisRunHookFailure,\n\tmaxGitCliLength,\n} from '../exec/git.js';\nimport type { HeadSnapshot, HeadState } from '../exec/headState.js';\nimport { getHeadWrite, getMovedHead, readHeadSnapshot, readHeadState } from '../exec/headState.js';\nimport type { IndexRefresher } from '../exec/indexRefresh.js';\nimport { refreshIndexAfter } from '../exec/indexRefresh.js';\nimport { resolveBranchRemote } from './branchRemote.js';\nimport { parseGitBoolean } from './config.js';\n\n/** The remotes a fetch read with their configured refspecs: one named remote, all of them, or a bare fetch's default */\ntype FetchedRemotes = { remote: string } | 'all' | 'default';\n\n/** The refs a write may move, read before it ran (`before` is `undefined` when git couldn't answer) */\ntype RefSnapshot = { patterns: string[]; before: Map<string, string> | undefined };\n\n/**\n * The refs that moved since a {@link RefSnapshot} was taken, with their kinds; `refs` is `undefined` when one of them is\n * of no kind an announcement can name (`refs/notes/*`).\n */\ntype MovedRefs = { kinds: ReadonlySet<RepositoryChange>; refs: string[] | undefined };\n\n/** The ref kinds a fetch can move, in the order its announcement lists them */\nconst fetchRefChangeKinds: readonly RepositoryChange[] = ['remotes', 'heads', 'tags', 'stash'];\n\n/** The kinds a pull announces, in order: `head` and `index` always, each ref kind when a ref of it may have moved */\nconst pullChanges: readonly RepositoryChange[] = ['head', 'heads', 'remotes', 'tags', 'stash', 'index'];\n\n/** The kinds a write that detaches or rewrites a worktree's HEAD file announces for every other worktree's watcher to take */\nconst worktreeHeadChanges: readonly RepositoryChange[] = ['worktrees', 'worktreeHead'];\n\n/** Keys each listing taken after a write apart, so it never joins an identical listing started before the write */\nconst afterWriteListingCounter = getScopedCounter();\n\n/** The destinations a fetch's snapshot covers when the remotes' configured refspecs can't be read */\nconst broadFetchDestinations: readonly string[] = ['refs/heads', 'refs/remotes'];\n\n/**\n * The ref a fetch refspec stores into, qualified as git's fetch does — `heads/`, `tags/` and `remotes/` get `refs/`,\n * and any other unqualified name is a local branch — or `undefined` when it stores nothing (no `:`, or nothing after\n * it). A glob destination keeps its glob.\n */\nfunction getRefspecDestination(refspec: string): string | undefined {\n\tconst stripped = refspec.startsWith('+') ? refspec.slice(1) : refspec;\n\tconst colonIndex = stripped.indexOf(':');\n\tif (colonIndex === -1) return undefined;\n\n\tconst destination = stripped.slice(colonIndex + 1);\n\tif (!destination) return undefined;\n\tif (destination.startsWith('refs/')) return destination;\n\n\treturn /^(?:heads|tags|remotes)\\//.test(destination) ? `refs/${destination}` : `refs/heads/${destination}`;\n}\n\n/**\n * The for-each-ref patterns covering `destinations` (the refs a fetch may store into) and tags, which a fetch follows\n * into what it fetched. A pattern's `*` doesn't match across `/`, so a glob destination is widened to the directory\n * above its first glob.\n */\nfunction getFetchSnapshotPatterns(destinations: Iterable<string>): string[] {\n\tconst patterns = ['refs/tags'];\n\tfor (let destination of destinations) {\n\t\tconst globIndex = destination.search(/[*?[]/);\n\t\tif (globIndex !== -1) {\n\t\t\tdestination = destination.substring(0, destination.lastIndexOf('/', globIndex));\n\t\t}\n\t\tif (patterns.some(p => destination === p || destination.startsWith(`${p}/`))) continue;\n\n\t\tpatterns.push(destination);\n\t}\n\treturn patterns;\n}\n\n/** The refs created, moved, retargeted or deleted between two snapshots */\nfunction getMovedRefs(before: ReadonlyMap<string, string>, after: ReadonlyMap<string, string>): string[] {\n\tconst moved: string[] = [];\n\tfor (const [ref, sha] of after) {\n\t\tif (before.get(ref) !== sha) {\n\t\t\tmoved.push(ref);\n\t\t}\n\t}\n\tfor (const ref of before.keys()) {\n\t\tif (!after.has(ref)) {\n\t\t\tmoved.push(ref);\n\t\t}\n\t}\n\treturn moved;\n}\n\nexport class OperationsGitSubProvider implements GitOperationsSubProvider {\n\t/** The `commonPath\\0remote` pairs {@link followRemoteHeads} has handled */\n\tprivate readonly followedRemoteHeads = new Set<string>();\n\n\tconstructor(\n\t\tprivate readonly context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t\tprivate readonly indexRefresher?: IndexRefresher,\n\t) {}\n\n\tscheduleIndexRefresh(repoPath: string): void {\n\t\tthis.indexRefresher?.schedule(repoPath);\n\t}\n\n\t@debug()\n\tasync checkout(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: { createBranch?: string; noTracking?: boolean },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst params = ['checkout'];\n\t\tif (options?.createBranch) {\n\t\t\tparams.push('-b', options.createBranch);\n\t\t\tif (options.noTracking) {\n\t\t\t\tparams.push('--no-track');\n\t\t\t}\n\t\t\tparams.push(ref, '--');\n\t\t} else {\n\t\t\tparams.push(ref, '--');\n\t\t}\n\n\t\ttry {\n\t\t\tawait refreshIndexAfter(this.indexRefresher, repoPath, () =>\n\t\t\t\tthis.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...params),\n\t\t\t);\n\t\t\tif (options?.createBranch) {\n\t\t\t\t// Evict the cached base only — see `createBranch` on why the persisted keys stay.\n\t\t\t\tthis.cache.deleteBaseBranchName(repoPath, options.createBranch);\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'checkout',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew CheckoutError(\n\t\t\t\t\t\t{ reason: reason ?? 'other', ref: ref, gitCommand: { repoPath: repoPath, args: params } },\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t} finally {\n\t\t\t// `-b` moves only the branch it creates, and writes tracking to that branch's own config section\n\t\t\tthis.announceHeadChanged(\n\t\t\t\trepoPath,\n\t\t\t\toptions?.createBranch ? { branch: `refs/heads/${options.createBranch}` } : undefined,\n\t\t\t\tBoolean(options?.createBranch) && mayWriteTracking(ref, options?.noTracking),\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\t}\n\n\t@sequentialize({ getQueueKey: rp => rp })\n\t@debug()\n\tasync cherryPick(\n\t\trepoPath: string,\n\t\trevs: string[],\n\t\toptions?: { edit?: boolean; noCommit?: boolean; source?: unknown },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<GitOperationResult> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst args = ['cherry-pick'];\n\t\tif (options?.edit) {\n\t\t\targs.push('-e');\n\t\t}\n\t\tif (options?.noCommit) {\n\t\t\targs.push('-n');\n\t\t}\n\n\t\tif (revs.length > 1) {\n\t\t\t// Sort commits in topological order (oldest ancestor first) so cherry-pick applies them correctly.\n\t\t\t// This is a local read-only pre-flight, not the user-initiated op — don't subject it to caller env/timeout.\n\t\t\tconst revsSet = new Set(revs);\n\t\t\tconst result = await this.git.run({ cwd: repoPath }, 'rev-list', '--topo-order', '--reverse', ...revs);\n\n\t\t\tconst ordered: string[] = [];\n\t\t\tfor (const sha of result.stdout.trim().split('\\n')) {\n\t\t\t\tif (sha && revsSet.has(sha)) {\n\t\t\t\t\tordered.push(sha);\n\t\t\t\t\tif (ordered.length === revs.length) break; // Early exit once we have all\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (ordered.length === revs.length) {\n\t\t\t\trevs = ordered;\n\t\t\t}\n\t\t\t// If we didn't get all commits (shouldn't happen), keep original order\n\t\t}\n\n\t\targs.push(...revs);\n\n\t\ttry {\n\t\t\tawait this.runMovingHeadBranch(repoPath, () =>\n\t\t\t\trefreshIndexAfter(this.indexRefresher, repoPath, () =>\n\t\t\t\t\tthis.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...args),\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn { conflicted: false };\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tawait this.throwIfSigningError(repoPath, args, ex, options?.source);\n\t\t\tconst mapped = getGitCommandError(\n\t\t\t\t'cherry-pick',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew CherryPickError(\n\t\t\t\t\t\t{ reason: reason ?? 'other', revs: revs, gitCommand: { repoPath: repoPath, args: args } },\n\t\t\t\t\t\tex as Error,\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tif (CherryPickError.is(mapped, 'conflicts')) {\n\t\t\t\treturn this.createConflictResult(repoPath, 'cherry-pick');\n\t\t\t}\n\t\t\tthrow mapped;\n\t\t}\n\t}\n\n\t@sequentialize({ getQueueKey: rp => rp })\n\t@debug()\n\tasync commit(\n\t\trepoPath: string,\n\t\tmessage: string,\n\t\toptions?: {\n\t\t\tall?: boolean;\n\t\t\tallowEmpty?: boolean;\n\t\t\tamend?: boolean;\n\t\t\tauthor?: string;\n\t\t\tdate?: string;\n\t\t\tsignoff?: boolean;\n\t\t\tsource?: unknown;\n\t\t},\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst params = ['commit'];\n\t\tif (options?.all) {\n\t\t\tparams.push('--all');\n\t\t}\n\t\tif (options?.allowEmpty) {\n\t\t\tparams.push('--allow-empty');\n\t\t}\n\t\tif (options?.amend) {\n\t\t\tparams.push('--amend');\n\t\t}\n\t\tif (options?.signoff) {\n\t\t\tparams.push('--signoff');\n\t\t}\n\t\tif (options?.author) {\n\t\t\tparams.push(`--author=${options.author}`);\n\t\t}\n\t\tif (options?.date) {\n\t\t\tparams.push(`--date=${options.date}`);\n\t\t}\n\t\t// Host-level override (e.g. VS Code's `git.enableCommitSigning`) — request signing explicitly\n\t\t// via `-S`. Implicit repo-config signing (`commit.gpgsign=true`) needs no flag, and `-S`\n\t\t// alongside it is harmless, so the override can only enable signing, never force it off.\n\t\tconst sign = this.context.config?.signing?.enabled === true;\n\t\tif (sign) {\n\t\t\tparams.push('-S');\n\t\t}\n\t\t// Read commit message from stdin via -F - to avoid shell escaping issues\n\t\tparams.push('-F', '-');\n\n\t\ttry {\n\t\t\t// A commit refused by a hook can still have restaged files, which the announcement covers too\n\t\t\tawait this.runMovingHeadBranch(repoPath, () =>\n\t\t\t\tthis.git.run(\n\t\t\t\t\t{ cwd: repoPath, stdin: message, stdinEncoding: 'utf8', errors: 'throw', ...runOptions },\n\t\t\t\t\t...params,\n\t\t\t\t),\n\t\t\t);\n\t\t\tif (sign) {\n\t\t\t\t// `-S` was passed and the commit succeeded, so signing is confirmed — fire the\n\t\t\t\t// explicit-sign hook (same contract as the patch provider's `commit-tree -S` path).\n\t\t\t\tlet format: SigningFormat | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tformat = (await this.provider.config.getSigningConfig?.(repoPath))?.format;\n\t\t\t\t} catch {}\n\t\t\t\tthis.context.hooks?.commits?.onSigned?.(format ?? 'gpg', options?.source);\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tawait this.throwIfSigningError(repoPath, params, ex, options?.source);\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'commit',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew CommitError(\n\t\t\t\t\t\t{ reason: reason ?? 'other', gitCommand: { repoPath: repoPath, args: params } },\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t@sequentialize({ getQueueKey: rp => rp })\n\t@debug()\n\tasync fetch(\n\t\trepoPath: string,\n\t\toptions?:\n\t\t\t| {\n\t\t\t\t\tall?: boolean;\n\t\t\t\t\tbranch?: GitBranchReference;\n\t\t\t\t\tprune?: boolean;\n\t\t\t\t\tpull?: boolean;\n\t\t\t\t\tremote?: string;\n\t\t\t\t\trefspecs?: undefined;\n\t\t\t\t\tpreserveFetchHead?: boolean;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tall?: undefined;\n\t\t\t\t\tbranch?: undefined;\n\t\t\t\t\tprune?: boolean;\n\t\t\t\t\tpull?: undefined;\n\t\t\t\t\tremote: string;\n\t\t\t\t\trefspecs: readonly string[];\n\t\t\t\t\tpreserveFetchHead?: boolean;\n\t\t\t },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst { branch, ...opts } = options ?? {};\n\t\tlet ran = false;\n\t\tlet fetched: FetchedRemotes | undefined;\n\t\tlet snapshot: RefSnapshot | undefined;\n\t\ttry {\n\t\t\tif (isBranchReference(branch)) {\n\t\t\t\tconst resolved = await resolveBranchRemote(this.provider, repoPath, branch, runOptions?.cancellation);\n\t\t\t\tif (resolved.remote == null) return;\n\n\t\t\t\t// A pull fetch stores the upstream into the local branch (see `fetchCore`)\n\t\t\t\tconst patterns = await this.getFetchSnapshotPatterns(\n\t\t\t\t\trepoPath,\n\t\t\t\t\tresolved.remote,\n\t\t\t\t\toptions?.pull ? [`${resolved.upstream}:${resolved.name}`] : undefined,\n\t\t\t\t);\n\t\t\t\tsnapshot = { patterns: patterns, before: await this.snapshotRefs(repoPath, patterns) };\n\t\t\t\tran = true;\n\t\t\t\tawait this.fetchCore(\n\t\t\t\t\trepoPath,\n\t\t\t\t\t{\n\t\t\t\t\t\tbranch: resolved.name,\n\t\t\t\t\t\tremote: resolved.remote,\n\t\t\t\t\t\tupstream: resolved.upstream!,\n\t\t\t\t\t\tpull: options?.pull,\n\t\t\t\t\t\tpreserveFetchHead: options?.preserveFetchHead,\n\t\t\t\t\t},\n\t\t\t\t\trunOptions,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// A bare fetch reads its default remote, or all of them: every remote's refspecs cover either\n\t\t\t\tconst patterns = await this.getFetchSnapshotPatterns(repoPath, opts.remote, opts.refspecs);\n\t\t\t\tsnapshot = { patterns: patterns, before: await this.snapshotRefs(repoPath, patterns) };\n\t\t\t\tran = true;\n\t\t\t\tawait this.fetchCore(repoPath, opts, runOptions);\n\t\t\t\tif (!opts.refspecs?.length) {\n\t\t\t\t\tfetched = opts.remote != null ? { remote: opts.remote } : opts.all ? 'all' : 'default';\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tthrow ex;\n\t\t} finally {\n\t\t\t// A rejected fetch may have stored some of its refs before it failed\n\t\t\tif (ran) {\n\t\t\t\tawait this.announceFetch(repoPath, snapshot, () => this.getFetchChanges(branch, options));\n\t\t\t}\n\t\t\tif (fetched != null) {\n\t\t\t\tvoid this.followRemoteHeads(repoPath, fetched);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Writes the missing `refs/remotes/<remote>/HEAD` (the default branch the base reads) of each remote a fetch just\n\t * read with its configured refspecs, once per remote, on git < 2.48 — newer git's fetch creates it itself. A bare\n\t * fetch/pull reads every remote when `fetch.all` is set (git 2.44+), else its default remote. Right after the\n\t * fetch, so the credentials it used are still cached. Never awaited; never rejects. A write that fails is not\n\t * retried, but a config read that fails marks nothing, so a later fetch tries again.\n\t */\n\tprivate async followRemoteHeads(repoPath: string, fetched: FetchedRemotes): Promise<void> {\n\t\ttry {\n\t\t\tif (await this.git.supports('git:fetch:follow-remote-head')) return;\n\n\t\t\tconst commonPath = this.cache.getCommonPath(repoPath);\n\t\t\tconst pending = (names: string[]): string[] =>\n\t\t\t\tnames.filter(r => !this.followedRemoteHeads.has(`${commonPath}\\0${r}`));\n\n\t\t\t// One cached read for everything that picks the remotes\n\t\t\tconst config = await this.provider.config.getConfigRegex(\n\t\t\t\trepoPath,\n\t\t\t\t'^(fetch\\\\.all|remote\\\\..+\\\\.skipfetchall|branch\\\\..+\\\\.remote)$',\n\t\t\t);\n\n\t\t\tif (\n\t\t\t\tfetched === 'default' &&\n\t\t\t\tparseGitBoolean(config.get('fetch.all')) &&\n\t\t\t\t(await this.git.supports('git:fetch:all-config'))\n\t\t\t) {\n\t\t\t\tfetched = 'all';\n\t\t\t}\n\n\t\t\tlet remotes: string[];\n\t\t\tif (fetched === 'all') {\n\t\t\t\t// `fetch --all` skips the remotes marked `skipFetchAll`\n\t\t\t\tremotes = pending(\n\t\t\t\t\t(await this.provider.remotes.getRemotes(repoPath))\n\t\t\t\t\t\t.map(r => r.name)\n\t\t\t\t\t\t.filter(r => !parseGitBoolean(config.get(`remote.${r}.skipfetchall`))),\n\t\t\t\t);\n\t\t\t} else if (fetched === 'default') {\n\t\t\t\tconst remote = await this.getDefaultFetchRemote(repoPath, config);\n\t\t\t\tremotes = pending(remote != null ? [remote] : []);\n\t\t\t} else {\n\t\t\t\tremotes = pending([fetched.remote]);\n\t\t\t}\n\t\t\tif (!remotes.length) return;\n\n\t\t\tfor (const remote of remotes) {\n\t\t\t\tthis.followedRemoteHeads.add(`${commonPath}\\0${remote}`);\n\t\t\t}\n\t\t\tfor (const remote of remotes) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.provider.branches.setRemoteHeadIfMissing(repoPath, remote);\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t} catch {}\n\t}\n\n\t/**\n\t * The remote a bare `fetch`/`pull` reads: the current branch's `branch.<name>.remote` (none for `.`, the local\n\t * repository), else the sole remote, else `origin`\n\t */\n\tprivate async getDefaultFetchRemote(repoPath: string, config: Map<string, string>): Promise<string | undefined> {\n\t\tconst current = await this.provider.branches.getBranch(repoPath);\n\t\tconst configured = current != null ? config.get(`branch.${current.name}.remote`) : undefined;\n\t\tif (configured) return configured === '.' ? undefined : configured;\n\n\t\tconst remotes = await this.provider.remotes.getRemotes(repoPath);\n\t\treturn remotes.length === 1 ? remotes[0].name : 'origin';\n\t}\n\n\t/**\n\t * The for-each-ref patterns covering every ref a fetch from `remote` (`undefined`: from any remote) may write: the\n\t * destinations of `refspecs`, those of the remote's configured `remote.<name>.fetch` refspecs (which a fetch of\n\t * explicit refspecs still updates opportunistically, and which may store into local branches, as a mirror's do),\n\t * and tags. A `remote` with no refspecs of its own may be a remote group (`remotes.<group>`), which fetches each of\n\t * its remotes, so every remote's destinations stand for it. When the configuration can't be read, all local and\n\t * remote-tracking branches stand for the configured destinations. `alsoMoves` are the refs the write may move\n\t * besides what its fetch stores (a pull's merge or rebase moves local branches).\n\t */\n\tprivate async getFetchSnapshotPatterns(\n\t\trepoPath: string,\n\t\tremote: string | undefined,\n\t\trefspecs: readonly string[] | undefined,\n\t\talsoMoves?: readonly string[],\n\t): Promise<string[]> {\n\t\tconst destinations: string[] = alsoMoves != null ? [...alsoMoves] : [];\n\t\tconst add = (refspec: string): void => {\n\t\t\tconst destination = getRefspecDestination(refspec);\n\t\t\tif (destination != null) {\n\t\t\t\tdestinations.push(destination);\n\t\t\t}\n\t\t};\n\n\t\tfor (const refspec of refspecs ?? []) {\n\t\t\tadd(refspec);\n\t\t}\n\n\t\tlet configured: Map<string, string[]> | undefined;\n\t\ttry {\n\t\t\tconfigured = await this.provider.config.getConfigRegexAll(repoPath, '^remote\\\\..+\\\\.fetch$');\n\t\t} catch {\n\t\t\tdestinations.unshift(...broadFetchDestinations);\n\t\t}\n\t\tconst ownKey = remote != null ? `remote.${remote}.fetch` : undefined;\n\t\tconst onlyKey = ownKey != null && configured?.has(ownKey) ? ownKey : undefined;\n\t\tfor (const [key, values] of configured ?? []) {\n\t\t\tif (onlyKey != null && key !== onlyKey) continue;\n\n\t\t\tfor (const refspec of values) {\n\t\t\t\tadd(refspec);\n\t\t\t}\n\t\t}\n\t\treturn getFetchSnapshotPatterns(destinations);\n\t}\n\n\t/**\n\t * Announces what a fetch moved. Its refs are compared with the snapshot taken before it ran, so a fetch that\n\t * brought nothing new announces nothing (and resets nothing), and one that did names exactly the refs it moved,\n\t * letting every worktree that doesn't track them skip its refresh. When either snapshot is missing, it announces\n\t * `fallback()`'s kinds unnamed, as if every ref of them may have moved; when a ref moved outside the kinds an\n\t * announcement can name (`refs/notes/*`), the kinds it did see, together with `fallback()`'s, unnamed.\n\t */\n\tprivate async announceFetch(\n\t\trepoPath: string,\n\t\tsnapshot: RefSnapshot | undefined,\n\t\tfallback: () => RepositoryChange[],\n\t): Promise<void> {\n\t\tconst moved = await this.getMovedRefsSince(repoPath, snapshot);\n\t\tif (moved?.refs?.length === 0) return;\n\n\t\tlet changes: RepositoryChange[];\n\t\tif (moved != null) {\n\t\t\tconst kinds = new Set(moved.kinds);\n\t\t\tif (moved.refs == null) {\n\t\t\t\tfor (const kind of fallback()) {\n\t\t\t\t\tkinds.add(kind);\n\t\t\t\t}\n\t\t\t}\n\t\t\tchanges = fetchRefChangeKinds.filter(k => kinds.has(k));\n\t\t} else {\n\t\t\tchanges = fallback();\n\t\t}\n\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'tags');\n\t\tif (moved?.refs != null) {\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, changes, moved.refs);\n\t\t} else {\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, changes);\n\t\t}\n\t}\n\n\t/**\n\t * What moved since `snapshot` was taken, read again now, or `undefined` when either read is missing, so any ref it\n\t * covers may have moved. Never rejects.\n\t */\n\tprivate async getMovedRefsSince(\n\t\trepoPath: string,\n\t\tsnapshot: RefSnapshot | undefined,\n\t): Promise<MovedRefs | undefined> {\n\t\tif (snapshot?.before == null) return undefined;\n\n\t\t// An identical listing started before the write may still be running, and would answer as the refs stood then\n\t\tconst after = await this.snapshotRefs(\n\t\t\trepoPath,\n\t\t\tsnapshot.patterns,\n\t\t\t`after-write-${afterWriteListingCounter.next()}`,\n\t\t);\n\t\tif (after == null) return undefined;\n\n\t\tconst moved = getMovedRefs(snapshot.before, after);\n\t\tconst kinds = new Set<RepositoryChange>();\n\t\tlet unnameable = false;\n\t\tfor (const ref of moved) {\n\t\t\tconst kind = ref.startsWith('refs/') ? getRefChangeKind(ref) : undefined;\n\t\t\tif (kind != null) {\n\t\t\t\tkinds.add(kind);\n\t\t\t} else {\n\t\t\t\tunnameable = true;\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tkinds: kinds,\n\t\t\trefs: unnameable ? undefined : moved,\n\t\t};\n\t}\n\n\t/**\n\t * Each ref under `patterns` (for-each-ref patterns) with its object and, for a symbolic ref, its target (a remote's\n\t * `HEAD` can move to another branch at the same commit), or `undefined` when git couldn't answer. A read, so it\n\t * announces nothing. `correlationKey` keeps it from joining an identical listing already in flight.\n\t * `cancellation` is for a read before a write, which a cancelled caller no longer waits for; the one after it is\n\t * never cancelled, since the write still announces.\n\t */\n\tprivate async snapshotRefs(\n\t\trepoPath: string,\n\t\tpatterns: readonly string[],\n\t\tcorrelationKey?: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<Map<string, string> | undefined> {\n\t\ttry {\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, errors: 'ignore', correlationKey: correlationKey, cancellation: cancellation },\n\t\t\t\t'for-each-ref',\n\t\t\t\t'--format=%(refname)%00%(objectname)%00%(symref)',\n\t\t\t\t...patterns,\n\t\t\t);\n\t\t\t// `errors: 'ignore'` resolves a failed read empty, which would read as every ref deleted\n\t\t\tif (result.completion.status !== 'exited' || result.exitCode !== 0) return undefined;\n\n\t\t\tconst refs = new Map<string, string>();\n\t\t\tfor (const line of result.stdout.split('\\n')) {\n\t\t\t\tconst index = line.indexOf('\\0');\n\t\t\t\tif (index === -1) continue;\n\n\t\t\t\trefs.set(line.substring(0, index), line.substring(index + 1).trim());\n\t\t\t}\n\t\t\treturn refs;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/** `remotes`, plus `heads`/`tags` for any local branch or tag the fetch writes — a `pull` fetch writes `<upstream>:<branch>` */\n\tprivate getFetchChanges(\n\t\tbranch: GitBranchReference | undefined,\n\t\toptions: { pull?: boolean; refspecs?: readonly string[] } | undefined,\n\t): RepositoryChange[] {\n\t\tif (isBranchReference(branch)) {\n\t\t\treturn options?.pull ? ['heads', 'remotes'] : ['remotes'];\n\t\t}\n\t\tif (!options?.refspecs?.length) return ['remotes'];\n\n\t\tconst changes: RepositoryChange[] = ['remotes'];\n\t\tfor (const refspec of options.refspecs) {\n\t\t\tconst destination = getRefspecDestination(refspec);\n\t\t\tif (destination == null) continue;\n\n\t\t\tif (destination.startsWith('refs/tags/')) {\n\t\t\t\tif (!changes.includes('tags')) {\n\t\t\t\t\tchanges.push('tags');\n\t\t\t\t}\n\t\t\t} else if (destination.startsWith('refs/heads/')) {\n\t\t\t\tif (!changes.includes('heads')) {\n\t\t\t\t\tchanges.push('heads');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn changes;\n\t}\n\n\tprivate async fetchCore(\n\t\trepoPath: string,\n\t\toptions:\n\t\t\t| {\n\t\t\t\t\tall?: boolean;\n\t\t\t\t\tbranch?: undefined;\n\t\t\t\t\tprune?: boolean;\n\t\t\t\t\tpull?: boolean;\n\t\t\t\t\tremote?: string;\n\t\t\t\t\trefspecs?: undefined;\n\t\t\t\t\tpreserveFetchHead?: boolean;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tall?: undefined;\n\t\t\t\t\tbranch: string;\n\t\t\t\t\tprune?: undefined;\n\t\t\t\t\tpull?: boolean;\n\t\t\t\t\tremote: string;\n\t\t\t\t\tupstream: string;\n\t\t\t\t\t/**\n\t\t\t\t\t * `-u` (`--update-head-ok`, the default) lets a `pull` fetch move a branch even where it is\n\t\t\t\t\t * checked out; `false` keeps git's own refusal as a guard against a stale worktree lookup.\n\t\t\t\t\t */\n\t\t\t\t\tupdateHeadOk?: boolean;\n\t\t\t\t\trefspecs?: undefined;\n\t\t\t\t\tpreserveFetchHead?: boolean;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tall?: undefined;\n\t\t\t\t\tbranch?: undefined;\n\t\t\t\t\tprune?: boolean;\n\t\t\t\t\tpull?: undefined;\n\t\t\t\t\tremote: string;\n\t\t\t\t\trefspecs: readonly string[];\n\t\t\t\t\tpreserveFetchHead?: boolean;\n\t\t\t },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst params = ['fetch'];\n\n\t\tif (options.prune) {\n\t\t\tparams.push('--prune');\n\t\t}\n\n\t\tif (options.preserveFetchHead && (await this.git.supports('git:fetch:no-write-fetch-head'))) {\n\t\t\tparams.push('--no-write-fetch-head');\n\t\t}\n\n\t\tif (options.branch && options.remote) {\n\t\t\tif (options.upstream && options.pull) {\n\t\t\t\tif (options.updateHeadOk !== false) {\n\t\t\t\t\tparams.push('-u');\n\t\t\t\t}\n\t\t\t\tparams.push(options.remote, `${options.upstream}:${options.branch}`);\n\t\t\t} else {\n\t\t\t\tparams.push(options.remote, options.upstream || options.branch);\n\t\t\t}\n\t\t} else if (options.refspecs?.length) {\n\t\t\tparams.push(options.remote, ...options.refspecs);\n\t\t} else if (options.remote) {\n\t\t\tparams.push(options.remote);\n\t\t} else if (options.all) {\n\t\t\tparams.push('--all');\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...params);\n\t\t} catch (ex) {\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'fetch',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew FetchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\tbranch: options?.branch,\n\t\t\t\t\t\t\tremote: options?.remote,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: params },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t@sequentialize({ getQueueKey: rp => rp })\n\t@debug()\n\tasync merge(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: { fastForward?: boolean | 'only'; noCommit?: boolean; squash?: boolean; source?: unknown },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<GitOperationResult> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst args = ['merge'];\n\n\t\tif (options?.fastForward === 'only') {\n\t\t\targs.push('--ff-only');\n\t\t} else if (options?.fastForward === true) {\n\t\t\targs.push('--ff');\n\t\t} else if (options?.fastForward === false) {\n\t\t\targs.push('--no-ff');\n\t\t}\n\t\tif (options?.squash) {\n\t\t\targs.push('--squash');\n\t\t}\n\t\tif (options?.noCommit) {\n\t\t\targs.push('--no-commit');\n\t\t}\n\n\t\targs.push(ref);\n\n\t\ttry {\n\t\t\tawait this.runMovingHeadBranch(repoPath, () =>\n\t\t\t\trefreshIndexAfter(this.indexRefresher, repoPath, () =>\n\t\t\t\t\tthis.git.run(\n\t\t\t\t\t\t// Avoid a timeout since merges can take a long time (set to 0 to disable)\n\t\t\t\t\t\t{ cwd: repoPath, errors: 'throw', timeout: 0, ...runOptions },\n\t\t\t\t\t\t...args,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn { conflicted: false };\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tawait this.throwIfSigningError(repoPath, args, ex, options?.source);\n\t\t\tconst mapped = getGitCommandError(\n\t\t\t\t'merge',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew MergeError(\n\t\t\t\t\t\t{ reason: reason ?? 'other', ref: ref, gitCommand: { repoPath: repoPath, args: args } },\n\t\t\t\t\t\tex as Error,\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tif (MergeError.is(mapped, 'conflicts')) {\n\t\t\t\treturn this.createConflictResult(repoPath, 'merge');\n\t\t\t}\n\t\t\tthrow mapped;\n\t\t}\n\t}\n\n\t@sequentialize({ getQueueKey: rp => rp })\n\t@debug()\n\tasync pull(\n\t\trepoPath: string,\n\t\toptions?: {\n\t\t\tbranch?: GitBranchReference;\n\t\t\tfastForward?: 'only';\n\t\t\trebase?: boolean;\n\t\t\ttags?: boolean;\n\t\t\tsource?: unknown;\n\t\t},\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\t// Set once a git command is about to run, so a pull that fails partway (a merge or rebase stopping on a\n\t\t// conflict, a fetch that stored some refs) announces what it changed the way a finished one does\n\t\tlet announce: (() => void | Promise<void>) | undefined;\n\t\t// A `pull` with no arguments fetches the branch's remote with its configured refspecs\n\t\tlet fetched: { repoPath: string; remotes: FetchedRemotes } | undefined;\n\t\ttry {\n\t\t\tif (isBranchReference(options?.branch)) {\n\t\t\t\tconst branch = options.branch;\n\t\t\t\t// Find the worktree where this branch is checked out (if any)\n\t\t\t\tconst worktree = await this.provider.worktrees?.getWorktree(\n\t\t\t\t\trepoPath,\n\t\t\t\t\twt => wt.branchName === branch.name,\n\t\t\t\t);\n\t\t\t\tif (worktree != null) {\n\t\t\t\t\t// Branch is checked out in a worktree — run git pull in that worktree's directory\n\t\t\t\t\t// Any rebase state (e.g. from `pull.rebase=true`) appears under the worktree path\n\t\t\t\t\tconst worktreePath = normalizePath(worktree.uri.fsPath);\n\t\t\t\t\t// Worktrees share their refs, so one snapshot names what moved for both paths\n\t\t\t\t\tconst [snapshot, headBefore] = await this.snapshotPullState(worktreePath, runOptions);\n\t\t\t\t\t// Its HEAD, index and any paused merge or rebase belong to that worktree, not to `repoPath`\n\t\t\t\t\tannounce = async () => {\n\t\t\t\t\t\tconst [moved, headWrite] = await this.getPullMoved(worktreePath, snapshot, headBefore);\n\t\t\t\t\t\tif (worktreePath !== normalizePath(repoPath)) {\n\t\t\t\t\t\t\tthis.announcePull(repoPath, moved, { detached: false, rewrote: false });\n\t\t\t\t\t\t\tthis.announcePull(worktreePath, moved, headWrite);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.announcePull(repoPath, moved, headWrite);\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\tthis.context.hooks?.operations?.onRebaseCapableOperation?.(worktreePath, 'pull', 'started');\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.pullCore(\n\t\t\t\t\t\t\tworktreePath,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfastForward: options?.fastForward,\n\t\t\t\t\t\t\t\trebase: options?.rebase,\n\t\t\t\t\t\t\t\ttags: options?.tags,\n\t\t\t\t\t\t\t\tsource: options?.source,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\trunOptions,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tfetched = { repoPath: worktreePath, remotes: 'default' };\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tthis.context.hooks?.operations?.onRebaseCapableOperation?.(worktreePath, 'pull', 'ended');\n\t\t\t\t\t}\n\t\t\t\t} else if (options?.fastForward === 'only') {\n\t\t\t\t\t// Not checked out anywhere, so there is no working tree to merge into — but a fast-forward\n\t\t\t\t\t// needs none: fetching `<upstream>:<branch>` advances the local branch, and git refuses that\n\t\t\t\t\t// non-forced refspec unless it fast-forwards. A plain fetch would leave the branch unmoved\n\t\t\t\t\t// and report success.\n\t\t\t\t\t// Fetched without `-u`: the worktree lookup above is cached and can miss a worktree added\n\t\t\t\t\t// outside core, and then git's own refusal is what keeps a checked-out branch from moving.\n\t\t\t\t\tconst {\n\t\t\t\t\t\tname: branchName,\n\t\t\t\t\t\tremote: remoteName,\n\t\t\t\t\t\tupstream,\n\t\t\t\t\t} = await resolveBranchRemote(this.provider, repoPath, branch, runOptions?.cancellation);\n\t\t\t\t\tif (remoteName == null || upstream == null) {\n\t\t\t\t\t\tthrow new PullError({\n\t\t\t\t\t\t\treason: 'noUpstream',\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: ['pull', '--ff-only', branch.name] },\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\t// A `pull` fetch writes `<upstream>:<branch>`, moving the local branch too — announced as `fetch()`\n\t\t\t\t\t// announces a pull fetch with a branch reference\n\t\t\t\t\tconst patterns = await this.getFetchSnapshotPatterns(repoPath, remoteName, [\n\t\t\t\t\t\t`${upstream}:${branchName}`,\n\t\t\t\t\t]);\n\t\t\t\t\tconst snapshot: RefSnapshot = {\n\t\t\t\t\t\tpatterns: patterns,\n\t\t\t\t\t\tbefore: await this.snapshotRefs(repoPath, patterns),\n\t\t\t\t\t};\n\t\t\t\t\tannounce = () => this.announceFetch(repoPath, snapshot, () => ['heads', 'remotes']);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.fetchCore(\n\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbranch: branchName,\n\t\t\t\t\t\t\t\tremote: remoteName,\n\t\t\t\t\t\t\t\tupstream: upstream,\n\t\t\t\t\t\t\t\tpull: true,\n\t\t\t\t\t\t\t\tupdateHeadOk: false,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\trunOptions,\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tif (FetchError.is(ex, 'noFastForward')) {\n\t\t\t\t\t\t\tthrow new PullError(\n\t\t\t\t\t\t\t\t{ reason: 'noFastForward', gitCommand: ex.details.gitCommand },\n\t\t\t\t\t\t\t\tex.original,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow ex;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Branch is not checked out anywhere — can only fetch (no working tree to merge into)\n\t\t\t\t\tawait this.fetch(repoPath, { branch: branch }, runOptions);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst [snapshot, headBefore] = await this.snapshotPullState(repoPath, runOptions);\n\t\t\tannounce = async () => {\n\t\t\t\tconst [moved, headWrite] = await this.getPullMoved(repoPath, snapshot, headBefore);\n\t\t\t\tthis.announcePull(repoPath, moved, headWrite);\n\t\t\t};\n\t\t\tthis.context.hooks?.operations?.onRebaseCapableOperation?.(repoPath, 'pull', 'started');\n\t\t\ttry {\n\t\t\t\tawait this.pullCore(\n\t\t\t\t\trepoPath,\n\t\t\t\t\t{\n\t\t\t\t\t\tfastForward: options?.fastForward,\n\t\t\t\t\t\trebase: options?.rebase,\n\t\t\t\t\t\ttags: options?.tags,\n\t\t\t\t\t\tsource: options?.source,\n\t\t\t\t\t},\n\t\t\t\t\trunOptions,\n\t\t\t\t);\n\t\t\t\tfetched = { repoPath: repoPath, remotes: 'default' };\n\t\t\t} finally {\n\t\t\t\tthis.context.hooks?.operations?.onRebaseCapableOperation?.(repoPath, 'pull', 'ended');\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tthrow ex;\n\t\t} finally {\n\t\t\tawait announce?.();\n\t\t\tif (fetched != null) {\n\t\t\t\tvoid this.followRemoteHeads(fetched.repoPath, fetched.remotes);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * A snapshot of every ref a `git pull` run in `repoPath` may move: what its fetch may store, from whichever remote a\n\t * bare fetch reads (see {@link getFetchSnapshotPatterns}), every local branch, as its merge or rebase moves HEAD's\n\t * branch, and a rebase that updates refs (`rebase.updateRefs`) moves others, and the stash, which keeps the\n\t * autostashed changes when restoring them conflicts. Taken together with `repoPath`'s HEAD, which a pull may detach\n\t * or rewrite (see {@link getPullMoved}), the two reads concurrently.\n\t */\n\tprivate async snapshotPullState(\n\t\trepoPath: string,\n\t\trunOptions: GitOperationRunOptions | undefined,\n\t): Promise<[RefSnapshot, HeadSnapshot]> {\n\t\treturn Promise.all([\n\t\t\t(async (): Promise<RefSnapshot> => {\n\t\t\t\tconst patterns = await this.getFetchSnapshotPatterns(repoPath, undefined, undefined, [\n\t\t\t\t\t'refs/heads',\n\t\t\t\t\t'refs/stash',\n\t\t\t\t]);\n\t\t\t\treturn {\n\t\t\t\t\tpatterns: patterns,\n\t\t\t\t\tbefore: await this.snapshotRefs(repoPath, patterns, undefined, runOptions?.cancellation),\n\t\t\t\t};\n\t\t\t})(),\n\t\t\treadHeadSnapshot(repoPath, this.context.fs, this.cache),\n\t\t]);\n\t}\n\n\t/**\n\t * What a pull run in `repoPath` moved, and how it left HEAD, read again now: its refs against `snapshot`, its HEAD\n\t * against `headBefore` (see {@link getHeadWrite}). Never rejects.\n\t */\n\tprivate async getPullMoved(\n\t\trepoPath: string,\n\t\tsnapshot: RefSnapshot,\n\t\theadBefore: HeadSnapshot,\n\t): Promise<[MovedRefs | undefined, { detached: boolean; rewrote: boolean }]> {\n\t\tconst [moved, headAfter] = await Promise.all([\n\t\t\tthis.getMovedRefsSince(repoPath, snapshot),\n\t\t\treadHeadSnapshot(repoPath, this.context.fs, this.cache),\n\t\t]);\n\t\treturn [moved, getHeadWrite(headBefore, headAfter)];\n\t}\n\n\t/**\n\t * Announces a pull's HEAD and index, and the refs it moved (see {@link getMovedRefsSince}): each ref kind only when a\n\t * ref of it moved, named, so a sibling worktree that follows none of them skips its refresh. When `moved` is\n\t * missing, or holds a ref no announcement can name, local and remote-tracking branches are announced unnamed, as if\n\t * any of them may have moved, with tags and the stash beside them when one moved. `detached` says the pull left\n\t * `repoPath`'s HEAD off the branch it was on (a rebase stopped partway), which every worktree's list of where each\n\t * branch is checked out shows, so `worktrees` and `worktreeHead` are announced with it, as for a checkout. `rewrote`\n\t * says the pull rewrote the HEAD file and put it back on its branch (a rebase that replayed commits detaches it,\n\t * then points it back), which every other worktree's watcher reports as `worktreeHead`, so the kinds are announced\n\t * for them to take the report for the pull's own. The list's placement of the branch is unchanged, so it is not\n\t * reset.\n\t */\n\tprivate announcePull(\n\t\trepoPath: string,\n\t\tmoved: MovedRefs | undefined,\n\t\t{ detached, rewrote }: { detached: boolean; rewrote: boolean },\n\t): void {\n\t\tif (detached) {\n\t\t\t// The worktree list carries this worktree's HEAD\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status', 'tags', 'worktrees');\n\t\t} else {\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status', 'tags');\n\t\t}\n\n\t\tconst refs = moved?.refs;\n\t\tconst changes = pullChanges.filter(\n\t\t\tk =>\n\t\t\t\tk === 'head' ||\n\t\t\t\tk === 'index' ||\n\t\t\t\tmoved?.kinds.has(k) === true ||\n\t\t\t\t(refs == null && (k === 'heads' || k === 'remotes')),\n\t\t);\n\t\tif (detached || rewrote) {\n\t\t\tchanges.push(...worktreeHeadChanges);\n\t\t}\n\t\tif (refs?.length) {\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, changes, refs);\n\t\t} else {\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, changes);\n\t\t}\n\t}\n\n\tprivate async pullCore(\n\t\trepoPath: string,\n\t\toptions: { fastForward?: 'only'; rebase?: boolean; tags?: boolean; source?: unknown },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst params = ['pull'];\n\n\t\tif (options.tags) {\n\t\t\tparams.push('--tags');\n\t\t}\n\n\t\tif (options.rebase) {\n\t\t\tparams.push('-r');\n\t\t}\n\n\t\tif (options.fastForward === 'only') {\n\t\t\tparams.push('--ff-only');\n\t\t}\n\n\t\ttry {\n\t\t\tawait refreshIndexAfter(this.indexRefresher, repoPath, () =>\n\t\t\t\tthis.git.run({ cwd: repoPath, configs: gitConfigsPull, errors: 'throw', ...runOptions }, ...params),\n\t\t\t);\n\t\t} catch (ex) {\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tawait this.throwIfSigningError(repoPath, params, ex, options.source);\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'pull',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew PullError({ reason: reason ?? 'other', gitCommand: { repoPath: repoPath, args: params } }, ex),\n\t\t\t);\n\t\t}\n\t}\n\n\t@sequentialize({ getQueueKey: rp => rp })\n\t@debug()\n\tasync push(\n\t\trepoPath: string,\n\t\toptions?: { reference?: GitReference; force?: boolean; publish?: { remote: string } },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\tlet branchName: string;\n\t\tlet remoteName: string | undefined;\n\t\tlet upstreamName: string | undefined;\n\t\t// Whether the push itself writes `branch.<n>.remote/merge` (`-u`): only when it establishes tracking,\n\t\t// never to rewrite what a branch with a live upstream already has\n\t\tlet trackUpstream = options?.publish != null;\n\t\tlet setUpstream:\n\t\t\t| {\n\t\t\t\t\tbranch: string;\n\t\t\t\t\tremote: string;\n\t\t\t\t\tremoteBranch: string;\n\t\t\t }\n\t\t\t| undefined;\n\n\t\tif (isBranchReference(options?.reference)) {\n\t\t\tconst resolved = await resolveBranchRemote(\n\t\t\t\tthis.provider,\n\t\t\t\trepoPath,\n\t\t\t\toptions.reference,\n\t\t\t\trunOptions?.cancellation,\n\t\t\t);\n\t\t\tif (options.publish != null) {\n\t\t\t\tbranchName = options.reference.name;\n\t\t\t\tremoteName = options.publish.remote;\n\t\t\t} else {\n\t\t\t\tbranchName = resolved.name;\n\t\t\t\tremoteName = resolved.remote;\n\t\t\t}\n\t\t\t// A local upstream names a branch in this repository, never a branch on the remote being published to\n\t\t\tupstreamName = options.publish != null && resolved.local ? undefined : resolved.upstream;\n\t\t\ttrackUpstream ||= options.reference.upstream?.missing === true;\n\n\t\t\t// Without a remote, a bare `git push` would follow `push.default` somewhere the caller didn't pick\n\t\t\tif (options.publish == null && remoteName == null) {\n\t\t\t\tthrow new PushError({ reason: 'noUpstream', branch: options.reference.name });\n\t\t\t}\n\t\t} else {\n\t\t\tconst branch = await this.provider.branches.getBranch(repoPath);\n\t\t\tif (branch == null) return;\n\n\t\t\tconst resolved = await resolveBranchRemote(this.provider, repoPath, branch, runOptions?.cancellation);\n\t\t\tif (options?.reference != null) {\n\t\t\t\t// Onto the upstream's remote-side name, which a custom fetch refspec or a renamed upstream can make differ\n\t\t\t\tbranchName = `${options.reference.ref}:${\n\t\t\t\t\toptions?.publish != null ? `refs/heads/${resolved.name}` : (resolved.upstream ?? resolved.name)\n\t\t\t\t}`;\n\t\t\t} else {\n\t\t\t\tconst tracking = options?.publish == null ? resolved.upstream : undefined;\n\t\t\t\tbranchName =\n\t\t\t\t\ttracking != null && tracking !== resolved.name ? `${branch.name}:${tracking}` : branch.name;\n\t\t\t}\n\t\t\tremoteName = resolved.remote ?? options?.publish?.remote;\n\t\t\tif (options?.publish == null && remoteName == null) {\n\t\t\t\tthrow new PushError({ reason: 'noUpstream', branch: branch.name });\n\t\t\t}\n\n\t\t\tupstreamName = options?.reference == null && options?.publish != null ? branch.name : undefined;\n\n\t\t\t// Git can't setup upstream tracking when publishing a new branch to a specific commit, so we'll need to do it after the push\n\t\t\tif (options?.publish?.remote != null && options?.reference != null) {\n\t\t\t\tsetUpstream = {\n\t\t\t\t\tbranch: resolved.name,\n\t\t\t\t\tremote: remoteName!,\n\t\t\t\t\tremoteBranch: resolved.name,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tlet forceOpts: PushForceOptions | undefined;\n\t\tif (options?.force) {\n\t\t\t// Honor the host's force-push preferences (e.g. VS Code's `git.useForcePushWithLease` /\n\t\t\t// `git.useForcePushIfIncludes`); fall back to the safer `--force-with-lease` behavior.\n\t\t\tconst useForceWithLease = this.context.config?.push?.useForceWithLease ?? true;\n\t\t\tforceOpts = useForceWithLease\n\t\t\t\t? { withLease: true, ifIncludes: this.context.config?.push?.useForceIfIncludes ?? true }\n\t\t\t\t: { withLease: false };\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.pushCore(\n\t\t\t\trepoPath,\n\t\t\t\t{\n\t\t\t\t\tbranch: branchName,\n\t\t\t\t\tremote: remoteName,\n\t\t\t\t\tupstream: upstreamName,\n\t\t\t\t\tforce: forceOpts,\n\t\t\t\t\tsetUpstream: trackUpstream,\n\t\t\t\t},\n\t\t\t\trunOptions,\n\t\t\t);\n\n\t\t\t// Since Git can't setup upstream tracking when publishing a new branch to a specific commit, do it now.\n\t\t\t// Soft-fail: the push already succeeded, so don't let a local upstream-tracking failure (cancellation\n\t\t\t// arriving mid-spawn, transient git error) suppress the post-push hook fan-out below.\n\t\t\tif (setUpstream != null) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, ...runOptions },\n\t\t\t\t\t\t'branch',\n\t\t\t\t\t\t'--set-upstream-to',\n\t\t\t\t\t\t`${setUpstream.remote}/${setUpstream.remoteBranch}`,\n\t\t\t\t\t\tsetUpstream.branch,\n\t\t\t\t\t);\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tscope?.error(ex, 'Unable to set upstream tracking after publish');\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tthrow ex;\n\t\t} finally {\n\t\t\t// A rejected push may have updated some of its remote-tracking refs before it failed\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tconst changes: RepositoryChange[] = [];\n\t\t\tif (trackUpstream || setUpstream != null) {\n\t\t\t\tchanges.push('config');\n\t\t\t}\n\t\t\tif (options?.publish != null) {\n\t\t\t\tchanges.push('heads');\n\t\t\t}\n\t\t\tchanges.push('remotes');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, changes);\n\t\t}\n\t}\n\n\tprivate async pushCore(\n\t\trepoPath: string,\n\t\toptions: {\n\t\t\tbranch?: string;\n\t\t\tforce?: PushForceOptions;\n\t\t\tsetUpstream?: boolean;\n\t\t\tremote?: string;\n\t\t\tupstream?: string;\n\t\t\tdelete?: { remote: string; branch: string };\n\t\t},\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst params = ['push'];\n\n\t\tif (options.force != null) {\n\t\t\tif (options.force.withLease) {\n\t\t\t\tparams.push('--force-with-lease');\n\t\t\t\tif (options.force.ifIncludes) {\n\t\t\t\t\tif (await this.git.supports('git:push:force-if-includes')) {\n\t\t\t\t\t\tparams.push('--force-if-includes');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tparams.push('--force');\n\t\t\t}\n\t\t}\n\n\t\t// `push` refuses a branch without a remote before reaching here, as this would drop the branch\n\t\tif (options.branch && options.remote) {\n\t\t\tif (options.upstream) {\n\t\t\t\tif (options.setUpstream) {\n\t\t\t\t\tparams.push('-u');\n\t\t\t\t}\n\t\t\t\tparams.push(options.remote, `${options.branch}:${options.upstream}`);\n\t\t\t} else if (options.setUpstream) {\n\t\t\t\tparams.push('--set-upstream', options.remote, options.branch);\n\t\t\t} else {\n\t\t\t\tparams.push(options.remote, options.branch);\n\t\t\t}\n\t\t} else if (options.remote) {\n\t\t\tparams.push(options.remote);\n\t\t} else if (options.delete) {\n\t\t\tparams.push(options.delete.remote, `:${options.delete.branch}`);\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...params);\n\t\t} catch (ex) {\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tconst error = getGitCommandError(\n\t\t\t\t'push',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew PushError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason,\n\t\t\t\t\t\t\tbranch: options?.branch || options?.delete?.branch,\n\t\t\t\t\t\t\tremote: options?.remote || options?.delete?.remote,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: params },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\n\t\t\tif (options?.force?.withLease && error.details.reason === 'rejected') {\n\t\t\t\tif (ex.stderr && /! \\[rejected\\].*\\(stale info\\)/m.test(ex.stderr)) {\n\t\t\t\t\tthrow new PushError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: 'rejectedWithLease',\n\t\t\t\t\t\t\tbranch: options?.branch || options?.delete?.branch,\n\t\t\t\t\t\t\tremote: options?.remote || options?.delete?.remote,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: params },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\toptions.force.ifIncludes &&\n\t\t\t\t\tex.stderr &&\n\t\t\t\t\t/! \\[rejected\\].*\\(remote ref updated since checkout\\)/m.test(ex.stderr)\n\t\t\t\t) {\n\t\t\t\t\tthrow new PushError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: 'rejectedWithLeaseIfIncludes',\n\t\t\t\t\t\t\tbranch: options?.branch || options?.delete?.branch,\n\t\t\t\t\t\t\tremote: options?.remote || options?.delete?.remote,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: params },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (ex.stderr && GitErrors.pushRejectedRefDoesNotExists.test(ex.stderr)) {\n\t\t\t\t\tthrow new PushError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: 'rejectedRefDoesNotExist',\n\t\t\t\t\t\t\tbranch: options?.branch || options?.delete?.branch,\n\t\t\t\t\t\t\tremote: options?.remote || options?.delete?.remote,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: params },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t@sequentialize({ getQueueKey: rp => rp })\n\t@debug()\n\tasync rebase(\n\t\trepoPath: string,\n\t\tupstream: string,\n\t\toptions?: {\n\t\t\tautoStash?: boolean;\n\t\t\tbranch?: string;\n\t\t\teditor?: string;\n\t\t\tinteractive?: boolean;\n\t\t\tprogrammaticEditor?: boolean;\n\t\t\tautosquash?: boolean;\n\t\t\tmessageEditor?: string;\n\t\t\tonto?: string;\n\t\t\tupdateRefs?: boolean;\n\t\t\tsource?: unknown;\n\t\t},\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<GitOperationResult> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst args = ['rebase'];\n\t\tconst configs: string[] = [];\n\n\t\tif (options?.autoStash !== false) {\n\t\t\targs.push('--autostash');\n\t\t}\n\n\t\tif (options?.interactive) {\n\t\t\targs.push('--interactive');\n\n\t\t\tif (options.editor) {\n\t\t\t\tconfigs.push('-c', `sequence.editor=${options.editor}`);\n\t\t\t}\n\n\t\t\t// A script-based sequence editor rewrites the todo by command word + SHA, so git must emit a\n\t\t\t// plain, natural-order todo regardless of the user's rebase config: `rebase.autosquash` would\n\t\t\t// reorder commits and rewrite `pick`→`fixup`, and `rebase.abbreviateCommands` would emit `p`.\n\t\t\tif (options.programmaticEditor) {\n\t\t\t\tconfigs.push('-c', 'rebase.autosquash=false', '-c', 'rebase.abbreviateCommands=false');\n\t\t\t}\n\t\t}\n\n\t\tif (options?.autosquash != null) {\n\t\t\tif (options.autosquash && options.programmaticEditor) {\n\t\t\t\tthrow new Error(l10n.t('rebase: autosquash cannot be combined with programmaticEditor'));\n\t\t\t}\n\n\t\t\t// `--no-autosquash` is passed explicitly when `false` — omitting the flag would let a\n\t\t\t// `rebase.autosquash=true` git config fold fixups anyway.\n\t\t\targs.push(options.autosquash ? '--autosquash' : '--no-autosquash');\n\t\t}\n\n\t\t// Drive per-commit message editing (the combined message a `squash` produces, or a `reword`).\n\t\t// `GIT_EDITOR` (not `core.editor`) is what git's interactive-rebase backend honors for the `reword`\n\t\t// amend step, so set it on the environment; also set `core.editor` config as a fallback.\n\t\tlet env = runOptions?.env;\n\t\tif (options?.messageEditor) {\n\t\t\tconfigs.push('-c', `core.editor=${options.messageEditor}`);\n\t\t\tenv = { ...env, GIT_EDITOR: options.messageEditor };\n\t\t}\n\n\t\tif (options?.updateRefs === true) {\n\t\t\targs.push('--update-refs');\n\t\t} else if (options?.updateRefs === false) {\n\t\t\targs.push('--no-update-refs');\n\t\t}\n\n\t\tif (options?.onto) {\n\t\t\targs.push('--onto', options.onto);\n\t\t}\n\n\t\targs.push(upstream);\n\n\t\tif (options?.branch) {\n\t\t\targs.push(options.branch);\n\t\t}\n\n\t\t// Fired before the process runs — `git rebase` exits 0 when stopping at `edit`/`break`,\n\t\t// so the result can't be used to detect that a rebase started\n\t\tthis.context.hooks?.operations?.onRebaseCapableOperation?.(repoPath, 'rebase', 'started');\n\t\ttry {\n\t\t\ttry {\n\t\t\t\tawait refreshIndexAfter(this.indexRefresher, repoPath, () =>\n\t\t\t\t\tthis.git.run(\n\t\t\t\t\t\t// Avoid a timeout since rebases can take a long time (set to 0 to disable)\n\t\t\t\t\t\t{ cwd: repoPath, errors: 'throw', configs: configs, timeout: 0, ...runOptions, env: env },\n\t\t\t\t\t\t...args,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} finally {\n\t\t\t\tthis.announceHeadChanged(repoPath, undefined, undefined, true);\n\t\t\t}\n\t\t\treturn { conflicted: false };\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tawait this.throwIfSigningError(repoPath, args, ex, options?.source);\n\t\t\tconst mapped = getGitCommandError(\n\t\t\t\t'rebase',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew RebaseError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\tupstream: upstream,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex as Error,\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tif (RebaseError.is(mapped, 'conflicts')) {\n\t\t\t\treturn await this.createConflictResult(repoPath, 'rebase');\n\t\t\t}\n\t\t\tthrow mapped;\n\t\t} finally {\n\t\t\t// The command exited (success, pause, or failure) — any rebase it left behind is on disk now\n\t\t\tthis.context.hooks?.operations?.onRebaseCapableOperation?.(repoPath, 'rebase', 'ended');\n\t\t}\n\t}\n\n\t@debug()\n\tasync reset(\n\t\trepoPath: string,\n\t\trev: string,\n\t\toptions?: { mode?: 'hard' | 'keep' | 'merge' | 'mixed' | 'soft' },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tawait this.runMovingHeadBranch(repoPath, () => this.resetCore(repoPath, rev, options?.mode, runOptions));\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\tprivate async resetCore(\n\t\trepoPath: string,\n\t\trev: string,\n\t\tmode?: 'hard' | 'keep' | 'merge' | 'mixed' | 'soft',\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst params = ['reset', '-q'];\n\t\tif (mode) {\n\t\t\tparams.push(`--${mode}`);\n\t\t}\n\t\tparams.push(rev, '--');\n\n\t\ttry {\n\t\t\tawait refreshIndexAfter(this.indexRefresher, repoPath, () =>\n\t\t\t\tthis.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...params),\n\t\t\t);\n\t\t} catch (ex) {\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'reset',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew ResetError({ reason: reason ?? 'other', gitCommand: { repoPath: repoPath, args: params } }, ex),\n\t\t\t);\n\t\t}\n\t}\n\n\t@sequentialize({ getQueueKey: rp => rp })\n\t@debug()\n\tasync restore(\n\t\trepoPath: string,\n\t\tpath: string | string[],\n\t\toptions?: { ref?: string; side?: 'ours' | 'theirs' },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst paths = Array.isArray(path) ? path : [path];\n\t\tif (!paths.length) return;\n\n\t\tconst scope = getScopedLogger();\n\t\tconst normalized = paths.map(p => splitPath(p, repoPath, true)[0]);\n\n\t\t// `side` and `ref` are mutually exclusive in git (--ours/--theirs apply during conflict\n\t\t// resolution and take no source ref); side takes precedence if both are somehow supplied.\n\t\t// Use a truthy check on `ref` so an empty string falls through to index-restore rather than\n\t\t// producing a malformed `git checkout '' -- …`. Implemented via `checkout` rather than\n\t\t// `git restore` for compatibility with the minimum supported git (2.7.2); `git restore`\n\t\t// only landed in 2.23.\n\t\tconst selector = options?.side != null ? `--${options.side}` : options?.ref || undefined;\n\t\tconst prefix = selector != null ? ['checkout', selector, '--'] : ['checkout', '--'];\n\n\t\tlet ran = false;\n\t\ttry {\n\t\t\tif (await this.git.supports('git:checkout:pathspec-from-file')) {\n\t\t\t\t// Git ≥ 2.26: stream all pathspecs via stdin (NUL-separated) in a single invocation —\n\t\t\t\t// no CLI-length limit (so no batching), and robust for paths with spaces/newlines.\n\t\t\t\t// Pathspecs come from the file rather than argv, so `--` isn't used.\n\t\t\t\tconst args = ['checkout'];\n\t\t\t\tif (selector != null) {\n\t\t\t\t\targs.push(selector);\n\t\t\t\t}\n\t\t\t\targs.push('--pathspec-from-file=-', '--pathspec-file-nul');\n\t\t\t\tran = true;\n\t\t\t\tawait refreshIndexAfter(this.indexRefresher, repoPath, () =>\n\t\t\t\t\tthis.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, errors: 'throw', ...runOptions, stdin: normalized.join('\\0') },\n\t\t\t\t\t\t...args,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// Older git: pass pathspecs as args, one git invocation per chunk (collapsing N\n\t\t\t\t// path-mode checkouts into ⌈N / chunk⌉ spawns). Reserve the command prefix length and\n\t\t\t\t// a per-arg overhead (separator + possible quoting) so the assembled command line\n\t\t\t\t// can't exceed the OS limit even with many short paths.\n\t\t\t\tconst perArgOverhead = 3;\n\t\t\t\tconst prefixLength = prefix.reduce((sum, arg) => sum + arg.length + perArgOverhead, 0);\n\t\t\t\tawait refreshIndexAfter(this.indexRefresher, repoPath, async () => {\n\t\t\t\t\tfor (const batch of chunkByStringLength(\n\t\t\t\t\t\tnormalized,\n\t\t\t\t\t\tmaxGitCliLength - prefixLength,\n\t\t\t\t\t\tperArgOverhead,\n\t\t\t\t\t)) {\n\t\t\t\t\t\tran = true;\n\t\t\t\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...prefix, ...batch);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'checkout',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew CheckoutError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\tref: options?.side ?? options?.ref,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: [...prefix, ...normalized] },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t} finally {\n\t\t\tif (ran) {\n\t\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'status');\n\t\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['index']);\n\t\t\t}\n\t\t}\n\t}\n\n\t@sequentialize({ getQueueKey: rp => rp })\n\t@debug()\n\tasync revert(\n\t\trepoPath: string,\n\t\trefs: string[],\n\t\toptions?: { editMessage?: boolean; source?: unknown },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<GitOperationResult> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst args = ['revert'];\n\n\t\tif (options?.editMessage === true) {\n\t\t\targs.push('--edit');\n\t\t} else if (options?.editMessage === false) {\n\t\t\targs.push('--no-edit');\n\t\t}\n\n\t\targs.push(...refs);\n\n\t\ttry {\n\t\t\tawait this.runMovingHeadBranch(repoPath, () =>\n\t\t\t\trefreshIndexAfter(this.indexRefresher, repoPath, () =>\n\t\t\t\t\tthis.git.run(\n\t\t\t\t\t\t// Avoid a timeout since reverts can take a long time (set to 0 to disable)\n\t\t\t\t\t\t{ cwd: repoPath, errors: 'throw', timeout: 0, ...runOptions },\n\t\t\t\t\t\t...args,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn { conflicted: false };\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tif (isRunHookFailure(ex)) throw ex;\n\n\t\t\tawait this.throwIfSigningError(repoPath, args, ex, options?.source);\n\n\t\t\tconst mapped = getGitCommandError(\n\t\t\t\t'revert',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew RevertError(\n\t\t\t\t\t\t{ reason: reason ?? 'other', refs: refs, gitCommand: { repoPath: repoPath, args: args } },\n\t\t\t\t\t\tex as Error,\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tif (RevertError.is(mapped, 'conflicts')) {\n\t\t\t\treturn this.createConflictResult(repoPath, 'revert');\n\t\t\t}\n\t\t\tthrow mapped;\n\t\t}\n\t}\n\n\t/**\n\t * Classifies `ex` as a signing failure; if so, fires the `commits.onSigningFailed`\n\t * hook and throws a typed {@link SigningError}. Callers should invoke this first\n\t * in their catch blocks, before falling through to command-specific error mapping\n\t * via {@link getGitCommandError}.\n\t *\n\t * `SigningFormat` is read opportunistically from `config.getSigningConfig`, with\n\t * {@link inferSigningFormatFromError} as a stderr-based fallback and `'gpg'` as\n\t * the final default.\n\t */\n\tprivate async throwIfSigningError(\n\t\trepoPath: string,\n\t\targs: readonly (string | undefined)[],\n\t\tex: unknown,\n\t\tsource?: unknown,\n\t): Promise<void> {\n\t\tconst reason = classifySigningError(ex);\n\t\tif (reason == null) return;\n\n\t\tlet format: SigningFormat | undefined;\n\t\ttry {\n\t\t\tformat = (await this.provider.config.getSigningConfig?.(repoPath))?.format;\n\t\t} catch {\n\t\t\t// Fall through — config read failed; use stderr-inferred format or gpg default\n\t\t}\n\t\tformat ??= inferSigningFormatFromError(ex) ?? 'gpg';\n\n\t\tthis.context.hooks?.commits?.onSigningFailed?.(reason, format, source);\n\t\tthrow new SigningError(\n\t\t\t{ reason: reason, gitCommand: { repoPath: repoPath, args: args } },\n\t\t\tex instanceof Error ? ex : undefined,\n\t\t);\n\t}\n\n\t/**\n\t * Called once git has run, success or not — a rejected write can still have moved HEAD or left state behind.\n\t * `moved` is the one branch the write could have moved, when it knows it, or `'detached'` when it moved a detached\n\t * HEAD and so no branch; `wroteTracking` says it wrote that branch's tracking, to its own config section.\n\t * `rewroteHead` says it rewrote the HEAD file (a checkout or rebase), as a detached HEAD's move always does: every other\n\t * worktree's watcher reports that as `worktreeHead`, so the kind is announced for them to take the report for the\n\t * write's own. A move of HEAD's branch alone (a commit) leaves the file be, and is announced without it.\n\t */\n\tprivate announceHeadChanged(\n\t\trepoPath: string,\n\t\tmoved?: HeadState,\n\t\twroteTracking?: boolean,\n\t\trewroteHead?: boolean,\n\t): void {\n\t\tif (moved === 'detached') {\n\t\t\t// The worktree list carries this worktree's HEAD, which `heads` would otherwise have reset\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status', 'worktrees');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'index', ...worktreeHeadChanges]);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status');\n\n\t\tconst changes: RepositoryChange[] = wroteTracking\n\t\t\t? ['config', 'head', 'heads', 'index']\n\t\t\t: ['head', 'heads', 'index'];\n\t\tif (rewroteHead) {\n\t\t\tchanges.push(...worktreeHeadChanges);\n\t\t}\n\t\tif (moved == null) {\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, changes);\n\t\t} else if (wroteTracking) {\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, changes, [moved.branch], {\n\t\t\t\tconfigConfinedToRefs: true,\n\t\t\t});\n\t\t} else {\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, changes, [moved.branch]);\n\t\t}\n\t}\n\n\t/**\n\t * Runs a write that moves only the branch HEAD is on (or no branch, on a detached HEAD), then announces it, success\n\t * or not. HEAD is read on both sides of the run: a hook or an outside `git switch` that moves it meanwhile leaves the\n\t * moved branch unknown, so then none is named.\n\t */\n\tprivate async runMovingHeadBranch<T>(repoPath: string, write: () => Promise<T>): Promise<T> {\n\t\tconst before = await readHeadState(repoPath, this.context.fs, this.cache);\n\t\ttry {\n\t\t\treturn await write();\n\t\t} finally {\n\t\t\tthis.announceHeadChanged(\n\t\t\t\trepoPath,\n\t\t\t\tgetMovedHead(before, await readHeadState(repoPath, this.context.fs, this.cache)),\n\t\t\t);\n\t\t}\n\t}\n\n\t/** The caller has already announced the change — the conflict is what the failed run left behind */\n\tprivate async createConflictResult(repoPath: string, command: GitConflictCommand): Promise<GitOperationResult> {\n\t\tlet conflicts: GitConflictFile[] | undefined;\n\t\ttry {\n\t\t\tconflicts = await this.provider.status.getConflictingFiles(repoPath);\n\t\t} catch (ex) {\n\t\t\t// Don't let a secondary status-read failure mask the original conflict signal\n\t\t\tLogger.warn(`Unable to read conflicting files after ${command}: ${ex}`);\n\t\t}\n\t\tthis.context.hooks?.operations?.onConflicted?.(command, conflicts);\n\t\treturn { conflicted: true, conflicts: conflicts };\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkEA,MAAM,sBAAmD;CAAC;CAAW;CAAS;CAAQ;AAAO;;AAG7F,MAAM,cAA2C;CAAC;CAAQ;CAAS;CAAW;CAAQ;CAAS;AAAO;;AAGtG,MAAM,sBAAmD,CAAC,aAAa,cAAc;;AAGrF,MAAM,2BAA2B,iBAAiB;;AAGlD,MAAM,yBAA4C,CAAC,cAAc,cAAc;;;;;;AAO/E,SAAS,sBAAsB,SAAqC;CACnE,MAAM,WAAW,QAAQ,WAAW,GAAG,IAAI,QAAQ,MAAM,CAAC,IAAI;CAC9D,MAAM,aAAa,SAAS,QAAQ,GAAG;CACvC,IAAI,eAAe,IAAI,OAAO,KAAA;CAE9B,MAAM,cAAc,SAAS,MAAM,aAAa,CAAC;CACjD,IAAI,CAAC,aAAa,OAAO,KAAA;CACzB,IAAI,YAAY,WAAW,OAAO,GAAG,OAAO;CAE5C,OAAO,4BAA4B,KAAK,WAAW,IAAI,QAAQ,gBAAgB,cAAc;AAC9F;;;;;;AA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E,YAAY;GAAiB;EAAU;CACjD;AACD;AA1jDE,WAAA,CAAA,MAAM,CAAA,GAAA,yBAAA,WAAA,YAAA,IAAA;AAoDN,WAAA,CAAA,cAAc,EAAE,cAAa,OAAM,GAAG,CAAC,GACvC,MAAM,CAAA,GAAA,yBAAA,WAAA,cAAA,IAAA;AAmEN,WAAA,CAAA,cAAc,EAAE,cAAa,OAAM,GAAG,CAAC,GACvC,MAAM,CAAA,GAAA,yBAAA,WAAA,UAAA,IAAA;AAgFN,WAAA,CAAA,cAAc,EAAE,cAAa,OAAM,GAAG,CAAC,GACvC,MAAM,CAAA,GAAA,yBAAA,WAAA,SAAA,IAAA;AA8ZN,WAAA,CAAA,cAAc,EAAE,cAAa,OAAM,GAAG,CAAC,GACvC,MAAM,CAAA,GAAA,yBAAA,WAAA,SAAA,IAAA;AA2DN,WAAA,CAAA,cAAc,EAAE,cAAa,OAAM,GAAG,CAAC,GACvC,MAAM,CAAA,GAAA,yBAAA,WAAA,QAAA,IAAA;AA4QN,WAAA,CAAA,cAAc,EAAE,cAAa,OAAM,GAAG,CAAC,GACvC,MAAM,CAAA,GAAA,yBAAA,WAAA,QAAA,IAAA;AAiPN,WAAA,CAAA,cAAc,EAAE,cAAa,OAAM,GAAG,CAAC,GACvC,MAAM,CAAA,GAAA,yBAAA,WAAA,UAAA,IAAA;AAyHN,WAAA,CAAA,MAAM,CAAA,GAAA,yBAAA,WAAA,SAAA,IAAA;AA6CN,WAAA,CAAA,cAAc,EAAE,cAAa,OAAM,GAAG,CAAC,GACvC,MAAM,CAAA,GAAA,yBAAA,WAAA,WAAA,IAAA;AAmFN,WAAA,CAAA,cAAc,EAAE,cAAa,OAAM,GAAG,CAAC,GACvC,MAAM,CAAA,GAAA,yBAAA,WAAA,UAAA,IAAA"}
@@ -36,7 +36,7 @@ var PatchGitSubProvider = class {
36
36
  }
37
37
  let targetPath = repoPath;
38
38
  const currentBranch = await this.provider.branches.getBranch(repoPath);
39
- const branchExists = options?.branchName == null || currentBranch?.name === options.branchName || (await this.provider.branches.getBranches(repoPath, { filter: (b) => b.name === options.branchName }))?.values?.length > 0;
39
+ const branchExists = options?.branchName == null || currentBranch?.name === options.branchName || await this.provider.branches.getBranch(repoPath, options.branchName) != null;
40
40
  const shouldCreate = options?.branchName != null && !branchExists && options.createBranchIfNeeded;
41
41
  if (options?.createWorktreePath != null) {
42
42
  if (options?.branchName === null || options.branchName === currentBranch?.name) throw new ApplyPatchCommitError({ reason: "createWorktreeFailed" });
@@ -1 +1 @@
1
- {"version":3,"file":"patch.js","names":[],"sources":["../../../../git-cli/src/providers/patch.ts"],"sourcesContent":["import type { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport { ApplyPatchCommitError, CherryPickError } from '@gitlens/git/errors.js';\nimport type { GitCommit, GitCommitIdentityShape } from '@gitlens/git/models/commit.js';\nimport type { GitPatchSubProvider } from '@gitlens/git/providers/patch.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { getSettledValue } from '@gitlens/utils/promise.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport { RunError } from '../exec/exec.errors.js';\nimport type { Git } from '../exec/git.js';\nimport { gitConfigsLog, GitError } from '../exec/git.js';\n\nexport class PatchGitSubProvider implements GitPatchSubProvider {\n\tconstructor(\n\t\tprivate readonly context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t) {}\n\n\t@debug()\n\tasync apply(repoPath: string, patch: string, options?: { threeWay?: boolean }): Promise<void> {\n\t\tconst args = ['apply', '--whitespace=warn'];\n\t\tif (options?.threeWay) {\n\t\t\targs.push('--3way');\n\t\t}\n\t\tawait this.git.run({ cwd: repoPath, stdin: patch }, ...args);\n\t}\n\n\t@debug()\n\tasync applyUnreachableCommitForPatch(\n\t\trepoPath: string,\n\t\trev: string,\n\t\toptions?: {\n\t\t\tbranchName?: string;\n\t\t\tcreateBranchIfNeeded?: boolean;\n\t\t\tcreateWorktreePath?: string;\n\t\t\tstash?: boolean;\n\t\t},\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\tif (options?.stash) {\n\t\t\t// Stash any changes first; a failed check for them fails the stash too\n\t\t\ttry {\n\t\t\t\tif (await this.provider.status?.hasWorkingChanges(repoPath)) {\n\t\t\t\t\tawait this.provider.stash.saveStash(repoPath, undefined, undefined, {\n\t\t\t\t\t\tincludeUntracked: true,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex);\n\t\t\t\tthrow new ApplyPatchCommitError({ reason: 'stashFailed' }, ex as Error);\n\t\t\t}\n\t\t}\n\n\t\tlet targetPath = repoPath;\n\t\tconst currentBranch = await this.provider.branches.getBranch(repoPath);\n\t\tconst branchExists =\n\t\t\toptions?.branchName == null ||\n\t\t\tcurrentBranch?.name === options.branchName ||\n\t\t\t(await this.provider.branches.getBranches(repoPath, { filter: b => b.name === options.branchName }))?.values\n\t\t\t\t?.length > 0;\n\t\tconst shouldCreate = options?.branchName != null && !branchExists && options.createBranchIfNeeded;\n\n\t\tif (options?.createWorktreePath != null) {\n\t\t\tif (options?.branchName === null || options.branchName === currentBranch?.name) {\n\t\t\t\tthrow new ApplyPatchCommitError({ reason: 'createWorktreeFailed' });\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst worktree = await this.provider.worktrees?.createWorktreeWithResult(\n\t\t\t\t\trepoPath,\n\t\t\t\t\toptions.createWorktreePath,\n\t\t\t\t\t{\n\t\t\t\t\t\tcommitish:\n\t\t\t\t\t\t\toptions?.branchName != null && branchExists ? options.branchName : currentBranch?.name,\n\t\t\t\t\t\tcreateBranch: shouldCreate ? options.branchName : undefined,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tif (worktree == null) {\n\t\t\t\t\tthrow new ApplyPatchCommitError({ reason: 'createWorktreeFailed' });\n\t\t\t\t}\n\n\t\t\t\ttargetPath = worktree.path;\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex);\n\t\t\t\tthrow new ApplyPatchCommitError({ reason: 'createWorktreeFailed' }, ex as Error);\n\t\t\t}\n\t\t}\n\n\t\tif (options?.branchName != null && currentBranch?.name !== options.branchName) {\n\t\t\tconst checkoutRef = shouldCreate ? (currentBranch?.ref ?? 'HEAD') : options.branchName;\n\t\t\ttry {\n\t\t\t\tawait this.provider.ops?.checkout(targetPath, checkoutRef, {\n\t\t\t\t\tcreateBranch: shouldCreate ? options.branchName : undefined,\n\t\t\t\t});\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex);\n\t\t\t\tthrow new ApplyPatchCommitError({ reason: 'checkoutFailed', branch: options.branchName }, ex as Error);\n\t\t\t}\n\t\t}\n\n\t\t// Apply the patch using a cherry pick without committing\n\t\ttry {\n\t\t\tconst result = await this.provider.ops?.cherryPick(targetPath, [rev], { noCommit: true });\n\t\t\tif (result?.conflicted) {\n\t\t\t\tthrow new ApplyPatchCommitError({ reason: 'appliedWithConflicts' });\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof ApplyPatchCommitError) throw ex;\n\n\t\t\tscope?.error(ex);\n\n\t\t\tif (CherryPickError.is(ex, 'wouldOverwriteChanges')) {\n\t\t\t\tthrow new ApplyPatchCommitError({ reason: 'wouldOverwriteChanges' }, ex);\n\t\t\t}\n\n\t\t\tthrow new ApplyPatchCommitError({ reason: 'applyFailed' }, ex as Error);\n\t\t}\n\t}\n\n\t@debug({\n\t\targs: (repoPath, base, _message, _patch) => ({\n\t\t\trepoPath: repoPath,\n\t\t\tbase: base,\n\t\t\tmessage: '<message>',\n\t\t\tpatch: '<patch>',\n\t\t}),\n\t})\n\tasync createUnreachableCommitForPatch(\n\t\trepoPath: string,\n\t\tbase: string,\n\t\tmessage: string,\n\t\tpatch: string,\n\t\toptions?: { sign?: boolean; source?: unknown },\n\t): Promise<GitCommit | undefined> {\n\t\t// Create a temporary index file from the base ref\n\t\tawait using disposableIndex = await this.provider.staging.createTemporaryIndex(repoPath, 'ref', base);\n\t\tconst { env } = disposableIndex;\n\n\t\tconst sha = await this.createUnreachableCommitForPatchCore(\n\t\t\tenv,\n\t\t\trepoPath,\n\t\t\tbase,\n\t\t\tmessage,\n\t\t\tpatch,\n\t\t\tundefined,\n\t\t\toptions,\n\t\t);\n\t\t// await is needed for the disposableIndex to be disposed properly after\n\t\treturn await this.provider.commits.getCommit(repoPath, sha);\n\t}\n\n\t@debug({ args: (repoPath, base, patches) => ({ repoPath: repoPath, base: base, patches: patches.length }) })\n\tasync createUnreachableCommitsFromPatches(\n\t\trepoPath: string,\n\t\tbase: string | undefined,\n\t\tpatches: { message: string; patch: string; author?: GitCommitIdentityShape }[],\n\t\toptions?: { sign?: boolean; source?: unknown },\n\t): Promise<string[]> {\n\t\t// Create a temporary index file - use empty index if no base (orphan commits)\n\t\tawait using disposableIndex = base\n\t\t\t? await this.provider.staging.createTemporaryIndex(repoPath, 'ref', base)\n\t\t\t: await this.provider.staging.createTemporaryIndex(repoPath, 'empty');\n\t\tconst { env } = disposableIndex;\n\n\t\tconst shas: string[] = [];\n\n\t\tfor (const { message, patch, author } of patches) {\n\t\t\tconst sha = await this.createUnreachableCommitForPatchCore(\n\t\t\t\tenv,\n\t\t\t\trepoPath,\n\t\t\t\tbase,\n\t\t\t\tmessage,\n\t\t\t\tpatch,\n\t\t\t\tauthor,\n\t\t\t\toptions,\n\t\t\t);\n\t\t\tshas.push(sha);\n\t\t\tbase = sha;\n\t\t}\n\n\t\treturn shas;\n\t}\n\n\tprivate async createUnreachableCommitForPatchCore(\n\t\tenv: Record<string, string>,\n\t\trepoPath: string,\n\t\tbase: string | undefined,\n\t\tmessage: string,\n\t\tpatch: string,\n\t\tauthor?: GitCommitIdentityShape,\n\t\toptions?: { sign?: boolean; source?: unknown },\n\t): Promise<string> {\n\t\tconst scope = getScopedLogger();\n\n\t\tif (!patch.endsWith('\\n')) {\n\t\t\tpatch += '\\n';\n\t\t}\n\n\t\tlet shouldSign = options?.sign;\n\n\t\ttry {\n\t\t\tconst [signingConfigResult, applyResult] = await Promise.allSettled([\n\t\t\t\tthis.provider.config.getSigningConfig?.(repoPath),\n\t\t\t\t// Apply the patch to our temp index, without touching the working directory\n\t\t\t\tthis.git.run(\n\t\t\t\t\t{ cwd: repoPath, configs: gitConfigsLog, env: env, stdin: patch },\n\t\t\t\t\t'apply',\n\t\t\t\t\t'--cached',\n\t\t\t\t\t'-',\n\t\t\t\t),\n\t\t\t]);\n\t\t\tif (applyResult.status === 'rejected') throw applyResult.reason;\n\n\t\t\t// Check if we should sign\n\t\t\tconst signingConfig = getSettledValue(signingConfigResult);\n\t\t\tshouldSign ??= signingConfig?.enabled ?? false;\n\n\t\t\t// Create a new tree from our patched index\n\t\t\tconst result = await this.git.run({ cwd: repoPath, env: env }, 'write-tree');\n\t\t\tconst tree = result.stdout.trim();\n\n\t\t\treturn await this.provider.commits.createCommitFromTree(repoPath, tree, {\n\t\t\t\tparents: base ? [base] : [],\n\t\t\t\tmessage: message,\n\t\t\t\tauthor: author ? { name: author.name, email: author.email || '' } : undefined,\n\t\t\t\tsign: shouldSign,\n\t\t\t\tsource: options?.source,\n\t\t\t});\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\tasync createEmptyInitialCommit(repoPath: string): Promise<string> {\n\t\tconst emptyTree = await this.provider.revision.getEmptyTreeSha(repoPath);\n\t\tconst sha = await this.provider.commits.createCommitFromTree(repoPath, emptyTree, {\n\t\t\tparents: [],\n\t\t\tmessage: 'temp',\n\t\t});\n\t\t// Point HEAD at the still-unborn `main` first, then create the branch through HEAD, so the one write\n\t\t// that announces anything does so after both changes, announcing the head and the branch together\n\t\tawait this.git.run({ cwd: repoPath }, 'symbolic-ref', 'HEAD', 'refs/heads/main');\n\t\tawait this.provider.refs.updateReference(repoPath, 'HEAD', sha);\n\t\treturn sha;\n\t}\n\n\t@debug({ quiet: true, args: repoPath => ({ repoPath: repoPath }) })\n\tasync validatePatch(repoPath: string | undefined, contents: string): Promise<boolean> {\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, configs: gitConfigsLog, stdin: contents }, 'apply', '--check', '-');\n\t\t\treturn true;\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof RunError || ex instanceof GitError) {\n\t\t\t\tif ((ex.stderr ?? '').includes('No valid patches in input')) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Other git errors mean the patch had content but couldn't apply cleanly\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;AAaA,IAAa,sBAAb,MAAgE;CAE7C;CACA;CACA;CACA;CAJlB,YACC,SACA,KACA,OACA,UACC;EAJgB,KAAA,UAAA;EACA,KAAA,MAAA;EACA,KAAA,QAAA;EACA,KAAA,WAAA;CACf;CAEH,MACM,MAAM,UAAkB,OAAe,SAAiD;EAC7F,MAAM,OAAO,CAAC,SAAS,mBAAmB;EAC1C,IAAI,SAAS,UACZ,KAAK,KAAK,QAAQ;EAEnB,MAAM,KAAK,IAAI,IAAI;GAAE,KAAK;GAAU,OAAO;EAAM,GAAG,GAAG,IAAI;CAC5D;CAEA,MACM,+BACL,UACA,KACA,SAMgB;EAChB,MAAM,QAAQ,gBAAgB;EAE9B,IAAI,SAAS,OAEZ,IAAI;GACH,IAAI,MAAM,KAAK,SAAS,QAAQ,kBAAkB,QAAQ,GACzD,MAAM,KAAK,SAAS,MAAM,UAAU,UAAU,KAAA,GAAW,KAAA,GAAW,EACnE,kBAAkB,KACnB,CAAC;EAEH,SAAS,IAAI;GACZ,OAAO,MAAM,EAAE;GACf,MAAM,IAAI,sBAAsB,EAAE,QAAQ,cAAc,GAAG,EAAW;EACvE;EAGD,IAAI,aAAa;EACjB,MAAM,gBAAgB,MAAM,KAAK,SAAS,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IR,OAAO;GACR;GAEA,OAAO;EACR;CACD;AACD;AAxPE,WAAA,CAAA,MAAM,CAAA,GAAA,oBAAA,WAAA,SAAA,IAAA;AASN,WAAA,CAAA,MAAM,CAAA,GAAA,oBAAA,WAAA,kCAAA,IAAA;AA6FN,WAAA,CAAA,MAAM,EACN,OAAO,UAAU,MAAM,UAAU,YAAY;CAClC;CACJ;CACN,SAAS;CACT,OAAO;AACR,GACD,CAAC,CAAA,GAAA,oBAAA,WAAA,mCAAA,IAAA;AAyBA,WAAA,CAAA,MAAM,EAAE,OAAO,UAAU,MAAM,aAAa;CAAY;CAAgB;CAAM,SAAS,QAAQ;AAAO,GAAG,CAAC,CAAA,GAAA,oBAAA,WAAA,uCAAA,IAAA;AAgG1G,WAAA,CAAA,MAAM;CAAE,OAAO;CAAM,OAAM,cAAa,EAAY,SAAS;AAAG,CAAC,CAAA,GAAA,oBAAA,WAAA,iBAAA,IAAA"}
1
+ {"version":3,"file":"patch.js","names":[],"sources":["../../../../git-cli/src/providers/patch.ts"],"sourcesContent":["import type { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport { ApplyPatchCommitError, CherryPickError } from '@gitlens/git/errors.js';\nimport type { GitCommit, GitCommitIdentityShape } from '@gitlens/git/models/commit.js';\nimport type { GitPatchSubProvider } from '@gitlens/git/providers/patch.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { getSettledValue } from '@gitlens/utils/promise.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport { RunError } from '../exec/exec.errors.js';\nimport type { Git } from '../exec/git.js';\nimport { gitConfigsLog, GitError } from '../exec/git.js';\n\nexport class PatchGitSubProvider implements GitPatchSubProvider {\n\tconstructor(\n\t\tprivate readonly context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t) {}\n\n\t@debug()\n\tasync apply(repoPath: string, patch: string, options?: { threeWay?: boolean }): Promise<void> {\n\t\tconst args = ['apply', '--whitespace=warn'];\n\t\tif (options?.threeWay) {\n\t\t\targs.push('--3way');\n\t\t}\n\t\tawait this.git.run({ cwd: repoPath, stdin: patch }, ...args);\n\t}\n\n\t@debug()\n\tasync applyUnreachableCommitForPatch(\n\t\trepoPath: string,\n\t\trev: string,\n\t\toptions?: {\n\t\t\tbranchName?: string;\n\t\t\tcreateBranchIfNeeded?: boolean;\n\t\t\tcreateWorktreePath?: string;\n\t\t\tstash?: boolean;\n\t\t},\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\tif (options?.stash) {\n\t\t\t// Stash any changes first; a failed check for them fails the stash too\n\t\t\ttry {\n\t\t\t\tif (await this.provider.status?.hasWorkingChanges(repoPath)) {\n\t\t\t\t\tawait this.provider.stash.saveStash(repoPath, undefined, undefined, {\n\t\t\t\t\t\tincludeUntracked: true,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex);\n\t\t\t\tthrow new ApplyPatchCommitError({ reason: 'stashFailed' }, ex as Error);\n\t\t\t}\n\t\t}\n\n\t\tlet targetPath = repoPath;\n\t\tconst currentBranch = await this.provider.branches.getBranch(repoPath);\n\t\tconst branchExists =\n\t\t\toptions?.branchName == null ||\n\t\t\tcurrentBranch?.name === options.branchName ||\n\t\t\t(await this.provider.branches.getBranch(repoPath, options.branchName)) != null;\n\t\tconst shouldCreate = options?.branchName != null && !branchExists && options.createBranchIfNeeded;\n\n\t\tif (options?.createWorktreePath != null) {\n\t\t\tif (options?.branchName === null || options.branchName === currentBranch?.name) {\n\t\t\t\tthrow new ApplyPatchCommitError({ reason: 'createWorktreeFailed' });\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst worktree = await this.provider.worktrees?.createWorktreeWithResult(\n\t\t\t\t\trepoPath,\n\t\t\t\t\toptions.createWorktreePath,\n\t\t\t\t\t{\n\t\t\t\t\t\tcommitish:\n\t\t\t\t\t\t\toptions?.branchName != null && branchExists ? options.branchName : currentBranch?.name,\n\t\t\t\t\t\tcreateBranch: shouldCreate ? options.branchName : undefined,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tif (worktree == null) {\n\t\t\t\t\tthrow new ApplyPatchCommitError({ reason: 'createWorktreeFailed' });\n\t\t\t\t}\n\n\t\t\t\ttargetPath = worktree.path;\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex);\n\t\t\t\tthrow new ApplyPatchCommitError({ reason: 'createWorktreeFailed' }, ex as Error);\n\t\t\t}\n\t\t}\n\n\t\tif (options?.branchName != null && currentBranch?.name !== options.branchName) {\n\t\t\tconst checkoutRef = shouldCreate ? (currentBranch?.ref ?? 'HEAD') : options.branchName;\n\t\t\ttry {\n\t\t\t\tawait this.provider.ops?.checkout(targetPath, checkoutRef, {\n\t\t\t\t\tcreateBranch: shouldCreate ? options.branchName : undefined,\n\t\t\t\t});\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex);\n\t\t\t\tthrow new ApplyPatchCommitError({ reason: 'checkoutFailed', branch: options.branchName }, ex as Error);\n\t\t\t}\n\t\t}\n\n\t\t// Apply the patch using a cherry pick without committing\n\t\ttry {\n\t\t\tconst result = await this.provider.ops?.cherryPick(targetPath, [rev], { noCommit: true });\n\t\t\tif (result?.conflicted) {\n\t\t\t\tthrow new ApplyPatchCommitError({ reason: 'appliedWithConflicts' });\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof ApplyPatchCommitError) throw ex;\n\n\t\t\tscope?.error(ex);\n\n\t\t\tif (CherryPickError.is(ex, 'wouldOverwriteChanges')) {\n\t\t\t\tthrow new ApplyPatchCommitError({ reason: 'wouldOverwriteChanges' }, ex);\n\t\t\t}\n\n\t\t\tthrow new ApplyPatchCommitError({ reason: 'applyFailed' }, ex as Error);\n\t\t}\n\t}\n\n\t@debug({\n\t\targs: (repoPath, base, _message, _patch) => ({\n\t\t\trepoPath: repoPath,\n\t\t\tbase: base,\n\t\t\tmessage: '<message>',\n\t\t\tpatch: '<patch>',\n\t\t}),\n\t})\n\tasync createUnreachableCommitForPatch(\n\t\trepoPath: string,\n\t\tbase: string,\n\t\tmessage: string,\n\t\tpatch: string,\n\t\toptions?: { sign?: boolean; source?: unknown },\n\t): Promise<GitCommit | undefined> {\n\t\t// Create a temporary index file from the base ref\n\t\tawait using disposableIndex = await this.provider.staging.createTemporaryIndex(repoPath, 'ref', base);\n\t\tconst { env } = disposableIndex;\n\n\t\tconst sha = await this.createUnreachableCommitForPatchCore(\n\t\t\tenv,\n\t\t\trepoPath,\n\t\t\tbase,\n\t\t\tmessage,\n\t\t\tpatch,\n\t\t\tundefined,\n\t\t\toptions,\n\t\t);\n\t\t// await is needed for the disposableIndex to be disposed properly after\n\t\treturn await this.provider.commits.getCommit(repoPath, sha);\n\t}\n\n\t@debug({ args: (repoPath, base, patches) => ({ repoPath: repoPath, base: base, patches: patches.length }) })\n\tasync createUnreachableCommitsFromPatches(\n\t\trepoPath: string,\n\t\tbase: string | undefined,\n\t\tpatches: { message: string; patch: string; author?: GitCommitIdentityShape }[],\n\t\toptions?: { sign?: boolean; source?: unknown },\n\t): Promise<string[]> {\n\t\t// Create a temporary index file - use empty index if no base (orphan commits)\n\t\tawait using disposableIndex = base\n\t\t\t? await this.provider.staging.createTemporaryIndex(repoPath, 'ref', base)\n\t\t\t: await this.provider.staging.createTemporaryIndex(repoPath, 'empty');\n\t\tconst { env } = disposableIndex;\n\n\t\tconst shas: string[] = [];\n\n\t\tfor (const { message, patch, author } of patches) {\n\t\t\tconst sha = await this.createUnreachableCommitForPatchCore(\n\t\t\t\tenv,\n\t\t\t\trepoPath,\n\t\t\t\tbase,\n\t\t\t\tmessage,\n\t\t\t\tpatch,\n\t\t\t\tauthor,\n\t\t\t\toptions,\n\t\t\t);\n\t\t\tshas.push(sha);\n\t\t\tbase = sha;\n\t\t}\n\n\t\treturn shas;\n\t}\n\n\tprivate async createUnreachableCommitForPatchCore(\n\t\tenv: Record<string, string>,\n\t\trepoPath: string,\n\t\tbase: string | undefined,\n\t\tmessage: string,\n\t\tpatch: string,\n\t\tauthor?: GitCommitIdentityShape,\n\t\toptions?: { sign?: boolean; source?: unknown },\n\t): Promise<string> {\n\t\tconst scope = getScopedLogger();\n\n\t\tif (!patch.endsWith('\\n')) {\n\t\t\tpatch += '\\n';\n\t\t}\n\n\t\tlet shouldSign = options?.sign;\n\n\t\ttry {\n\t\t\tconst [signingConfigResult, applyResult] = await Promise.allSettled([\n\t\t\t\tthis.provider.config.getSigningConfig?.(repoPath),\n\t\t\t\t// Apply the patch to our temp index, without touching the working directory\n\t\t\t\tthis.git.run(\n\t\t\t\t\t{ cwd: repoPath, configs: gitConfigsLog, env: env, stdin: patch },\n\t\t\t\t\t'apply',\n\t\t\t\t\t'--cached',\n\t\t\t\t\t'-',\n\t\t\t\t),\n\t\t\t]);\n\t\t\tif (applyResult.status === 'rejected') throw applyResult.reason;\n\n\t\t\t// Check if we should sign\n\t\t\tconst signingConfig = getSettledValue(signingConfigResult);\n\t\t\tshouldSign ??= signingConfig?.enabled ?? false;\n\n\t\t\t// Create a new tree from our patched index\n\t\t\tconst result = await this.git.run({ cwd: repoPath, env: env }, 'write-tree');\n\t\t\tconst tree = result.stdout.trim();\n\n\t\t\treturn await this.provider.commits.createCommitFromTree(repoPath, tree, {\n\t\t\t\tparents: base ? [base] : [],\n\t\t\t\tmessage: message,\n\t\t\t\tauthor: author ? { name: author.name, email: author.email || '' } : undefined,\n\t\t\t\tsign: shouldSign,\n\t\t\t\tsource: options?.source,\n\t\t\t});\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\tasync createEmptyInitialCommit(repoPath: string): Promise<string> {\n\t\tconst emptyTree = await this.provider.revision.getEmptyTreeSha(repoPath);\n\t\tconst sha = await this.provider.commits.createCommitFromTree(repoPath, emptyTree, {\n\t\t\tparents: [],\n\t\t\tmessage: 'temp',\n\t\t});\n\t\t// Point HEAD at the still-unborn `main` first, then create the branch through HEAD, so the one write\n\t\t// that announces anything does so after both changes, announcing the head and the branch together\n\t\tawait this.git.run({ cwd: repoPath }, 'symbolic-ref', 'HEAD', 'refs/heads/main');\n\t\tawait this.provider.refs.updateReference(repoPath, 'HEAD', sha);\n\t\treturn sha;\n\t}\n\n\t@debug({ quiet: true, args: repoPath => ({ repoPath: repoPath }) })\n\tasync validatePatch(repoPath: string | undefined, contents: string): Promise<boolean> {\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, configs: gitConfigsLog, stdin: contents }, 'apply', '--check', '-');\n\t\t\treturn true;\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof RunError || ex instanceof GitError) {\n\t\t\t\tif ((ex.stderr ?? '').includes('No valid patches in input')) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Other git errors mean the patch had content but couldn't apply cleanly\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;AAaA,IAAa,sBAAb,MAAgE;CAE7C;CACA;CACA;CACA;CAJlB,YACC,SACA,KACA,OACA,UACC;EAJgB,KAAA,UAAA;EACA,KAAA,MAAA;EACA,KAAA,QAAA;EACA,KAAA,WAAA;CACf;CAEH,MACM,MAAM,UAAkB,OAAe,SAAiD;EAC7F,MAAM,OAAO,CAAC,SAAS,mBAAmB;EAC1C,IAAI,SAAS,UACZ,KAAK,KAAK,QAAQ;EAEnB,MAAM,KAAK,IAAI,IAAI;GAAE,KAAK;GAAU,OAAO;EAAM,GAAG,GAAG,IAAI;CAC5D;CAEA,MACM,+BACL,UACA,KACA,SAMgB;EAChB,MAAM,QAAQ,gBAAgB;EAE9B,IAAI,SAAS,OAEZ,IAAI;GACH,IAAI,MAAM,KAAK,SAAS,QAAQ,kBAAkB,QAAQ,GACzD,MAAM,KAAK,SAAS,MA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S;IAAe,OAAO;GAAS,GAAG,SAAS,WAAW,GAAG;GACtG,OAAO;EACR,SAAS,IAAI;GACZ,IAAI,cAAc,YAAY,cAAc,UAAU;IACrD,KAAK,GAAG,UAAU,GAAA,CAAI,SAAS,2BAA2B,GACzD,OAAO;IAIR,OAAO;GACR;GAEA,OAAO;EACR;CACD;AACD;AAvPE,WAAA,CAAA,MAAM,CAAA,GAAA,oBAAA,WAAA,SAAA,IAAA;AASN,WAAA,CAAA,MAAM,CAAA,GAAA,oBAAA,WAAA,kCAAA,IAAA;AA4FN,WAAA,CAAA,MAAM,EACN,OAAO,UAAU,MAAM,UAAU,YAAY;CAClC;CACJ;CACN,SAAS;CACT,OAAO;AACR,GACD,CAAC,CAAA,GAAA,oBAAA,WAAA,mCAAA,IAAA;AAyBA,WAAA,CAAA,MAAM,EAAE,OAAO,UAAU,MAAM,aAAa;CAAY;CAAgB;CAAM,SAAS,QAAQ;AAAO,GAAG,CAAC,CAAA,GAAA,oBAAA,WAAA,uCAAA,IAAA;AAgG1G,WAAA,CAAA,MAAM;CAAE,OAAO;CAAM,OAAM,cAAa,EAAY,SAAS;AAAG,CAAC,CAAA,GAAA,oBAAA,WAAA,iBAAA,IAAA"}
@@ -49,7 +49,7 @@ export declare class RefsGitSubProvider implements GitRefsSubProvider {
49
49
  /**
50
50
  * Like {@link getSymbolicReferenceName}, but tells a ref git confirmed doesn't exist (`rev-parse --verify` exit 1)
51
51
  * apart from a read that didn't complete (timeout, error, cancellation), which never reports `missing`.
52
- * Shares the same cached `rev-parse`, though only a found ref is cached: a missing one re-runs on every call.
52
+ * Shares the same cached `rev-parse`, which keeps a missing ref as it does a found one.
53
53
  */
54
54
  getSymbolicReferenceNameOrMissing(repoPath: string, ref: string, options?: {
55
55
  priority?: GitCommandPriority;
@@ -103,10 +103,14 @@ var RefsGitSubProvider = class {
103
103
  async getRefTips(repoPath, options, cancellation) {
104
104
  if (!repoPath) return [];
105
105
  const scope = getScopedLogger();
106
- const all = await this.cache.getRefTips(repoPath, async (_commonPath, _cacheable, signal) => {
106
+ const all = await this.cache.getRefTips(repoPath, async (_commonPath, cacheable, signal) => {
107
107
  try {
108
108
  var _usingCtx3 = _usingCtx();
109
109
  const records = await this.getRefs(repoPath, signal);
110
+ if (!records.length) {
111
+ cacheable.invalidate();
112
+ return [];
113
+ }
110
114
  const sw = _usingCtx3.u(maybeStopWatch(scope, { log: {
111
115
  onlyExit: true,
112
116
  level: "debug"
@@ -183,7 +187,7 @@ var RefsGitSubProvider = class {
183
187
  cancellation,
184
188
  configs: gitConfigsBranch
185
189
  }, "rev-list", "--topo-order", "--parents", "--all", `^${oldestSha}^@`);
186
- _usingCtx4.u(createDisposable(() => void stream.return?.(void 0)));
190
+ _usingCtx4.u(createDisposable(() => void stream.return?.(void 0)?.catch(() => {})));
187
191
  try {
188
192
  for await (const line of iterateAsyncByDelimiter(stream, "\n")) {
189
193
  if (cancellation?.aborted) throw new CancellationError();
@@ -304,7 +308,7 @@ var RefsGitSubProvider = class {
304
308
  /**
305
309
  * Like {@link getSymbolicReferenceName}, but tells a ref git confirmed doesn't exist (`rev-parse --verify` exit 1)
306
310
  * apart from a read that didn't complete (timeout, error, cancellation), which never reports `missing`.
307
- * Shares the same cached `rev-parse`, though only a found ref is cached: a missing one re-runs on every call.
311
+ * Shares the same cached `rev-parse`, which keeps a missing ref as it does a found one.
308
312
  */
309
313
  async getSymbolicReferenceNameOrMissing(repoPath, ref, options, cancellation) {
310
314
  const result = await this.runSymbolicReferenceName(repoPath, ref, options, cancellation);
@@ -319,6 +323,7 @@ var RefsGitSubProvider = class {
319
323
  cwd: repoPath,
320
324
  cancellation,
321
325
  errors: "ignore",
326
+ expectedExitCodes: [1],
322
327
  caching: {
323
328
  cache: this.cache.gitResults,
324
329
  options: { accessTTL: 6e4 }
@@ -328,14 +333,8 @@ var RefsGitSubProvider = class {
328
333
  }
329
334
  async hasBranchOrTag(repoPath, options, cancellation) {
330
335
  if (repoPath == null) return false;
331
- const [{ values: branches }, { values: tags }] = await Promise.all([this.provider.branches.getBranches(repoPath, {
332
- filter: options?.filter?.branches,
333
- sort: false
334
- }, cancellation), this.provider.tags.getTags(repoPath, {
335
- filter: options?.filter?.tags,
336
- sort: false
337
- }, cancellation)]);
338
- return branches.length !== 0 || tags.length !== 0;
336
+ if (await this.provider.branches.hasBranch(repoPath, options?.filter?.branches, cancellation)) return true;
337
+ return this.provider.tags.hasTag(repoPath, options?.filter?.tags, cancellation);
339
338
  }
340
339
  async isValidReference(repoPath, ref, pathOrUri, cancellation) {
341
340
  const path = pathOrUri != null ? toFsPath(pathOrUri) : void 0;