@gitkraken/core-gitlens 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/CHANGELOG.md +32 -1
  2. package/dist/git/cache.d.ts +11 -0
  3. package/dist/git/cache.js +26 -3
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/context.d.ts +3 -2
  6. package/dist/git/context.js.map +1 -1
  7. package/dist/git/features.d.ts +1 -1
  8. package/dist/git/features.js +1 -0
  9. package/dist/git/features.js.map +1 -1
  10. package/dist/git/models/reflog.d.ts +6 -0
  11. package/dist/git/models/reflog.js.map +1 -1
  12. package/dist/git/models/revision.d.ts +0 -1
  13. package/dist/git/models/revision.js +1 -2
  14. package/dist/git/models/revision.js.map +1 -1
  15. package/dist/git/providers/commits.d.ts +20 -1
  16. package/dist/git/providers/operations.d.ts +13 -0
  17. package/dist/git/providers/provider.d.ts +14 -4
  18. package/dist/git/providers/refs.d.ts +10 -0
  19. package/dist/git/providers/revision.d.ts +2 -0
  20. package/dist/git/providers/staging.d.ts +2 -1
  21. package/dist/git/providers/stash.d.ts +3 -2
  22. package/dist/git/providers/status.d.ts +4 -0
  23. package/dist/git/run.types.d.ts +16 -0
  24. package/dist/git-cli/cliGitProvider.d.ts +24 -3
  25. package/dist/git-cli/cliGitProvider.js +79 -17
  26. package/dist/git-cli/cliGitProvider.js.map +1 -1
  27. package/dist/git-cli/exec/commandClassifier.d.ts +31 -0
  28. package/dist/git-cli/exec/commandClassifier.js +391 -0
  29. package/dist/git-cli/exec/commandClassifier.js.map +1 -0
  30. package/dist/git-cli/exec/git.d.ts +24 -3
  31. package/dist/git-cli/exec/git.js +116 -12
  32. package/dist/git-cli/exec/git.js.map +1 -1
  33. package/dist/git-cli/parsers/reflogParser.d.ts +7 -0
  34. package/dist/git-cli/parsers/reflogParser.js +11 -1
  35. package/dist/git-cli/parsers/reflogParser.js.map +1 -1
  36. package/dist/git-cli/providers/branches.js +16 -14
  37. package/dist/git-cli/providers/branches.js.map +1 -1
  38. package/dist/git-cli/providers/commits.d.ts +4 -2
  39. package/dist/git-cli/providers/commits.js +55 -4
  40. package/dist/git-cli/providers/commits.js.map +1 -1
  41. package/dist/git-cli/providers/diff.js +4 -4
  42. package/dist/git-cli/providers/diff.js.map +1 -1
  43. package/dist/git-cli/providers/operations.d.ts +12 -0
  44. package/dist/git-cli/providers/operations.js +26 -3
  45. package/dist/git-cli/providers/operations.js.map +1 -1
  46. package/dist/git-cli/providers/patch.js +2 -5
  47. package/dist/git-cli/providers/patch.js.map +1 -1
  48. package/dist/git-cli/providers/refs.d.ts +5 -0
  49. package/dist/git-cli/providers/refs.js +26 -1
  50. package/dist/git-cli/providers/refs.js.map +1 -1
  51. package/dist/git-cli/providers/remotes.js +3 -2
  52. package/dist/git-cli/providers/remotes.js.map +1 -1
  53. package/dist/git-cli/providers/revision.d.ts +2 -0
  54. package/dist/git-cli/providers/revision.js +11 -0
  55. package/dist/git-cli/providers/revision.js.map +1 -1
  56. package/dist/git-cli/providers/staging.d.ts +2 -1
  57. package/dist/git-cli/providers/staging.js +12 -7
  58. package/dist/git-cli/providers/staging.js.map +1 -1
  59. package/dist/git-cli/providers/stash.d.ts +3 -2
  60. package/dist/git-cli/providers/stash.js +34 -22
  61. package/dist/git-cli/providers/stash.js.map +1 -1
  62. package/dist/git-cli/providers/status.d.ts +2 -0
  63. package/dist/git-cli/providers/status.js +27 -9
  64. package/dist/git-cli/providers/status.js.map +1 -1
  65. package/dist/plus/git-github/providers/github/commits.d.ts +4 -2
  66. package/dist/plus/git-github/providers/github/commits.js +3 -1
  67. package/dist/plus/git-github/providers/github/commits.js.map +1 -1
  68. package/dist/plus/git-github/providers/github/revision.d.ts +1 -0
  69. package/dist/plus/git-github/providers/github/revision.js +5 -0
  70. package/dist/plus/git-github/providers/github/revision.js.map +1 -1
  71. package/docs/kepler-git-write-api-parity.md +140 -14
  72. 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 { 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 { getBranchNameAndRemote, getBranchTrackingWithoutRemote } from '@gitlens/git/utils/branch.utils.js';\nimport { isBranchReference } from '@gitlens/git/utils/reference.utils.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 type { Git, PushForceOptions } from '../exec/git.js';\nimport {\n\tclassifySigningError,\n\tgetGitCommandError,\n\tgitConfigsPull,\n\tGitErrors,\n\tinferSigningFormatFromError,\n\tmaxGitCliLength,\n} from '../exec/git.js';\n\nexport class OperationsGitSubProvider implements GitOperationsSubProvider {\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 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 this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...params);\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\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'index']);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\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}\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.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...args);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'index']);\n\t\t\treturn { conflicted: false };\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\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\tawait this.git.run(\n\t\t\t\t{ cwd: repoPath, stdin: message, stdinEncoding: 'utf8', errors: 'throw', ...runOptions },\n\t\t\t\t...params,\n\t\t\t);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'index']);\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\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?: { all?: boolean; branch?: GitBranchReference; prune?: boolean; pull?: boolean; remote?: string },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst { branch, ...opts } = options ?? {};\n\t\ttry {\n\t\t\tif (isBranchReference(branch)) {\n\t\t\t\tconst [branchName, remoteName] = getBranchNameAndRemote(branch);\n\t\t\t\tif (remoteName == null) return;\n\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: branchName,\n\t\t\t\t\t\tremote: remoteName,\n\t\t\t\t\t\tupstream: getBranchTrackingWithoutRemote(branch)!,\n\t\t\t\t\t\tpull: options?.pull,\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\tawait this.fetchCore(repoPath, opts, runOptions);\n\t\t\t}\n\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'tags');\n\t\t\t// A `pull` fetch writes `<upstream>:<branch>`, moving the local branch too\n\t\t\tthis.context.hooks?.repository?.onChanged?.(\n\t\t\t\trepoPath,\n\t\t\t\tisBranchReference(branch) && options?.pull ? ['heads', 'remotes'] : ['remotes'],\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\tprivate async fetchCore(\n\t\trepoPath: string,\n\t\toptions:\n\t\t\t| { all?: boolean; branch?: undefined; prune?: boolean; pull?: boolean; remote?: string }\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 },\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.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.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\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.git.run(\n\t\t\t\t// Avoid a timeout since merges can take a long time (set to 0 to disable)\n\t\t\t\t{ cwd: repoPath, errors: 'throw', timeout: 0, ...runOptions },\n\t\t\t\t...args,\n\t\t\t);\n\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'index']);\n\t\t\treturn { conflicted: false };\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\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\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.branch?.name === 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\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} finally {\n\t\t\t\t\t\tthis.context.hooks?.operations?.onRebaseCapableOperation?.(worktreePath, 'pull', 'ended');\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status', 'tags');\n\t\t\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'remotes', 'index']);\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 [branchName, remoteName] = getBranchNameAndRemote(branch);\n\t\t\t\t\tconst upstream = getBranchTrackingWithoutRemote(branch);\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\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\n\t\t\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'tags');\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\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['heads', 'remotes']);\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\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} finally {\n\t\t\t\tthis.context.hooks?.operations?.onRebaseCapableOperation?.(repoPath, 'pull', 'ended');\n\t\t\t}\n\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status', 'tags');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'remotes', 'index']);\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 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 this.git.run({ cwd: repoPath, configs: gitConfigsPull, errors: 'throw', ...runOptions }, ...params);\n\t\t} catch (ex) {\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\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\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\t[branchName, remoteName] = getBranchNameAndRemote(options.reference);\n\t\t\t}\n\t\t\tupstreamName = getBranchTrackingWithoutRemote(options.reference);\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\tif (options?.reference != null) {\n\t\t\t\tbranchName = `${options.reference.ref}:${\n\t\t\t\t\toptions?.publish != null ? 'refs/heads/' : ''\n\t\t\t\t}${branch.nameWithoutRemote}`;\n\t\t\t} else {\n\t\t\t\tconst tracking = options?.publish == null ? branch.trackingWithoutRemote : undefined;\n\t\t\t\tbranchName =\n\t\t\t\t\ttracking != null && tracking !== branch.nameWithoutRemote\n\t\t\t\t\t\t? `${branch.name}:${tracking}`\n\t\t\t\t\t\t: branch.name;\n\t\t\t}\n\t\t\tremoteName = branch.remoteName ?? options?.publish?.remote;\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: branch.nameWithoutRemote,\n\t\t\t\t\tremote: remoteName!,\n\t\t\t\t\tremoteBranch: branch.nameWithoutRemote,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tif (options?.publish == null && remoteName == null && upstreamName == null) {\n\t\t\tthrow new PushError({ reason: 'other' });\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\tpublish: options?.publish != null,\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\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(\n\t\t\t\trepoPath,\n\t\t\t\toptions?.publish != null ? ['config', 'heads', 'remotes'] : ['remotes'],\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\tprivate async pushCore(\n\t\trepoPath: string,\n\t\toptions: {\n\t\t\tbranch?: string;\n\t\t\tforce?: PushForceOptions;\n\t\t\tpublish?: 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\tif (options.branch && options.remote) {\n\t\t\tif (options.upstream) {\n\t\t\t\tparams.push('-u', options.remote, `${options.branch}:${options.upstream}`);\n\t\t\t} else if (options.publish) {\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\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\tawait this.git.run(\n\t\t\t\t// Avoid a timeout since rebases can take a long time (set to 0 to disable)\n\t\t\t\t{ cwd: repoPath, errors: 'throw', configs: configs, timeout: 0, ...runOptions, env: env },\n\t\t\t\t...args,\n\t\t\t);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'index']);\n\t\t\treturn { conflicted: false };\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\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.resetCore(repoPath, rev, options?.mode, runOptions);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'index']);\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 this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...params);\n\t\t} catch (ex) {\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\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\tawait this.git.run(\n\t\t\t\t\t{ cwd: repoPath, errors: 'throw', ...runOptions, stdin: normalized.join('\\0') },\n\t\t\t\t\t...args,\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\tfor (const batch of chunkByStringLength(normalized, maxGitCliLength - prefixLength, perArgOverhead)) {\n\t\t\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...prefix, ...batch);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'status');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['index']);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\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}\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.git.run(\n\t\t\t\t// Avoid a timeout since reverts can take a long time (set to 0 to disable)\n\t\t\t\t{ cwd: repoPath, errors: 'throw', timeout: 0, ...runOptions },\n\t\t\t\t...args,\n\t\t\t);\n\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'index']);\n\t\t\treturn { conflicted: false };\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\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\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\t// A conflicted op mutates the working tree, index, and paused-op state — invalidate caches\n\t\t// and fire repository-change the same way the success path does, so downstream views refresh.\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status');\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'index']);\n\t\tthis.context.hooks?.operations?.onConflicted?.(command, conflicts);\n\t\treturn { conflicted: true, conflicts: conflicts };\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AA2CA,IAAa,2BAAb,MAA0E;CAEvD;CACA;CACA;CACA;CAJlB,YACC,SACA,KACA,OACA,UACC;EAJgB,KAAA,UAAA;EACA,KAAA,MAAA;EACA,KAAA,QAAA;EACA,KAAA,WAAA;CACf;CAEH,MACM,SACL,UACA,KACA,SACA,YACgB;EAChB,MAAM,QAAQ,gBAAgB;EAE9B,MAAM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AAA,yBAAA,WAAA,QAAA,IAAA;AAqJN,WAAA,CAAA,cAAc,EAAE,cAAa,OAAM,GAAG,CAAC,GACvC,MAAM,CAAA,GAAA,yBAAA,WAAA,QAAA,IAAA;AAoNN,WAAA,CAAA,cAAc,EAAE,cAAa,OAAM,GAAG,CAAC,GACvC,MAAM,CAAA,GAAA,yBAAA,WAAA,UAAA,IAAA;AAmHN,WAAA,CAAA,MAAM,CAAA,GAAA,yBAAA,WAAA,SAAA,IAAA;AA2CN,WAAA,CAAA,cAAc,EAAE,cAAa,OAAM,GAAG,CAAC,GACvC,MAAM,CAAA,GAAA,yBAAA,WAAA,WAAA,IAAA;AAmEN,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 { getBranchNameAndRemote, getBranchTrackingWithoutRemote } from '@gitlens/git/utils/branch.utils.js';\nimport { isBranchReference } from '@gitlens/git/utils/reference.utils.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 type { Git, PushForceOptions } from '../exec/git.js';\nimport {\n\tclassifySigningError,\n\tgetGitCommandError,\n\tgitConfigsPull,\n\tGitErrors,\n\tinferSigningFormatFromError,\n\tmaxGitCliLength,\n} from '../exec/git.js';\n\nexport class OperationsGitSubProvider implements GitOperationsSubProvider {\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 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 this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...params);\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\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'index']);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\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}\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.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...args);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'index']);\n\t\t\treturn { conflicted: false };\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\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\tawait this.git.run(\n\t\t\t\t{ cwd: repoPath, stdin: message, stdinEncoding: 'utf8', errors: 'throw', ...runOptions },\n\t\t\t\t...params,\n\t\t\t);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'index']);\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\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\ttry {\n\t\t\tif (isBranchReference(branch)) {\n\t\t\t\tconst [branchName, remoteName] = getBranchNameAndRemote(branch);\n\t\t\t\tif (remoteName == null) return;\n\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: branchName,\n\t\t\t\t\t\tremote: remoteName,\n\t\t\t\t\t\tupstream: getBranchTrackingWithoutRemote(branch)!,\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\tawait this.fetchCore(repoPath, opts, runOptions);\n\t\t\t}\n\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'tags');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, this.getFetchChanges(branch, options));\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tthrow ex;\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 stripped = refspec.startsWith('+') ? refspec.slice(1) : refspec;\n\t\t\tconst colonIndex = stripped.indexOf(':');\n\t\t\tif (colonIndex === -1) continue;\n\n\t\t\t// Qualified as git's fetch does: an empty destination stores nothing, `heads/`/`tags/`/`remotes/`\n\t\t\t// get `refs/`, and any other unqualified name is a local branch\n\t\t\tlet destination = stripped.slice(colonIndex + 1);\n\t\t\tif (!destination) continue;\n\n\t\t\tif (!destination.startsWith('refs/')) {\n\t\t\t\tdestination = /^(?:heads|tags|remotes)\\//.test(destination)\n\t\t\t\t\t? `refs/${destination}`\n\t\t\t\t\t: `refs/heads/${destination}`;\n\t\t\t}\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\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.git.run(\n\t\t\t\t// Avoid a timeout since merges can take a long time (set to 0 to disable)\n\t\t\t\t{ cwd: repoPath, errors: 'throw', timeout: 0, ...runOptions },\n\t\t\t\t...args,\n\t\t\t);\n\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'index']);\n\t\t\treturn { conflicted: false };\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\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\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.branch?.name === 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\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} finally {\n\t\t\t\t\t\tthis.context.hooks?.operations?.onRebaseCapableOperation?.(worktreePath, 'pull', 'ended');\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status', 'tags');\n\t\t\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'remotes', 'index']);\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 [branchName, remoteName] = getBranchNameAndRemote(branch);\n\t\t\t\t\tconst upstream = getBranchTrackingWithoutRemote(branch);\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\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\n\t\t\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'tags');\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\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['heads', 'remotes']);\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\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} finally {\n\t\t\t\tthis.context.hooks?.operations?.onRebaseCapableOperation?.(repoPath, 'pull', 'ended');\n\t\t\t}\n\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status', 'tags');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'remotes', 'index']);\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 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 this.git.run({ cwd: repoPath, configs: gitConfigsPull, errors: 'throw', ...runOptions }, ...params);\n\t\t} catch (ex) {\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\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\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\t[branchName, remoteName] = getBranchNameAndRemote(options.reference);\n\t\t\t}\n\t\t\tupstreamName = getBranchTrackingWithoutRemote(options.reference);\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\tif (options?.reference != null) {\n\t\t\t\tbranchName = `${options.reference.ref}:${\n\t\t\t\t\toptions?.publish != null ? 'refs/heads/' : ''\n\t\t\t\t}${branch.nameWithoutRemote}`;\n\t\t\t} else {\n\t\t\t\tconst tracking = options?.publish == null ? branch.trackingWithoutRemote : undefined;\n\t\t\t\tbranchName =\n\t\t\t\t\ttracking != null && tracking !== branch.nameWithoutRemote\n\t\t\t\t\t\t? `${branch.name}:${tracking}`\n\t\t\t\t\t\t: branch.name;\n\t\t\t}\n\t\t\tremoteName = branch.remoteName ?? options?.publish?.remote;\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: branch.nameWithoutRemote,\n\t\t\t\t\tremote: remoteName!,\n\t\t\t\t\tremoteBranch: branch.nameWithoutRemote,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tif (options?.publish == null && remoteName == null && upstreamName == null) {\n\t\t\tthrow new PushError({ reason: 'other' });\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\tpublish: options?.publish != null,\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\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(\n\t\t\t\trepoPath,\n\t\t\t\toptions?.publish != null ? ['config', 'heads', 'remotes'] : ['remotes'],\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\tprivate async pushCore(\n\t\trepoPath: string,\n\t\toptions: {\n\t\t\tbranch?: string;\n\t\t\tforce?: PushForceOptions;\n\t\t\tpublish?: 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\tif (options.branch && options.remote) {\n\t\t\tif (options.upstream) {\n\t\t\t\tparams.push('-u', options.remote, `${options.branch}:${options.upstream}`);\n\t\t\t} else if (options.publish) {\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\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\tawait this.git.run(\n\t\t\t\t// Avoid a timeout since rebases can take a long time (set to 0 to disable)\n\t\t\t\t{ cwd: repoPath, errors: 'throw', configs: configs, timeout: 0, ...runOptions, env: env },\n\t\t\t\t...args,\n\t\t\t);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'index']);\n\t\t\treturn { conflicted: false };\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\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.resetCore(repoPath, rev, options?.mode, runOptions);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'index']);\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 this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...params);\n\t\t} catch (ex) {\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\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\tawait this.git.run(\n\t\t\t\t\t{ cwd: repoPath, errors: 'throw', ...runOptions, stdin: normalized.join('\\0') },\n\t\t\t\t\t...args,\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\tfor (const batch of chunkByStringLength(normalized, maxGitCliLength - prefixLength, perArgOverhead)) {\n\t\t\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...prefix, ...batch);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'status');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['index']);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\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}\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.git.run(\n\t\t\t\t// Avoid a timeout since reverts can take a long time (set to 0 to disable)\n\t\t\t\t{ cwd: repoPath, errors: 'throw', timeout: 0, ...runOptions },\n\t\t\t\t...args,\n\t\t\t);\n\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'index']);\n\t\t\treturn { conflicted: false };\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\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\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\t// A conflicted op mutates the working tree, index, and paused-op state — invalidate caches\n\t\t// and fire repository-change the same way the success path does, so downstream views refresh.\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'status');\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['head', 'heads', 'index']);\n\t\tthis.context.hooks?.operations?.onConflicted?.(command, conflicts);\n\t\treturn { conflicted: true, conflicts: conflicts };\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AA4CA,IAAa,2BAAb,MAA0E;CAEvD;CACA;CACA;CACA;CAJlB,YACC,SACA,KACA,OACA,UACC;EAJgB,KAAA,UAAA;EACA,KAAA,MAAA;EACA,KAAA,QAAA;EACA,KAAA,WAAA;CACf;CAEH,MACM,SACL,UACA,KACA,SACA,YACgB;EAChB,MAAM,QAAQ,gBAAgB;EAE9B,MAAM,SAAS,CAAC,UAAU;EAC1B,IAAI,SAAS,cAAc;GAC1B,OAAO,KAAK,M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WAAA,WAAA,IAAA;AAmEN,WAAA,CAAA,cAAc,EAAE,cAAa,OAAM,GAAG,CAAC,GACvC,MAAM,CAAA,GAAA,yBAAA,WAAA,UAAA,IAAA"}
@@ -138,11 +138,8 @@ var PatchGitSubProvider = class {
138
138
  }
139
139
  }
140
140
  async createEmptyInitialCommit(repoPath) {
141
- const emptyTree = await this.git.run({
142
- cwd: repoPath,
143
- stdin: ""
144
- }, "hash-object", "-t", "tree", "--stdin");
145
- const sha = await this.provider.commits.createCommitFromTree(repoPath, emptyTree.stdout.trim(), {
141
+ const emptyTree = await this.provider.revision.getEmptyTreeSha(repoPath);
142
+ const sha = await this.provider.commits.createCommitFromTree(repoPath, emptyTree, {
146
143
  parents: [],
147
144
  message: "temp"
148
145
  });
@@ -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\n\t\t\tconst hasChanges = await this.provider.status?.hasWorkingChanges(repoPath);\n\t\t\tif (hasChanges) {\n\t\t\t\ttry {\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} catch (ex) {\n\t\t\t\t\tscope?.error(ex);\n\t\t\t\t\tthrow new ApplyPatchCommitError({ reason: 'stashFailed' }, ex as Error);\n\t\t\t\t}\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.git.run({ cwd: repoPath, stdin: '' }, 'hash-object', '-t', 'tree', '--stdin');\n\t\tconst sha = await this.provider.commits.createCommitFromTree(repoPath, emptyTree.stdout.trim(), {\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({ 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,OAGR;OAAA,MADqB,KAAK,SAAS,QAAQ,kBAAkB,QAAQ,GAExE,IAAI;IACH,MAAM,KAAK,SAAS,MAAM,UAAU,UAAU,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AO;CACR;CAEA,MACM,cAAc,UAA8B,UAAoC;EACrF,IAAI;GACH,MAAM,KAAK,IAAI,IAAI;IAAE,KAAK;IAAU,SAAS;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;AAzPE,WAAA,CAAA,MAAM,CAAA,GAAA,oBAAA,WAAA,SAAA,IAAA;AASN,WAAA,CAAA,MAAM,CAAA,GAAA,oBAAA,WAAA,kCAAA,IAAA;AA8FN,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,EAAE,OAAM,cAAa,EAAY,SAAS,GAAG,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\n\t\t\tconst hasChanges = await this.provider.status?.hasWorkingChanges(repoPath);\n\t\t\tif (hasChanges) {\n\t\t\t\ttry {\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} catch (ex) {\n\t\t\t\t\tscope?.error(ex);\n\t\t\t\t\tthrow new ApplyPatchCommitError({ reason: 'stashFailed' }, ex as Error);\n\t\t\t\t}\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({ 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,mBAA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AAQ;EACvE,MAAM,MAAM,MAAM,KAAK,SAAS,QAAQ,qBAAqB,UAAU,WAAW;GACjF,SAAS,CAAC;GACV,SAAS;EACV,CAAC;EAGD,MAAM,KAAK,IAAI,IAAI,EAAE,KAAK,SAAS,GAAG,gBAAgB,QAAQ,iBAAiB;EAC/E,MAAM,KAAK,SAAS,KAAK,gBAAgB,UAAU,QAAQ,GAAG;EAC9D,OAAO;CACR;CAEA,MACM,cAAc,UAA8B,UAAoC;EACrF,IAAI;GACH,MAAM,KAAK,IAAI,IAAI;IAAE,KAAK;IAAU,SAAS;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;AAzPE,WAAA,CAAA,MAAM,CAAA,GAAA,oBAAA,WAAA,SAAA,IAAA;AASN,WAAA,CAAA,MAAM,CAAA,GAAA,oBAAA,WAAA,kCAAA,IAAA;AA8FN,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,EAAE,OAAM,cAAa,EAAY,SAAS,GAAG,CAAC,CAAA,GAAA,oBAAA,WAAA,iBAAA,IAAA"}
@@ -4,6 +4,7 @@ import { GitBranch } from "../../git/models/branch.js";
4
4
  import { GitServiceContext } from "../../git/context.js";
5
5
  import { GitTag } from "../../git/models/tag.js";
6
6
  import { GitCommandPriority } from "../../git/run.types.js";
7
+ import { GitReflogEntry } from "../../git/models/reflog.js";
7
8
  import { Cache } from "../../git/cache.js";
8
9
  import { GitRefsSubProvider } from "../../git/providers/refs.js";
9
10
  import { Git } from "../exec/git.js";
@@ -35,6 +36,10 @@ export declare class RefsGitSubProvider implements GitRefsSubProvider {
35
36
  forkPoint?: boolean;
36
37
  priority?: GitCommandPriority;
37
38
  }, cancellation?: AbortSignal): Promise<string | undefined>;
39
+ getReflogEntries(repoPath: string, ref: string, options?: {
40
+ grep?: string;
41
+ priority?: GitCommandPriority;
42
+ }, cancellation?: AbortSignal): Promise<GitReflogEntry[]>;
38
43
  getReference(repoPath: string, ref: string, options?: {
39
44
  force?: boolean;
40
45
  }, cancellation?: AbortSignal): Promise<GitReference | undefined>;
@@ -9,11 +9,12 @@ import { createReference } from "../../git/utils/reference.utils.js";
9
9
  import __decorate from "../../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
10
10
  import { ReferenceUpdateError } from "../../git/errors.js";
11
11
  import { createDisposable } from "../../utils/disposable.js";
12
- import { getGitCommandError, gitConfigsBranch } from "../exec/git.js";
12
+ import { getGitCommandError, gitConfigsBranch, gitConfigsLog } from "../exec/git.js";
13
13
  import { maybeStopWatch } from "../../utils/stopwatch.js";
14
14
  import _usingCtx from "../../_virtual/@oxc-project+runtime/helpers/esm/usingCtx.js";
15
15
  import { isRemoteHEAD } from "../../git/utils/branch.utils.js";
16
16
  import { compareRefTips } from "../../git/utils/sorting.js";
17
+ import { getReflogEntryParser } from "../parsers/reflogParser.js";
17
18
  import { getRefParser } from "../parsers/refParser.js";
18
19
  //#region ../git-cli/src/providers/refs.ts
19
20
  var RefsGitSubProvider = class {
@@ -243,6 +244,29 @@ var RefsGitSubProvider = class {
243
244
  return;
244
245
  }
245
246
  }
247
+ async getReflogEntries(repoPath, ref, options, cancellation) {
248
+ const parser = getReflogEntryParser();
249
+ const args = [
250
+ "reflog",
251
+ "show",
252
+ ...parser.arguments
253
+ ];
254
+ if (options?.grep) args.push(`--grep-reflog=${options.grep}`);
255
+ args.push(ref, "--");
256
+ const result = await this.git.run({
257
+ cwd: repoPath,
258
+ errors: "throw",
259
+ cancellation,
260
+ configs: gitConfigsLog,
261
+ ...options?.priority != null ? { priority: options.priority } : void 0
262
+ }, ...args);
263
+ const entries = [];
264
+ for (const entry of parser.parse(result.stdout)) entries.push({
265
+ sha: entry.sha,
266
+ message: entry.subject
267
+ });
268
+ return entries;
269
+ }
246
270
  async getReference(repoPath, ref, options, cancellation) {
247
271
  if (!ref || ref === "0000000000000000000000000000000000000000-") return void 0;
248
272
  if (!(options?.force ? await this.validateReference(repoPath, ref, { force: true }, cancellation) : await this.isValidReference(repoPath, ref, void 0, cancellation))) return void 0;
@@ -429,6 +453,7 @@ __decorate([debug()], RefsGitSubProvider.prototype, "getRefs", null);
429
453
  __decorate([debug()], RefsGitSubProvider.prototype, "getRefTips", null);
430
454
  __decorate([debug()], RefsGitSubProvider.prototype, "getRefsContainingShas", null);
431
455
  __decorate([debug()], RefsGitSubProvider.prototype, "getMergeBase", null);
456
+ __decorate([debug()], RefsGitSubProvider.prototype, "getReflogEntries", null);
432
457
  __decorate([debug()], RefsGitSubProvider.prototype, "getReference", null);
433
458
  __decorate([debug()], RefsGitSubProvider.prototype, "getSymbolicReferenceName", null);
434
459
  __decorate([debug({ args: (repoPath) => ({ repoPath }) })], RefsGitSubProvider.prototype, "hasBranchOrTag", null);