@gitkraken/core-gitlens 0.11.1 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +84 -1
- package/dist/git/cache.d.ts +84 -29
- package/dist/git/cache.js +188 -54
- package/dist/git/cache.js.map +1 -1
- package/dist/git/features.d.ts +1 -1
- package/dist/git/features.js +4 -0
- package/dist/git/features.js.map +1 -1
- package/dist/git/models/branch.d.ts +15 -2
- package/dist/git/models/branch.js +27 -5
- package/dist/git/models/branch.js.map +1 -1
- package/dist/git/models/issue.d.ts +3 -1
- package/dist/git/models/issue.js.map +1 -1
- package/dist/git/models/status.js +1 -1
- package/dist/git/models/worktree.d.ts +4 -1
- package/dist/git/models/worktree.js +4 -2
- package/dist/git/models/worktree.js.map +1 -1
- package/dist/git/providers/branches.d.ts +73 -8
- package/dist/git/providers/pausedOperations.d.ts +6 -0
- package/dist/git/providers/provider.d.ts +34 -2
- package/dist/git/providers/status.d.ts +8 -2
- package/dist/git/remotes/azure-devops.js +61 -53
- package/dist/git/remotes/azure-devops.js.map +1 -1
- package/dist/git/service.d.ts +8 -5
- package/dist/git/service.js +16 -8
- package/dist/git/service.js.map +1 -1
- package/dist/git/utils/branch.utils.d.ts +8 -1
- package/dist/git/utils/branch.utils.js +30 -1
- package/dist/git/utils/branch.utils.js.map +1 -1
- package/dist/git/utils/issue.utils.d.ts +3 -1
- package/dist/git/utils/issue.utils.js +5 -1
- package/dist/git/utils/issue.utils.js.map +1 -1
- package/dist/git/watching/changeEvent.d.ts +13 -2
- package/dist/git/watching/changeEvent.js +17 -3
- package/dist/git/watching/changeEvent.js.map +1 -1
- package/dist/git/watching/gitDirPoller.d.ts +111 -0
- package/dist/git/watching/gitDirPoller.js +266 -0
- package/dist/git/watching/gitDirPoller.js.map +1 -0
- package/dist/git/watching/provider.d.ts +16 -0
- package/dist/git/watching/watchGroup.d.ts +40 -4
- package/dist/git/watching/watchGroup.js +143 -17
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git/watching/watchService.d.ts +70 -1
- package/dist/git/watching/watchService.js +158 -13
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git/watching/watchSession.d.ts +44 -0
- package/dist/git/watching/watchSession.js +91 -6
- package/dist/git/watching/watchSession.js.map +1 -1
- package/dist/git/watching/watcherPatterns.d.ts +21 -0
- package/dist/git/watching/watcherPatterns.js +67 -1
- package/dist/git/watching/watcherPatterns.js.map +1 -1
- package/dist/git/watching/worktreeSummary.d.ts +34 -7
- package/dist/git/watching/worktreeSummary.js +39 -12
- package/dist/git/watching/worktreeSummary.js.map +1 -1
- package/dist/git-cli/cliGitProvider.d.ts +34 -2
- package/dist/git-cli/cliGitProvider.js +119 -17
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/exec/commandClassifier.d.ts +15 -0
- package/dist/git-cli/exec/commandClassifier.js +48 -2
- package/dist/git-cli/exec/commandClassifier.js.map +1 -1
- package/dist/git-cli/exec/git.d.ts +15 -3
- package/dist/git-cli/exec/git.js +38 -17
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/exec/gitQueue.d.ts +2 -0
- package/dist/git-cli/exec/gitQueue.js +2 -1
- package/dist/git-cli/exec/gitQueue.js.map +1 -1
- package/dist/git-cli/exec/indexLock.d.ts +38 -0
- package/dist/git-cli/exec/indexLock.js +150 -0
- package/dist/git-cli/exec/indexLock.js.map +1 -0
- package/dist/git-cli/parsers/worktreeParser.js +42 -2
- package/dist/git-cli/parsers/worktreeParser.js.map +1 -1
- package/dist/git-cli/providers/branches.d.ts +109 -10
- package/dist/git-cli/providers/branches.js +624 -131
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/config.d.ts +9 -5
- package/dist/git-cli/providers/config.js +60 -27
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/operations.d.ts +17 -0
- package/dist/git-cli/providers/operations.js +153 -96
- package/dist/git-cli/providers/operations.js.map +1 -1
- package/dist/git-cli/providers/pausedOperations.d.ts +8 -0
- package/dist/git-cli/providers/pausedOperations.js +60 -40
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/git-cli/providers/refs.js +11 -8
- package/dist/git-cli/providers/refs.js.map +1 -1
- package/dist/git-cli/providers/remotes.js +19 -10
- package/dist/git-cli/providers/remotes.js.map +1 -1
- package/dist/git-cli/providers/staging.js +40 -15
- package/dist/git-cli/providers/staging.js.map +1 -1
- package/dist/git-cli/providers/stash.d.ts +2 -0
- package/dist/git-cli/providers/stash.js +33 -18
- package/dist/git-cli/providers/stash.js.map +1 -1
- package/dist/git-cli/providers/status.d.ts +3 -1
- package/dist/git-cli/providers/status.js +38 -20
- package/dist/git-cli/providers/status.js.map +1 -1
- package/dist/git-cli/providers/tags.js +6 -4
- package/dist/git-cli/providers/tags.js.map +1 -1
- package/dist/git-cli/providers/worktrees.d.ts +1 -0
- package/dist/git-cli/providers/worktrees.js +60 -31
- package/dist/git-cli/providers/worktrees.js.map +1 -1
- package/dist/git-cli/service.d.ts +6 -0
- package/dist/git-cli/service.js +5 -2
- package/dist/git-cli/service.js.map +1 -1
- package/dist/ipc/discovery.js +1 -1
- package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
- package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
- package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
- package/dist/plus/git-github/providers/github/status.d.ts +3 -1
- package/dist/plus/git-github/providers/github/status.js +1 -1
- package/dist/plus/git-github/providers/github/status.js.map +1 -1
- package/dist/plus/integrations/collectionMetadata.d.ts +13 -2
- package/dist/plus/integrations/collectionMetadata.js +14 -2
- package/dist/plus/integrations/collectionMetadata.js.map +1 -1
- package/dist/plus/integrations/index.d.ts +2 -2
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +1 -0
- package/dist/plus/integrations/integrationService.js +1 -1
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +1 -0
- package/dist/plus/integrations/models/gitHostIntegration.d.ts +41 -5
- package/dist/plus/integrations/models/gitHostIntegration.js +109 -30
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
- package/dist/plus/integrations/models/integration.js +1 -1
- package/dist/plus/integrations/models/issueReads.d.ts +17 -4
- package/dist/plus/integrations/providers/apiClients.d.ts +2 -0
- package/dist/plus/integrations/providers/apiClients.js +7 -1
- package/dist/plus/integrations/providers/apiClients.js.map +1 -1
- package/dist/plus/integrations/providers/azure/azure.d.ts +5 -4
- package/dist/plus/integrations/providers/azure/azure.js +38 -77
- package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
- package/dist/plus/integrations/providers/azure/azure.utils.js +20 -17
- package/dist/plus/integrations/providers/azure/azure.utils.js.map +1 -1
- package/dist/plus/integrations/providers/azure/models.d.ts +27 -10
- package/dist/plus/integrations/providers/azure/models.js +40 -20
- package/dist/plus/integrations/providers/azure/models.js.map +1 -1
- package/dist/plus/integrations/providers/azure/workItemStateCategories.d.ts +23 -0
- package/dist/plus/integrations/providers/azure/workItemStateCategories.js +84 -0
- package/dist/plus/integrations/providers/azure/workItemStateCategories.js.map +1 -0
- package/dist/plus/integrations/providers/azureDevOps.d.ts +44 -0
- package/dist/plus/integrations/providers/azureDevOps.js +113 -22
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOpsServer.d.ts +45 -1
- package/dist/plus/integrations/providers/azureDevOpsServer.js +121 -6
- package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +0 -1
- package/dist/plus/integrations/providers/jira-server.js +29 -19
- package/dist/plus/integrations/providers/jira-server.js.map +1 -1
- package/dist/plus/integrations/providers/jira.d.ts +5 -2
- package/dist/plus/integrations/providers/jira.js +63 -44
- package/dist/plus/integrations/providers/jira.js.map +1 -1
- package/dist/plus/integrations/providers/jiraIssueByKey.d.ts +3 -4
- package/dist/plus/integrations/providers/jiraIssueByKey.js +3 -4
- package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
- package/dist/plus/integrations/providers/linearIssuesEtag.d.ts +5 -5
- package/dist/plus/integrations/providers/linearIssuesEtag.js +6 -6
- package/dist/plus/integrations/providers/linearIssuesEtag.js.map +1 -1
- package/dist/plus/integrations/providers/models.d.ts +12 -3
- package/dist/plus/integrations/providers/models.js +16 -9
- package/dist/plus/integrations/providers/models.js.map +1 -1
- package/dist/plus/integrations/providers/providersApi.d.ts +21 -33
- package/dist/plus/integrations/providers/providersApi.js +159 -49
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/plus/integrations/providers/utils/jiraIssueDrains.d.ts +49 -15
- package/dist/plus/integrations/providers/utils/jiraIssueDrains.js +132 -10
- package/dist/plus/integrations/providers/utils/jiraIssueDrains.js.map +1 -1
- package/dist/plus/integrations/providers/utils/providerPaging.js +8 -2
- package/dist/plus/integrations/providers/utils/providerPaging.js.map +1 -1
- package/dist/plus/integrations/reads/cursors.js +1 -1
- package/dist/plus/integrations/reads/drains.d.ts +0 -1
- package/dist/plus/integrations/reads/filters.d.ts +3 -3
- package/dist/plus/integrations/reads/filters.js.map +1 -1
- package/dist/plus/integrations/reads/hierarchy.js +2 -2
- package/dist/plus/integrations/reads/hierarchy.js.map +1 -1
- package/dist/plus/integrations/reads/hierarchy.utils.d.ts +13 -0
- package/dist/plus/integrations/reads/hierarchy.utils.js +26 -1
- package/dist/plus/integrations/reads/hierarchy.utils.js.map +1 -1
- package/dist/plus/integrations/reads/issueBatch.d.ts +2 -1
- package/dist/plus/integrations/reads/issueBatch.js +1 -1
- package/dist/plus/integrations/reads/issueBatch.js.map +1 -1
- package/dist/plus/integrations/reads/issueTracker.js +27 -18
- package/dist/plus/integrations/reads/issueTracker.js.map +1 -1
- package/dist/plus/integrations/reads/issues.d.ts +2 -1
- package/dist/plus/integrations/reads/issues.js +19 -4
- package/dist/plus/integrations/reads/issues.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestBatch.js +1 -1
- package/dist/plus/integrations/reads/resolveRepository.js +12 -3
- package/dist/plus/integrations/reads/resolveRepository.js.map +1 -1
- package/dist/plus/integrations/reads/warnings.d.ts +11 -4
- package/dist/plus/integrations/reads/warnings.js +15 -5
- package/dist/plus/integrations/reads/warnings.js.map +1 -1
- package/dist/plus/integrations/results.d.ts +48 -4
- package/dist/plus/integrations/results.js +33 -13
- package/dist/plus/integrations/results.js.map +1 -1
- package/dist/plus/integrations/utils/integration.utils.d.ts +6 -1
- package/dist/plus/integrations/utils/integration.utils.js +8 -1
- package/dist/plus/integrations/utils/integration.utils.js.map +1 -1
- package/dist/utils/env/node/exec.js +2 -2
- package/dist/utils/promiseCache.d.ts +10 -0
- package/dist/utils/promiseCache.js +17 -2
- package/dist/utils/promiseCache.js.map +1 -1
- package/docs/integrations.md +93 -31
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branches.js","names":["Logger"],"sources":["../../../../git-cli/src/providers/branches.ts"],"sourcesContent":["import type { Cache, ConflictDetectionCacheKey, GkConfigInvalidationTarget } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport { BranchError } from '@gitlens/git/errors.js';\nimport type { BranchDisposition, BranchMetadata } from '@gitlens/git/models/branch.js';\nimport { GitBranch } from '@gitlens/git/models/branch.js';\nimport type { ConflictDetectionErrorReason, ConflictDetectionResult } from '@gitlens/git/models/mergeConflicts.js';\nimport type { GitBranchReference, RefRecord } from '@gitlens/git/models/reference.js';\nimport type { GitRevisionRange } from '@gitlens/git/models/revision.js';\nimport type {\n\tAheadOfBase,\n\tBranchContributionsOverview,\n\tGitBranchesSubProvider,\n\tGitBranchMergedStatus,\n} from '@gitlens/git/providers/branches.js';\nimport type { GitCommandPriority } from '@gitlens/git/run.types.js';\nimport {\n\tformatDetachedHeadName,\n\tgetLocalBranchByUpstream,\n\tisDetachedHead,\n\tisRemoteHEAD,\n\tparseRefName,\n\tparseUpstream,\n} from '@gitlens/git/utils/branch.utils.js';\nimport { createConflictDetectionError } from '@gitlens/git/utils/mergeConflicts.utils.js';\nimport { createReference } from '@gitlens/git/utils/reference.utils.js';\nimport { createRevisionRange, shortenRevision } from '@gitlens/git/utils/revision.utils.js';\nimport type { BranchSortOptions } from '@gitlens/git/utils/sorting.js';\nimport { sortBranches, sortContributors } from '@gitlens/git/utils/sorting.js';\nimport { ensureArray, filterMap } from '@gitlens/utils/array.js';\nimport { CancellationError, isCancellationError } from '@gitlens/utils/cancellation.js';\nimport { debounce } from '@gitlens/utils/decorators/debounce.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { getBranchId } from '@gitlens/utils/gitRefs.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport type { PagedResult, PagingOptions } from '@gitlens/utils/paging.js';\nimport { emptyPagedResult, PageableResult } from '@gitlens/utils/paging.js';\nimport { normalizePath } from '@gitlens/utils/path.js';\nimport { getSettledValue } from '@gitlens/utils/promise.js';\nimport type { CacheController } from '@gitlens/utils/promiseCache.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport type { GitResult } from '../exec/exec.types.js';\nimport type { Git } from '../exec/git.js';\nimport { getGitCommandError, gitConfigsBranch, gitConfigsLog, GitError, GitErrors, GitWarnings } from '../exec/git.js';\nimport type { GitMergeConflict } from '../parsers/mergeTreeParser.js';\nimport { parseMergeTreeConflict } from '../parsers/mergeTreeParser.js';\n\n/** Minimum time between writes to the config for last accessed/modified dates */\nconst dateMetadataStaleThresholdMs = 5 * 60 * 1000; // 5 minutes\n\nexport class BranchesGitSubProvider implements GitBranchesSubProvider {\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 getBranch(\n\t\trepoPath: string,\n\t\tname?: string,\n\t\toptions?: { force?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranch | undefined> {\n\t\tif (options?.force) {\n\t\t\tthis.cache.evictCaches(repoPath, 'branches');\n\t\t}\n\n\t\tif (name != null) {\n\t\t\tconst {\n\t\t\t\tvalues: [branch],\n\t\t\t} = await this.getBranches(repoPath, { filter: b => b.name === name }, cancellation);\n\t\t\treturn branch;\n\t\t}\n\n\t\tconst branchPromise = this.cache.branch.getOrCreate(\n\t\t\trepoPath,\n\t\t\tasync (_cacheable, signal) => {\n\t\t\t\tconst {\n\t\t\t\t\tvalues: [branch],\n\t\t\t\t} = await this.getBranches(repoPath, { filter: b => b.current }, signal);\n\t\t\t\treturn branch ?? this.getCurrentBranch(repoPath, undefined, undefined, signal);\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\n\t\tif (branchPromise == null) {\n\t\t\tconst {\n\t\t\t\tvalues: [branch],\n\t\t\t} = await this.getBranches(repoPath, { filter: b => b.current }, cancellation);\n\t\t\treturn branch ?? this.getCurrentBranch(repoPath, undefined, undefined, cancellation);\n\t\t}\n\n\t\treturn branchPromise;\n\t}\n\n\tprivate async getCurrentBranch(\n\t\trepoPath: string,\n\t\tmetadataMap: Map<string, BranchMetadata> | undefined,\n\t\tordering: string | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranch | undefined> {\n\t\tconst ref = await this.getCurrentBranchReferenceCore(repoPath, ordering, cancellation);\n\t\tif (ref == null) return undefined;\n\n\t\tconst [pausedOpStatusResult, committerDateResult, defaultWorktreePathResult, metadataMapResult] =\n\t\t\tawait Promise.allSettled([\n\t\t\t\tisDetachedHead(ref.name)\n\t\t\t\t\t? this.provider.pausedOps?.getPausedOperationStatus(repoPath, undefined, cancellation)\n\t\t\t\t\t: undefined,\n\t\t\t\tthis.git\n\t\t\t\t\t.run(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcwd: repoPath,\n\t\t\t\t\t\t\tcancellation: cancellation,\n\t\t\t\t\t\t\tconfigs: gitConfigsLog,\n\t\t\t\t\t\t\terrors: 'ignore',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'log',\n\t\t\t\t\t\t'-n1',\n\t\t\t\t\t\t'--format=%ct',\n\t\t\t\t\t\tordering ? `--${ordering}-order` : undefined,\n\t\t\t\t\t\t'--',\n\t\t\t\t\t)\n\t\t\t\t\t.then(result => (result.stdout ? result.stdout.trim() : undefined)),\n\t\t\t\tthis.provider.config.getDefaultWorktreePath?.(repoPath),\n\t\t\t\tmetadataMap != null ? Promise.resolve(metadataMap) : this.getBranchMetadataMap(repoPath),\n\t\t\t]);\n\n\t\tconst committerDate = getSettledValue(committerDateResult);\n\t\tconst pausedOpStatus = getSettledValue(pausedOpStatusResult);\n\t\tconst rebaseStatus = pausedOpStatus?.type === 'rebase' ? pausedOpStatus : undefined;\n\t\tconst defaultWorktreePath = getSettledValue(defaultWorktreePathResult);\n\t\tmetadataMap ??= getSettledValue(metadataMapResult);\n\t\tconst metadata = metadataMap?.get(ref.name);\n\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst branchRefName = rebaseStatus?.incoming.name ?? `refs/heads/${ref.name}`;\n\n\t\tconst branch = new GitBranch(\n\t\t\trepoPath, // Use worktree-specific path for consistent IDs within each worktree\n\t\t\tbranchRefName,\n\t\t\ttrue,\n\t\t\tcommitterDate != null ? new Date(Number(committerDate) * 1000) : undefined,\n\t\t\tmetadata,\n\t\t\tref.sha,\n\t\t\tref.upstream ? { ...ref.upstream, state: { ahead: 0, behind: 0 } } : undefined,\n\t\t\t{ path: repoPath, isDefault: repoPath === defaultWorktreePath },\n\t\t\tundefined,\n\t\t\trebaseStatus != null,\n\t\t);\n\n\t\treturn branch;\n\t}\n\n\t@debug({ args: repoPath => ({ repoPath: repoPath }) })\n\tasync getBranches(\n\t\trepoPath: string,\n\t\toptions?: {\n\t\t\tfilter?: (b: GitBranch) => boolean;\n\t\t\tordering?: 'date' | 'author-date' | 'topo' | null;\n\t\t\tpaging?: PagingOptions;\n\t\t\tsort?: boolean | BranchSortOptions;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<PagedResult<GitBranch>> {\n\t\tif (repoPath == null) return emptyPagedResult;\n\n\t\tconst scope = getScopedLogger();\n\n\t\tconst getCore = async (\n\t\t\tcommonPath: string,\n\t\t\tcacheable?: CacheController,\n\t\t\tsignal?: AbortSignal,\n\t\t): Promise<PagedResult<GitBranch>> => {\n\t\t\t// Prefer the aggregate signal from the cache when present; fall back to the caller's\n\t\t\t// own cancellation when bypassing the cache (e.g. paging-cursor path).\n\t\t\tsignal ??= cancellation;\n\t\t\ttry {\n\t\t\t\tconst [recordsResult, supportedResult, defaultWorktreePathResult, metadataMapResult] =\n\t\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\t\tthis.provider.refs.getRefs(commonPath, signal),\n\t\t\t\t\t\tthis.git.supported('git:for-each-ref'),\n\t\t\t\t\t\tthis.provider.config.getDefaultWorktreePath?.(commonPath),\n\t\t\t\t\t\tthis.getBranchMetadataMap(commonPath),\n\t\t\t\t\t]);\n\n\t\t\t\tconst records = getSettledValue(recordsResult) ?? [];\n\t\t\t\tconst supported = getSettledValue(supportedResult) ?? [];\n\t\t\t\tconst metadataMap = getSettledValue(metadataMapResult) ?? new Map<string, BranchMetadata>();\n\t\t\t\tconst defaultWorktreePath = getSettledValue(defaultWorktreePathResult);\n\t\t\t\tconst worktreePathSupported = supported.includes('git:for-each-ref:worktreePath');\n\n\t\t\t\t// If we don't get any data, assume the repo doesn't have any commits yet so check if we have a current branch\n\t\t\t\tif (!records.length) {\n\t\t\t\t\t// Never CACHE that conclusion. `getRefs` reports a failed enumeration the same way as a\n\t\t\t\t\t// genuinely ref-less repo — an empty array (it invalidates its own entry but doesn't\n\t\t\t\t\t// throw) — so a transient `for-each-ref` failure would otherwise pin this degraded\n\t\t\t\t\t// current-branch-only list in a map with no TTL, and every branch consumer would see a\n\t\t\t\t\t// one-branch repo for the session. A truly empty repo re-reads cheaply, so refusing the\n\t\t\t\t\t// entry costs nothing in the case this is actually meant to serve.\n\t\t\t\t\tcacheable?.invalidate();\n\n\t\t\t\t\tconst current = await this.getCurrentBranch(\n\t\t\t\t\t\tcommonPath,\n\t\t\t\t\t\tmetadataMap,\n\t\t\t\t\t\toptions?.ordering ?? this.context.config?.commits.ordering ?? undefined,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t);\n\t\t\t\t\treturn current != null ? { values: [current] } : emptyPagedResult;\n\t\t\t\t}\n\n\t\t\t\tusing sw = maybeStopWatch(scope, { log: { onlyExit: true, level: 'debug' } });\n\n\t\t\t\tconst branches: GitBranch[] = [];\n\n\t\t\t\tfor (const record of records) {\n\t\t\t\t\tconst fullName = record.name;\n\t\t\t\t\t// Filter to branches and remote-tracking branches; skip tags from the unified records.\n\t\t\t\t\tif (!fullName.startsWith('refs/heads/') && !fullName.startsWith('refs/remotes/')) continue;\n\t\t\t\t\t// Skip HEAD refs in remote branches\n\t\t\t\t\tif (isRemoteHEAD(fullName)) continue;\n\n\t\t\t\t\tconst upstream = parseUpstream(record.upstream, record.upstreamTracking);\n\n\t\t\t\t\tconst metadata = metadataMap.get(parseRefName(fullName).name);\n\t\t\t\t\tconst worktreePath = record.worktreePath ? normalizePath(record.worktreePath) : undefined;\n\n\t\t\t\t\tbranches.push(\n\t\t\t\t\t\tnew GitBranch(\n\t\t\t\t\t\t\tcommonPath,\n\t\t\t\t\t\t\tfullName,\n\t\t\t\t\t\t\tfalse, // Don't trust %(HEAD) for current as it's per-worktree -- we will set it later\n\t\t\t\t\t\t\trecord.committerDate ? new Date(record.committerDate) : undefined,\n\t\t\t\t\t\t\tmetadata,\n\t\t\t\t\t\t\trecord.objectname,\n\t\t\t\t\t\t\tupstream,\n\t\t\t\t\t\t\tworktreePathSupported\n\t\t\t\t\t\t\t\t? worktreePath\n\t\t\t\t\t\t\t\t\t? { path: worktreePath, isDefault: worktreePath === defaultWorktreePath }\n\t\t\t\t\t\t\t\t\t: false\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tsw?.stop({ suffix: ` parsed ${branches.length} branches` });\n\n\t\t\t\t// Pre-populate current branch cache for worktrees based on worktreePath info\n\t\t\t\t// This eliminates the need for rev-parse calls during branch reconstruction\n\t\t\t\tfor (const branch of branches) {\n\t\t\t\t\t// oxlint-disable-next-line typescript/prefer-optional-chain\n\t\t\t\t\tif (branch.worktree && branch.worktree.path) {\n\t\t\t\t\t\tconst { name } = parseRefName(branch.refName);\n\t\t\t\t\t\tconst reference = createReference(name, branch.worktree.path, {\n\t\t\t\t\t\t\trefType: 'branch',\n\t\t\t\t\t\t\tname: name,\n\t\t\t\t\t\t\tid: getBranchId(branch.worktree.path, false, name),\n\t\t\t\t\t\t\tremote: false,\n\t\t\t\t\t\t\tupstream: branch.upstream?.name\n\t\t\t\t\t\t\t\t? { name: branch.upstream.name, missing: branch.upstream.missing }\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\tsha: branch.sha,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.cache.setCurrentBranchReferenceIfAbsent(branch.worktree.path, reference);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn branches.length ? { values: branches } : emptyPagedResult;\n\t\t\t} catch (ex) {\n\t\t\t\t// Signal cache invalidation so the shared cache entry is cleaned up\n\t\t\t\tcacheable?.invalidate();\n\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\treturn emptyPagedResult;\n\t\t\t}\n\t\t};\n\n\t\t// Mapper function that adjusts branches for a specific worktree\n\t\tconst mapBranches = async (\n\t\t\tshared: PagedResult<GitBranch>,\n\t\t\ttargetRepoPath: string,\n\t\t\tcommonPath: string,\n\t\t\tmapperSignal?: AbortSignal,\n\t\t): Promise<PagedResult<GitBranch>> => {\n\t\t\tif (!shared.values.length) return shared;\n\n\t\t\t// Prefer the mapper's per-entry aggregate signal when present; fall back to the\n\t\t\t// caller's own cancellation when bypassing the cache (paging-cursor path).\n\t\t\tmapperSignal ??= cancellation;\n\n\t\t\t// Get current branch info and default worktree path for the target worktree\n\t\t\tconst [currentRefResult, defaultWorktreePathResult] = await Promise.allSettled([\n\t\t\t\tthis.getCurrentBranchReferenceCore(targetRepoPath, undefined, mapperSignal),\n\t\t\t\tthis.provider.config.getDefaultWorktreePath?.(commonPath),\n\t\t\t]);\n\t\t\tconst currentRef = getSettledValue(currentRefResult);\n\t\t\tconst defaultWorktreePath = getSettledValue(defaultWorktreePathResult);\n\t\t\tconst isDetached = currentRef != null && isDetachedHead(currentRef.name);\n\n\t\t\t// Clone branches with correct repoPath and current flag\n\t\t\tconst branches: GitBranch[] = shared.values.map(b => {\n\t\t\t\t// Check if this branch is current in the target worktree\n\t\t\t\tconst isCurrent = !b.remote && b.name === currentRef?.name && !isDetached;\n\n\t\t\t\t// Only create new object if something changed\n\t\t\t\tif (!isCurrent && targetRepoPath === commonPath) return b;\n\n\t\t\t\treturn new GitBranch(\n\t\t\t\t\ttargetRepoPath, // Use target worktree path\n\t\t\t\t\tb.refName,\n\t\t\t\t\tisCurrent,\n\t\t\t\t\tb.date,\n\t\t\t\t\tb.metadata,\n\t\t\t\t\tb.sha,\n\t\t\t\t\tb.upstream,\n\t\t\t\t\t// For current branch, ensure worktree is set (fallback when git doesn't support worktreePath)\n\t\t\t\t\tisCurrent\n\t\t\t\t\t\t? (b.worktree ?? { path: targetRepoPath, isDefault: targetRepoPath === defaultWorktreePath })\n\t\t\t\t\t\t: b.worktree,\n\t\t\t\t\tfalse, // detached - only true for detached HEAD branch itself\n\t\t\t\t\tfalse, // rebasing - only true for detached HEAD branch in rebase\n\t\t\t\t);\n\t\t\t});\n\n\t\t\t// Handle detached HEAD - need to create a special branch for it\n\t\t\tif (isDetached || (currentRef != null && !branches.some(b => b.current))) {\n\t\t\t\tconst metadataMap = await this.getBranchMetadataMap(commonPath);\n\t\t\t\tconst current = await this.getCurrentBranch(\n\t\t\t\t\ttargetRepoPath,\n\t\t\t\t\tmetadataMap,\n\t\t\t\t\toptions?.ordering ?? this.context.config?.commits.ordering ?? undefined,\n\t\t\t\t\tmapperSignal,\n\t\t\t\t);\n\t\t\t\tif (current != null) {\n\t\t\t\t\t// Replace if exists (by id), otherwise prepend\n\t\t\t\t\tconst index = branches.findIndex(b => b.id === current.id);\n\t\t\t\t\tif (index !== -1) {\n\t\t\t\t\t\tbranches[index] = current;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbranches.unshift(current);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { ...shared, values: branches };\n\t\t};\n\n\t\tlet result: PagedResult<GitBranch>;\n\n\t\t// Use paging cursor to bypass cache if paginating\n\t\tif (options?.paging?.cursor != null) {\n\t\t\tconst commonPath = this.cache.getCommonPath(repoPath);\n\t\t\tconst shared = await getCore(commonPath);\n\t\t\t// Still apply the mapper to ensure correct repoPath and current flag for the requesting worktree\n\t\t\tresult = await mapBranches(shared, repoPath, commonPath);\n\t\t} else {\n\t\t\tresult = await this.cache.getBranches(repoPath, getCore, mapBranches, cancellation);\n\t\t}\n\n\t\tif (options?.filter != null) {\n\t\t\tresult = {\n\t\t\t\t...result,\n\t\t\t\tvalues: result.values.filter(options.filter),\n\t\t\t};\n\t\t}\n\n\t\tif (options?.sort) {\n\t\t\tsortBranches(result.values, typeof options.sort === 'boolean' ? undefined : options.sort);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t@debug()\n\tasync getBranchContributionsOverview(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: {\n\t\t\tassociatedPullRequest?: Promise<\n\t\t\t\t{ refs?: { base?: { branch: string } }; stack?: { position: number } } | undefined\n\t\t\t>;\n\t\t\tpriority?: GitCommandPriority;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<BranchContributionsOverview | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst priority = options?.priority;\n\t\tconst priorityOpts = priority != null ? { priority: priority } : undefined;\n\n\t\t// Expensive body — runs only on cache miss. Closes over `mergeTarget` so the cache key\n\t\t// (`${ref}|${mergeTarget}`) fully captures every input that affects the result.\n\t\tconst fetchBody = async (\n\t\t\tmergeTarget: string,\n\t\t\tsignal: AbortSignal | undefined,\n\t\t): Promise<BranchContributionsOverview | undefined> => {\n\t\t\tconst mergeBase = await this.provider.refs.getMergeBase(repoPath, ref, mergeTarget, priorityOpts, signal);\n\t\t\tif (mergeBase == null) return undefined;\n\n\t\t\t// Fetch the merge-base commit's dates in parallel with contributors so consumers\n\t\t\t// (e.g. the graph minimap scope window) don't pay a separate round-trip for them.\n\t\t\t// `allSettled` so a transient failure in one side doesn't drop the overview entirely.\n\t\t\tconst [contributorsSettled, mergeBaseDatesSettled] = await Promise.allSettled([\n\t\t\t\tthis.provider.contributors.getContributors(\n\t\t\t\t\trepoPath,\n\t\t\t\t\tcreateRevisionRange(mergeBase, ref, '..'),\n\t\t\t\t\t{ stats: true },\n\t\t\t\t\tsignal,\n\t\t\t\t),\n\t\t\t\tthis.provider.commits.getCommitDates(repoPath, mergeBase, signal),\n\t\t\t]);\n\n\t\t\tif (signal?.aborted) throw new CancellationError();\n\n\t\t\tconst result = getSettledValue(contributorsSettled) ?? { contributors: [] };\n\t\t\tconst mergeBaseDates = getSettledValue(mergeBaseDatesSettled);\n\n\t\t\tsortContributors(result.contributors, { orderBy: 'score:desc' });\n\n\t\t\tlet totalCommits = 0;\n\t\t\tlet totalFiles = 0;\n\t\t\tlet totalAdditions = 0;\n\t\t\tlet totalDeletions = 0;\n\t\t\tlet firstCommitTimestamp;\n\t\t\tlet latestCommitTimestamp;\n\n\t\t\tfor (const c of result.contributors) {\n\t\t\t\ttotalCommits += c.contributionCount;\n\t\t\t\ttotalFiles += c.stats?.files ?? 0;\n\t\t\t\ttotalAdditions += c.stats?.additions ?? 0;\n\t\t\t\ttotalDeletions += c.stats?.deletions ?? 0;\n\n\t\t\t\tconst firstTimestamp = c.firstCommitDate?.getTime();\n\t\t\t\tconst latestTimestamp = c.latestCommitDate?.getTime();\n\n\t\t\t\tif (firstTimestamp != null || latestTimestamp != null) {\n\t\t\t\t\tfirstCommitTimestamp =\n\t\t\t\t\t\tfirstCommitTimestamp != null\n\t\t\t\t\t\t\t? Math.min(firstCommitTimestamp, firstTimestamp ?? Infinity, latestTimestamp ?? Infinity)\n\t\t\t\t\t\t\t: (firstTimestamp ?? latestTimestamp);\n\n\t\t\t\t\tlatestCommitTimestamp =\n\t\t\t\t\t\tlatestCommitTimestamp != null\n\t\t\t\t\t\t\t? Math.max(latestCommitTimestamp, firstTimestamp ?? -Infinity, latestTimestamp ?? -Infinity)\n\t\t\t\t\t\t\t: (latestTimestamp ?? firstTimestamp);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\trepoPath: repoPath,\n\t\t\t\tbranch: ref,\n\t\t\t\tmergeTarget: mergeTarget,\n\t\t\t\tmergeBase: mergeBase,\n\t\t\t\tmergeBaseDate: mergeBaseDates?.committerDate,\n\n\t\t\t\tcommits: totalCommits,\n\t\t\t\tfiles: totalFiles,\n\t\t\t\tadditions: totalAdditions,\n\t\t\t\tdeletions: totalDeletions,\n\n\t\t\t\tlatestCommitDate: latestCommitTimestamp != null ? new Date(latestCommitTimestamp) : undefined,\n\t\t\t\tfirstCommitDate: firstCommitTimestamp != null ? new Date(firstCommitTimestamp) : undefined,\n\n\t\t\t\tcontributors: result.contributors,\n\t\t\t};\n\t\t};\n\n\t\ttry {\n\t\t\t// Resolve `mergeTarget` through Tier 1 → Tier 2 → Tier 3. The pieces of each tier are\n\t\t\t// already individually cached (`getStoredMergeTargetBranchName`, `getBaseBranchName`,\n\t\t\t// `getDefaultBranchName`), so this resolution path is cheap on warm caches. Only the\n\t\t\t// expensive body below (`getMergeBase` + `getContributors` w/ stats + `getCommitDates`)\n\t\t\t// is wrapped by `cache.getBranchOverview`, keyed on the resolved `mergeTarget` so any\n\t\t\t// caller that resolves to the same target shares; differing targets get independent\n\t\t\t// slots, which is the correctness constraint that previously forced the Tier 2/3 paths\n\t\t\t// to bypass the cache entirely.\n\t\t\tlet mergeTarget: string | undefined;\n\n\t\t\t// Tier 1: Stored merge target (user-set or previously detected from PR). A target whose\n\t\t\t// branch is gone is skipped, so resolution falls through to the next tier.\n\t\t\tmergeTarget = await this.getStoredMergeTargetBranchName(repoPath, ref, priorityOpts, cancellation);\n\n\t\t\t// Tier 2: PR-based lookup. The branch object is only needed here (for `remoteName`),\n\t\t\t// so lazy-load it on the cold path instead of paying for it on every call.\n\t\t\tif (mergeTarget == null && options?.associatedPullRequest != null) {\n\t\t\t\tconst pr = await options.associatedPullRequest;\n\t\t\t\tif (pr?.refs?.base != null) {\n\t\t\t\t\tconst branch = await this.getBranch(repoPath, ref, undefined, cancellation);\n\t\t\t\t\tif (branch == null) return undefined;\n\n\t\t\t\t\tconst prTarget = `${branch.remoteName}/${pr.refs.base.branch}`;\n\t\t\t\t\t// A PR's base can be gone too (e.g. a stale PR read still naming a merged stack layer),\n\t\t\t\t\t// so a confirmed-gone base is skipped like a stored target.\n\t\t\t\t\tconst { missing } = await this.provider.refs.getSymbolicReferenceNameOrMissing(\n\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\tprTarget,\n\t\t\t\t\t\tpriorityOpts,\n\t\t\t\t\t\tcancellation,\n\t\t\t\t\t);\n\t\t\t\t\tif (!missing) {\n\t\t\t\t\t\tmergeTarget = prTarget;\n\n\t\t\t\t\t\t// A stacked PR's base is the layer below it, which is deleted when the stack merges.\n\t\t\t\t\t\t// A stored target beats every other tier for as long as its branch exists, and a merged\n\t\t\t\t\t\t// layer's branch can linger (an unpruned remote-tracking ref, or a repo that keeps merged\n\t\t\t\t\t\t// branches). Use it for this lookup, but don't persist it.\n\t\t\t\t\t\tif (pr.stack == null) {\n\t\t\t\t\t\t\t// Store for future reuse — turns the next call into a Tier 1 path. Skip the\n\t\t\t\t\t\t\t// `branchOverviews` invalidation that the write would otherwise trigger: we're\n\t\t\t\t\t\t\t// about to populate `${ref}|${mergeTarget}` with this exact target, so evicting\n\t\t\t\t\t\t\t// it would just force the next caller to redo the body. (gk-merge-target writes\n\t\t\t\t\t\t\t// do not affect `baseBranchName`, so no need to skip that target.)\n\t\t\t\t\t\t\tvoid this.storeMergeTargetBranchName(repoPath, ref, prTarget, {\n\t\t\t\t\t\t\t\tskipInvalidation: ['branchOverviews'],\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Tier 3: Base branch, then default branch.\n\t\t\tmergeTarget ??= await this.getBaseBranchName(repoPath, ref, priorityOpts, cancellation);\n\t\t\tmergeTarget ??= await this.getDefaultBranchName(repoPath, undefined, priorityOpts, cancellation);\n\n\t\t\tif (mergeTarget == null) return undefined;\n\n\t\t\tconst resolvedTarget = mergeTarget;\n\t\t\treturn await this.cache.getBranchOverview(\n\t\t\t\trepoPath,\n\t\t\t\t`${ref}|${resolvedTarget}`,\n\t\t\t\t(_commonPath, _cacheable, signal) => fetchBody(resolvedTarget, signal ?? cancellation),\n\t\t\t\t{ cancellation: cancellation },\n\t\t\t);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@debug()\n\tasync getBranchesWithCommits(\n\t\trepoPath: string,\n\t\tcommits: string[],\n\t\tbranch?: string,\n\t\toptions?:\n\t\t\t| { all?: boolean; commitDate?: Date; mode?: 'contains' | 'pointsAt' }\n\t\t\t| { commitDate?: Date; mode?: 'contains' | 'pointsAt'; remotes?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<string[]> {\n\t\tif (branch != null) {\n\t\t\tconst result = await this.branchesContainingCore(\n\t\t\t\trepoPath,\n\t\t\t\tcommits,\n\t\t\t\t{ mode: 'contains', name: branch },\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst data = result.stdout.trim();\n\t\t\treturn data ? [data] : [];\n\t\t}\n\n\t\tconst result = await this.branchesContainingCore(repoPath, commits, options, cancellation);\n\t\tif (!result.stdout) return [];\n\n\t\treturn filterMap(result.stdout.split('\\n'), b => b.trim() || undefined);\n\t}\n\n\tprivate async branchesContainingCore(\n\t\trepoPath: string,\n\t\trefs: string[],\n\t\toptions?: {\n\t\t\tall?: boolean;\n\t\t\tmode?: 'contains' | 'pointsAt';\n\t\t\tname?: string;\n\t\t\tremotes?: boolean;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitResult> {\n\t\tconst params: string[] = ['branch'];\n\t\tif (options?.all) {\n\t\t\tparams.push('-a');\n\t\t} else if (options?.remotes) {\n\t\t\tparams.push('-r');\n\t\t}\n\n\t\tparams.push('--format=%(refname:short)');\n\n\t\tfor (const ref of refs) {\n\t\t\tparams.push(options?.mode === 'pointsAt' ? `--points-at=${ref}` : `--contains=${ref}`);\n\t\t}\n\n\t\tif (options?.name != null) {\n\t\t\tparams.push(options.name);\n\t\t}\n\n\t\treturn this.git.run(\n\t\t\t{\n\t\t\t\tcwd: repoPath,\n\t\t\t\tcancellation: cancellation,\n\t\t\t\tconfigs: gitConfigsBranch,\n\t\t\t\terrors: 'ignore',\n\t\t\t},\n\t\t\t...params,\n\t\t);\n\t}\n\n\t@debug()\n\tasync getCurrentBranchReference(\n\t\trepoPath: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranchReference | undefined> {\n\t\tlet ref = await this.getCurrentBranchReferenceCore(repoPath, undefined, cancellation);\n\t\tif (ref != null && isDetachedHead(ref.name)) {\n\t\t\tref = createReference(ref.sha!, repoPath, {\n\t\t\t\trefType: 'branch',\n\t\t\t\tname: formatDetachedHeadName(ref.sha!),\n\t\t\t\tid: getBranchId(repoPath, ref.remote, ref.sha!),\n\t\t\t\tremote: ref.remote,\n\t\t\t\tupstream: ref.upstream,\n\t\t\t\tsha: ref.sha,\n\t\t\t});\n\t\t}\n\t\treturn ref;\n\t}\n\n\tprivate getCurrentBranchReferenceCore(\n\t\trepoPath: string,\n\t\tordering?: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranchReference | undefined> {\n\t\treturn this.cache.currentBranchReference.getOrCreate(\n\t\t\trepoPath,\n\t\t\tasync (_cacheable, signal) => {\n\t\t\t\tconst commitOrdering = ordering;\n\n\t\t\t\tlet data: [string, string | undefined] | undefined;\n\t\t\t\tlet result;\n\t\t\t\ttry {\n\t\t\t\t\tresult = await this.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, cancellation: signal, errors: 'throw' },\n\t\t\t\t\t\t'rev-parse',\n\t\t\t\t\t\t'--abbrev-ref',\n\t\t\t\t\t\t'--symbolic-full-name',\n\t\t\t\t\t\t'@',\n\t\t\t\t\t\t'@{u}',\n\t\t\t\t\t\t'--',\n\t\t\t\t\t);\n\t\t\t\t\tdata = [result.stdout, undefined];\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\t\tconst msg: string = ex?.toString() ?? '';\n\t\t\t\t\tif (GitErrors.badRevision.test(msg) || GitWarnings.noUpstream.test(msg)) {\n\t\t\t\t\t\tif (ex.stdout != null && ex.stdout.length !== 0) {\n\t\t\t\t\t\t\tdata = [ex.stdout, undefined];\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tresult = await this.git.run(\n\t\t\t\t\t\t\t\t\t{ cwd: repoPath, cancellation: signal },\n\t\t\t\t\t\t\t\t\t'symbolic-ref',\n\t\t\t\t\t\t\t\t\t'--short',\n\t\t\t\t\t\t\t\t\t'HEAD',\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (result.stdout) {\n\t\t\t\t\t\t\t\t\tdata = [result.stdout.trim(), undefined];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (data == null) {\n\t\t\t\t\t\t\t\tconst symbolicRef = await this.getDefaultBranchName(\n\t\t\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\t\t\t'origin',\n\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (symbolicRef != null) {\n\t\t\t\t\t\t\t\t\tdata = [\n\t\t\t\t\t\t\t\t\t\tsymbolicRef.startsWith('origin/')\n\t\t\t\t\t\t\t\t\t\t\t? symbolicRef.substring('origin/'.length)\n\t\t\t\t\t\t\t\t\t\t\t: symbolicRef,\n\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (data == null) {\n\t\t\t\t\t\t\t\tconst defaultBranch =\n\t\t\t\t\t\t\t\t\t(await this.provider.config.getConfig(repoPath, 'init.defaultBranch')) ?? 'main';\n\t\t\t\t\t\t\t\tconst configMap = await this.provider.config.getConfigRegex(\n\t\t\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\t\t\t`branch\\\\.${defaultBranch}\\\\.+`,\n\t\t\t\t\t\t\t\t\t{ runGitLocally: true },\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tconst remote = configMap.get(`branch.${defaultBranch}.remote`);\n\t\t\t\t\t\t\t\tconst merge = configMap.get(`branch.${defaultBranch}.merge`);\n\t\t\t\t\t\t\t\tconst remoteBranch = merge?.startsWith('refs/heads/')\n\t\t\t\t\t\t\t\t\t? merge.substring('refs/heads/'.length)\n\t\t\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\t\t\t\tdata = [\n\t\t\t\t\t\t\t\t\t`${defaultBranch}${remote && remoteBranch ? `\\n${remote}/${remoteBranch}` : ''}`,\n\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (GitWarnings.headNotABranch.test(msg)) {\n\t\t\t\t\t\tresult = await this.git.run(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcwd: repoPath,\n\t\t\t\t\t\t\t\tcancellation: signal,\n\t\t\t\t\t\t\t\tconfigs: gitConfigsLog,\n\t\t\t\t\t\t\t\terrors: 'ignore',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'log',\n\t\t\t\t\t\t\t'-n1',\n\t\t\t\t\t\t\t'--format=%H',\n\t\t\t\t\t\t\tcommitOrdering ? `--${commitOrdering}-order` : undefined,\n\t\t\t\t\t\t\t'--',\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif (result.completion.status === 'cancelled' || signal?.aborted) {\n\t\t\t\t\t\t\tthrow new CancellationError();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst sha = result.stdout.trim();\n\t\t\t\t\t\tif (sha) {\n\t\t\t\t\t\t\tdata = [`(HEAD detached at ${shortenRevision(sha)})`, sha];\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tLogger.warn(`[${repoPath}] Unable to get current branch: ${ex}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (data == null) return undefined;\n\n\t\t\t\tconst [name, upstream] = data[0].split('\\n');\n\n\t\t\t\treturn createReference(name, repoPath, {\n\t\t\t\t\trefType: 'branch',\n\t\t\t\t\tname: name,\n\t\t\t\t\tid: getBranchId(repoPath, false, name),\n\t\t\t\t\tremote: false,\n\t\t\t\t\tupstream: upstream ? { name: upstream, missing: false } : undefined,\n\t\t\t\t\tsha: data[1],\n\t\t\t\t});\n\t\t\t},\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\t@debug({ exit: true })\n\tasync getDefaultBranchName(\n\t\trepoPath: string | undefined,\n\t\tremote?: string,\n\t\toptions?: { priority?: GitCommandPriority; local?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<string | undefined> {\n\t\tif (repoPath == null) return undefined;\n\n\t\tremote ??= 'origin';\n\t\tconst priority = options?.priority;\n\t\tconst priorityOpts = priority != null ? { priority: priority } : undefined;\n\n\t\t// Local-only: read just the existing local symref, never contacting the remote. Cached under a\n\t\t// `${remote}:local` key — a colon can't appear in a refname component, so it can never collide\n\t\t// with a real remote name used by the networked variant below. Invalidated by the same\n\t\t// remotes/branches cache cascades as the networked lookup.\n\t\tif (options?.local) {\n\t\t\treturn this.cache.getDefaultBranchName(\n\t\t\t\trepoPath,\n\t\t\t\t`${remote}:local`,\n\t\t\t\tasync (commonPath, cacheable, signal) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Bind to the aggregate `signal` (fires only when ALL current callers abort), not\n\t\t\t\t\t\t// this-caller's `cancellation` — otherwise a superseded caller's abort would kill the\n\t\t\t\t\t\t// shared command and reject concurrent riders that never cancelled.\n\t\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t\t{ cwd: commonPath, cancellation: signal ?? cancellation, ...priorityOpts },\n\t\t\t\t\t\t\t'symbolic-ref',\n\t\t\t\t\t\t\t'--short',\n\t\t\t\t\t\t\t`refs/remotes/${remote}/HEAD`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn result.stdout.trim() || undefined;\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\t\t\t// `symbolic-ref` on an absent `refs/remotes/<remote>/HEAD` exits fatal rather than\n\t\t\t\t\t\t// empty, and that message matches no `GitWarnings` entry, so it arrives here as a\n\t\t\t\t\t\t// throw. It is still an ANSWER — the ref genuinely isn't set — and the overwhelmingly\n\t\t\t\t\t\t// common one, so cache it. Invalidating instead means every caller re-probes and the\n\t\t\t\t\t\t// whole point of caching this lookup is lost.\n\t\t\t\t\t\tconst stderr = (ex as { stderr?: string }).stderr ?? '';\n\t\t\t\t\t\tif (stderr.includes('is not a symbolic ref')) return undefined;\n\n\t\t\t\t\t\t// Anything else never produced an answer (spawn failure, queue rejection). This entry\n\t\t\t\t\t\t// has no TTL, so caching that would pin \"no default branch\" for the session.\n\t\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t}\n\n\t\treturn this.cache.getDefaultBranchName(\n\t\t\trepoPath,\n\t\t\tremote,\n\t\t\tasync (commonPath, cacheable, signal) => {\n\t\t\t\tlet retried = false;\n\t\t\t\twhile (true) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t\t{ cwd: commonPath, cancellation: signal ?? cancellation, ...priorityOpts },\n\t\t\t\t\t\t\t'symbolic-ref',\n\t\t\t\t\t\t\t'--short',\n\t\t\t\t\t\t\t`refs/remotes/${remote}/HEAD`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn result.stdout.trim() || undefined;\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\t// Only \"no HEAD ref configured\" is an ANSWER here; every other throw means the lookup\n\t\t\t\t\t\t// never happened. This entry has no TTL, so caching a failure — an offline `ls-remote`\n\t\t\t\t\t\t// being the likely one — would pin \"no default branch\" for the session.\n\t\t\t\t\t\tlet answered = false;\n\t\t\t\t\t\tif (/is not a symbolic ref/.test(ex.stderr)) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tif (!retried) {\n\t\t\t\t\t\t\t\t\tretried = true;\n\t\t\t\t\t\t\t\t\tawait this.git.run(\n\t\t\t\t\t\t\t\t\t\t{ cwd: commonPath, cancellation: signal ?? cancellation, ...priorityOpts },\n\t\t\t\t\t\t\t\t\t\t'remote',\n\t\t\t\t\t\t\t\t\t\t'set-head',\n\t\t\t\t\t\t\t\t\t\t'-a',\n\t\t\t\t\t\t\t\t\t\tremote,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t// This just created `refs/remotes/<remote>/HEAD`, which the `local` variant\n\t\t\t\t\t\t\t\t\t// may already have cached a miss for. The watcher would also catch the new\n\t\t\t\t\t\t\t\t\t// ref, but evict directly so consumers of this package that don't wire up a\n\t\t\t\t\t\t\t\t\t// watcher aren't stuck with that miss.\n\t\t\t\t\t\t\t\t\tthis.cache.deleteDefaultBranchName(commonPath, `${remote}:local`);\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t\t\t\t{ cwd: commonPath, cancellation: signal ?? cancellation, ...priorityOpts },\n\t\t\t\t\t\t\t\t\t'ls-remote',\n\t\t\t\t\t\t\t\t\t'--symref',\n\t\t\t\t\t\t\t\t\tremote,\n\t\t\t\t\t\t\t\t\t'HEAD',\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (result.stdout) {\n\t\t\t\t\t\t\t\t\tconst match = /ref:\\s(\\S+)\\s+HEAD/m.exec(result.stdout);\n\t\t\t\t\t\t\t\t\tif (match != null) {\n\t\t\t\t\t\t\t\t\t\tconst [, branch] = match;\n\t\t\t\t\t\t\t\t\t\treturn `${remote}/${branch.substring('refs/heads/'.length).trim()}`;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// `ls-remote` ran and the remote advertised no HEAD — a real \"none\".\n\t\t\t\t\t\t\t\tanswered = true;\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!answered) {\n\t\t\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\t@debug()\n\tasync createBranch(repoPath: string, name: string, ref: string, options?: { noTracking?: boolean }): Promise<void> {\n\t\tconst args = ['branch', name, ref];\n\t\tif (options?.noTracking) {\n\t\t\targs.push('--no-track');\n\t\t}\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t\t// Evict the cached base so the new branch re-derives its own. The PERSISTED `branch.<ref>.gk-*`\n\t\t\t// keys are left alone: they're dropped when GitLens deletes a branch, never when one is created.\n\t\t\t// Removing them here would mean treating a reused name as proof of a different branch, which\n\t\t\t// nothing can establish — so the trade is that a branch reusing a name deleted outside GitLens\n\t\t\t// inherits the orphaned section.\n\t\t\tthis.cache.deleteBaseBranchName(repoPath, name);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['heads']);\n\t\t} catch (ex) {\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'branch',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew BranchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\taction: 'create',\n\t\t\t\t\t\t\tbranch: name,\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,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t@debug()\n\tasync deleteLocalBranch(repoPath: string, names: string | string[], options?: { force?: boolean }): Promise<void> {\n\t\tconst branches = ensureArray(names);\n\t\tconst args = ['branch', options?.force ? '-D' : '-d', ...branches];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t\tfor (const branch of branches) {\n\t\t\t\tawait this.forgetDeletedBranch(repoPath, branch);\n\t\t\t}\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['heads']);\n\t\t} catch (ex) {\n\t\t\t// A multi-name delete partially succeeds: `git branch -d a bad c` removes `a` and `c`, refuses\n\t\t\t// `bad`, and still exits non-zero — so the loop above never ran for the branches that did go.\n\t\t\t// Clean those up here rather than leave persisted gk metadata behind for a name a later branch\n\t\t\t// can reuse.\n\t\t\tconst anyDeleted = await this.cleanupDeletedBranchMetadata(repoPath, branches);\n\n\t\t\t// The success path's notifications never ran, but some branches DID go — without these the\n\t\t\t// branch caches stay stale and consumers wait on the filesystem watcher (which never fires\n\t\t\t// for a packed ref).\n\t\t\tif (anyDeleted) {\n\t\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['heads']);\n\t\t\t}\n\n\t\t\tif (ex instanceof BranchError) {\n\t\t\t\tthrow ex.update({\n\t\t\t\t\taction: options?.force ? 'force delete' : 'delete',\n\t\t\t\t\tbranch: branches.join(', '),\n\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Classify the failure (e.g. not fully merged) so consumers like the delete wizard can offer a\n\t\t\t// force retry — without this the reason would be undefined and every failure reads as 'other'.\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'branch',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew BranchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\taction: options?.force ? 'force delete' : 'delete',\n\t\t\t\t\t\t\tbranch: branches.join(', '),\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,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Drops what GitLens keeps for a local branch beyond its ref, for both ways one is deleted\n\t * (`deleteLocalBranch` and `refs.deleteReference`). The persisted gk metadata goes too, not just the\n\t * cached resolution: `getBaseBranchName` reads `branch.<ref>.gk-merge-base` before falling back to the\n\t * reflog, so leaving it behind would hand a later branch reusing this name its predecessor's base.\n\t */\n\tasync forgetDeletedBranch(repoPath: string, name: string): Promise<void> {\n\t\tthis.cache.deleteBaseBranchName(repoPath, name);\n\t\tawait this.provider.config.removeGkConfigBranchSection(repoPath, name);\n\t}\n\n\t/**\n\t * Drops the cached and persisted per-branch metadata for whichever of `names` no longer exists. Only\n\t * for the partial-failure path — one extra `for-each-ref` is cheap while already handling an error,\n\t * and keeps the success path free of it.\n\t *\n\t * Returns whether any of `names` is confirmed gone; `false` when the probe couldn't answer, so a\n\t * spurious notification is never fired on an unrelated failure.\n\t */\n\tprivate async cleanupDeletedBranchMetadata(repoPath: string, names: string[]): Promise<boolean> {\n\t\ttry {\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, errors: 'ignore' },\n\t\t\t\t'for-each-ref',\n\t\t\t\t// Full refname, stripped here rather than by git. NOT `%(refname:short)`: that yields the\n\t\t\t\t// shortest UNAMBIGUOUS name, so a branch with a same-named tag comes back as `heads/<name>`,\n\t\t\t\t// never matches the requested name, and would read as deleted — wiping a live branch's\n\t\t\t\t// metadata. `%(refname:strip=2)` also solves that, but `%(refname)` is the oldest, plainest\n\t\t\t\t// field and needs no assumption about which git version gained `strip`.\n\t\t\t\t'--format=%(refname)',\n\t\t\t\t...names.map(n => `refs/heads/${n}`),\n\t\t\t);\n\t\t\t// `errors: 'ignore'` means a failed probe RESOLVES empty, which is indistinguishable from \"none\n\t\t\t// of them survived\" — and would delete every name's metadata, including user-owned keys like\n\t\t\t// `gk-disposition` and `gk-associated-issues`. Only act on a genuine answer.\n\t\t\t//\n\t\t\t// BOTH conditions: `exitCode !== 0` catches a probe git ran and rejected, `status !== 'exited'`\n\t\t\t// catches one that never produced an answer — a spawn failure or queue rejection (no exit code at\n\t\t\t// all), or a swallowed warning (which carries git's real code, so the exit-code test alone can\n\t\t\t// still read it as \"none survived\").\n\t\t\tif (result.completion.status !== 'exited' || result.exitCode !== 0) return false;\n\n\t\t\tconst prefix = 'refs/heads/';\n\t\t\tconst surviving = new Set(\n\t\t\t\tresult.stdout\n\t\t\t\t\t.split('\\n')\n\t\t\t\t\t.map(l => l.trim())\n\t\t\t\t\t.filter(l => l.startsWith(prefix))\n\t\t\t\t\t.map(l => l.substring(prefix.length)),\n\t\t\t);\n\n\t\t\tlet anyDeleted = false;\n\t\t\tfor (const name of names) {\n\t\t\t\tif (surviving.has(name)) continue;\n\n\t\t\t\tanyDeleted = true;\n\t\t\t\tawait this.forgetDeletedBranch(repoPath, name);\n\t\t\t}\n\n\t\t\treturn anyDeleted;\n\t\t} catch {\n\t\t\t// Best-effort bookkeeping while already unwinding a failure — never mask the original error.\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t@debug()\n\tasync deleteRemoteBranch(repoPath: string, names: string | string[], remote: string): Promise<void> {\n\t\tconst branches = ensureArray(names);\n\t\tconst args = ['push', '-d', remote, ...branches];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['remotes']);\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof BranchError) {\n\t\t\t\tthrow ex.update({\n\t\t\t\t\taction: 'delete',\n\t\t\t\t\tbranch: branches.join(', '),\n\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Classify against the underlying `git push -d` failure modes; map the \"remote ref does not\n\t\t\t// exist\" case onto BranchError's noRemoteReference so consumers get an actionable reason.\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'push',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew BranchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason === 'rejectedRefDoesNotExist' ? 'noRemoteReference' : 'other',\n\t\t\t\t\t\t\taction: 'delete',\n\t\t\t\t\t\t\tbranch: branches.join(', '),\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,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t@debug()\n\tasync getBranchMergedStatus(\n\t\trepoPath: string,\n\t\tbranch: GitBranchReference,\n\t\tinto: GitBranchReference,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranchMergedStatus> {\n\t\tif (branch.name === into.name || branch.upstream?.name === into.name) {\n\t\t\treturn { merged: false };\n\t\t}\n\n\t\t// Hoisted so it can feed the cache key below (its tip is a 3rd key input) and the mapper\n\t\t// below reuses it instead of resolving it a second time.\n\t\tconst localInto = into.remote\n\t\t\t? await this.getLocalBranchByUpstream(repoPath, into.name, cancellation)\n\t\t\t: undefined;\n\n\t\t// Cache key omits repoPath so worktrees of the same common repo share the cached answer.\n\t\t// Content-keyed on the involved tip shas (the result is a pure function of them), so tip\n\t\t// movement mints a new key instead of relying on eviction; falls back to the name-only\n\t\t// identity when a sha is missing (defensive — the sole caller always supplies both tips).\n\t\tconst cacheKey =\n\t\t\tbranch.sha != null && into.sha != null\n\t\t\t\t? `${branch.remote ? 'r' : 'l'}:${branch.name}@${branch.sha}|${into.remote ? 'r' : 'l'}:${into.name}@${into.sha}${\n\t\t\t\t\t\tlocalInto?.sha != null ? `|L:${localInto.name}@${localInto.sha}` : ''\n\t\t\t\t\t}`\n\t\t\t\t: `${branch.remote ? 'r' : 'l'}:${branch.name}|${into.remote ? 'r' : 'l'}:${into.name}`;\n\n\t\treturn this.cache.getBranchMergedStatus(\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tasync (commonPath, _cacheable, signal) => {\n\t\t\t\tconst result = await this.getBranchMergedStatusCore(commonPath, branch, into, signal);\n\t\t\t\tif (result.merged) return result;\n\n\t\t\t\t// If there is a local branch and it is not the branch we are checking, check if it has been merged into it\n\t\t\t\tif (localInto != null && localInto.name !== branch.name) {\n\t\t\t\t\t// Skip the second full merge-check cycle when the local branch points at the same commit as the remote —\n\t\t\t\t\t// the merge-base/cherry/diff/apply pipeline would produce the same answer we already got for `into` above\n\t\t\t\t\tif (localInto.sha != null && localInto.sha === into.sha) {\n\t\t\t\t\t\treturn { merged: false };\n\t\t\t\t\t}\n\n\t\t\t\t\tconst result = await this.getBranchMergedStatusCore(commonPath, branch, localInto, signal);\n\t\t\t\t\tif (result.merged) {\n\t\t\t\t\t\t// `localBranchOnly` is built against `commonPath` here; the cache mapper rewrites\n\t\t\t\t\t\t// `repoPath`/`id` to the requesting worktree on retrieval.\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\tlocalBranchOnly: createReference(localInto.ref, commonPath, {\n\t\t\t\t\t\t\t\tid: getBranchId(commonPath, localInto.remote, localInto.name),\n\t\t\t\t\t\t\t\trefType: 'branch',\n\t\t\t\t\t\t\t\tname: localInto.name,\n\t\t\t\t\t\t\t\tremote: localInto.remote,\n\t\t\t\t\t\t\t\tupstream: localInto.upstream,\n\t\t\t\t\t\t\t\tsha: localInto.sha,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn { merged: false };\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate async getBranchMergedStatusCore(\n\t\trepoPath: string,\n\t\tbranch: GitBranchReference,\n\t\tinto: GitBranchReference,\n\t\tcancellation?: AbortSignal,\n\t): Promise<Exclude<GitBranchMergedStatus, 'localBranchOnly'>> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\t// Check if branch is direct ancestor (handles FF merges)\n\t\t\ttry {\n\t\t\t\tawait this.git.run(\n\t\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t\t'merge-base',\n\t\t\t\t\t'--is-ancestor',\n\t\t\t\t\tbranch.name,\n\t\t\t\t\tinto.name,\n\t\t\t\t);\n\t\t\t\treturn { merged: true, confidence: 'highest' };\n\t\t\t} catch (ex) {\n\t\t\t\tif (isCancellationError(ex)) throw ex;\n\t\t\t}\n\n\t\t\t// Cherry-pick detection (handles cherry-picks, rebases, etc)\n\t\t\tlet result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation },\n\t\t\t\t'cherry',\n\t\t\t\t'--abbrev',\n\t\t\t\t'-v',\n\t\t\t\tinto.name,\n\t\t\t\tbranch.name,\n\t\t\t);\n\t\t\t// Check if there are no lines or all lines startwith a `-` (i.e. likely merged)\n\t\t\tif (\n\t\t\t\t!result.stdout ||\n\t\t\t\tresult.stdout\n\t\t\t\t\t.trim()\n\t\t\t\t\t.split('\\n')\n\t\t\t\t\t.every(l => l.startsWith('-'))\n\t\t\t) {\n\t\t\t\treturn { merged: true, confidence: 'high' };\n\t\t\t}\n\n\t\t\t// Attempt to detect squash merges by checking if the diff of the branch can be cleanly removed from the target\n\t\t\tconst mergeBase = await this.provider.refs.getMergeBase(\n\t\t\t\trepoPath,\n\t\t\t\tinto.name,\n\t\t\t\tbranch.name,\n\t\t\t\tundefined,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tresult = await this.git.run({ cwd: repoPath, cancellation: cancellation }, 'diff', mergeBase, branch.name);\n\t\t\tif (result.stdout) {\n\t\t\t\t// Create a temporary index file\n\t\t\t\tawait using disposableIndex = await this.provider.staging.createTemporaryIndex(\n\t\t\t\t\trepoPath,\n\t\t\t\t\t'ref',\n\t\t\t\t\tinto.name,\n\t\t\t\t);\n\t\t\t\tconst { env } = disposableIndex;\n\n\t\t\t\tresult = await this.git.run(\n\t\t\t\t\t{\n\t\t\t\t\t\tcwd: repoPath,\n\t\t\t\t\t\tcancellation: cancellation,\n\t\t\t\t\t\tenv: env,\n\t\t\t\t\t\terrors: 'ignore',\n\t\t\t\t\t\tstdin: result.stdout,\n\t\t\t\t\t},\n\t\t\t\t\t'apply',\n\t\t\t\t\t'--cached',\n\t\t\t\t\t'--reverse',\n\t\t\t\t\t'--check',\n\t\t\t\t\t'-',\n\t\t\t\t);\n\n\t\t\t\tif (result.exitCode === 0 && !result.stdout.trim() && !result.stderr?.trim()) {\n\t\t\t\t\treturn { merged: true, confidence: 'medium' };\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { merged: false };\n\t\t} catch (ex) {\n\t\t\tif (Logger.enabled('trace')) {\n\t\t\t\tscope?.error(ex);\n\t\t\t}\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn { merged: false };\n\t\t}\n\t}\n\n\t@debug()\n\tasync getLocalBranchByUpstream(\n\t\trepoPath: string,\n\t\tremoteBranchName: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranch | undefined> {\n\t\tconst branches = new PageableResult<GitBranch>(p =>\n\t\t\tthis.getBranches(repoPath, p != null ? { paging: p } : undefined, cancellation),\n\t\t);\n\t\treturn getLocalBranchByUpstream(remoteBranchName, branches);\n\t}\n\n\t/** Detects potential conflicts when applying commits onto a target branch (git rebase and cherry-pick) */\n\t@debug()\n\tasync getPotentialApplyConflicts(\n\t\trepoPath: string,\n\t\ttargetBranch: string,\n\t\tshas: string[],\n\t\toptions?: { stopOnFirstConflict?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<ConflictDetectionResult> {\n\t\tif (!shas.length) return { status: 'clean' };\n\n\t\tconst cacheKey: ConflictDetectionCacheKey = `apply:${targetBranch}:${shas.join(',')}:${options?.stopOnFirstConflict ?? false}`;\n\t\treturn this.cache.conflictDetection.getOrCreate(\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tasync (_cacheable, signal) => {\n\t\t\t\t// Resolve all parent refs in a single call - fails if any commit is a root commit (no parent)\n\t\t\t\tconst parentRefs = shas.map(c => `${c}^`);\n\t\t\t\tlet parentShas: string[];\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, cancellation: signal, errors: 'throw' },\n\t\t\t\t\t\t'rev-parse',\n\t\t\t\t\t\t...parentRefs,\n\t\t\t\t\t);\n\t\t\t\t\tparentShas = result.stdout.trim().split('\\n');\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\t\t\t\t\t// If any commit doesn't have a parent (root commit), we can't do conflict detection\n\t\t\t\t\treturn createConflictDetectionError('noParent');\n\t\t\t\t}\n\n\t\t\t\tif (parentShas.length !== shas.length) {\n\t\t\t\t\treturn createConflictDetectionError('refNotFound');\n\t\t\t\t}\n\n\t\t\t\tconst commitsWithParents = shas.map((c, i) => ({ sha: c, parent: parentShas[i] }));\n\t\t\t\treturn this.checkForPotentialConflicts(repoPath, commitsWithParents, targetBranch, signal, options);\n\t\t\t},\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\t/** Detects potential conflict when merge a branch into a target branch (git merge) */\n\t@debug()\n\tasync getPotentialMergeConflicts(\n\t\trepoPath: string,\n\t\tbranch: string,\n\t\ttargetBranch: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<ConflictDetectionResult> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst cacheKey: ConflictDetectionCacheKey = `merge:${branch}:${targetBranch}`;\n\t\treturn this.cache.conflictDetection.getOrCreate(\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tasync (_cacheable, signal) => {\n\t\t\t\tif (!(await this.git.supports('git:merge-tree:write-tree'))) {\n\t\t\t\t\treturn createConflictDetectionError('unsupported');\n\t\t\t\t}\n\n\t\t\t\tlet data;\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, cancellation: signal, errors: 'throw' },\n\t\t\t\t\t\t'merge-tree',\n\t\t\t\t\t\t'-z',\n\t\t\t\t\t\t'--name-only',\n\t\t\t\t\t\t'--no-messages',\n\t\t\t\t\t\tbranch,\n\t\t\t\t\t\ttargetBranch,\n\t\t\t\t\t);\n\t\t\t\t\tdata = result.stdout;\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\t\tconst msg: string = ex?.toString() ?? '';\n\t\t\t\t\tif (GitErrors.notAValidObjectName.test(msg)) {\n\t\t\t\t\t\tscope?.error(\n\t\t\t\t\t\t\tex,\n\t\t\t\t\t\t\t`'${targetBranch}' or '${branch}' not found - ensure the branches exist and are fully qualified (e.g. 'refs/heads/main')`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn createConflictDetectionError('refNotFound');\n\t\t\t\t\t} else if (GitErrors.badRevision.test(msg)) {\n\t\t\t\t\t\tscope?.error(ex, `Invalid branch name: ${msg.slice(msg.indexOf(\"'\"))}`);\n\t\t\t\t\t\treturn createConflictDetectionError('refNotFound');\n\t\t\t\t\t} else if (GitErrors.noMergeBase.test(msg)) {\n\t\t\t\t\t\tscope?.error(\n\t\t\t\t\t\t\tex,\n\t\t\t\t\t\t\t`Unable to merge '${branch}' and '${targetBranch}' as they have no common ancestor`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn createConflictDetectionError('noMergeBase');\n\t\t\t\t\t} else if (ex instanceof GitError) {\n\t\t\t\t\t\tdata = ex.stdout;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tscope?.error(ex);\n\t\t\t\t\t\treturn createConflictDetectionError('other');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!data) return { status: 'clean' };\n\n\t\t\t\tconst mergeConflict = parseMergeTreeConflict(data);\n\t\t\t\tif (!mergeConflict.conflicts.length) return { status: 'clean', treeOid: mergeConflict.treeOid };\n\n\t\t\t\treturn {\n\t\t\t\t\tstatus: 'conflicts',\n\t\t\t\t\tconflict: {\n\t\t\t\t\t\trepoPath: repoPath,\n\t\t\t\t\t\tbranch: branch,\n\t\t\t\t\t\ttarget: targetBranch,\n\t\t\t\t\t\tfiles: mergeConflict.conflicts,\n\t\t\t\t\t\tshas: undefined, // Merge conflicts don't have a specific commit SHA\n\t\t\t\t\t},\n\t\t\t\t\ttreeOid: mergeConflict.treeOid,\n\t\t\t\t};\n\t\t\t},\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\t/** Detects conflicts when an autostash is reapplied onto the tree an integration produced */\n\t@debug()\n\tasync getPotentialStashReapplyConflicts(\n\t\trepoPath: string,\n\t\tontoTreeOid: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<ConflictDetectionResult> {\n\t\t// Requires Git v2.38+ for --write-tree with 3-arg form\n\t\t// `runMergeTreeStep` relies on `--merge-base`\n\t\tif (!(await this.git.supports('git:merge-tree:merge-base'))) {\n\t\t\treturn createConflictDetectionError('unsupported');\n\t\t}\n\n\t\t// git stash create writes commit objects but touches neither the working tree nor the stash ref, and\n\t\t// captures tracked changes only — which is exactly what autostash does\n\t\tlet stashSha: string;\n\t\ttry {\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t'stash',\n\t\t\t\t'create',\n\t\t\t);\n\t\t\tstashSha = result.stdout.trim();\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn createConflictDetectionError('other');\n\t\t}\n\n\t\tif (!stashSha) return { status: 'clean' };\n\n\t\t// Key on what the simulation actually consumes — the stash's tree and its first parent (the HEAD it was\n\t\t// taken against, and so the merge base). The stash SHA itself embeds a commit timestamp, so two runs over\n\t\t// an identical tree produce different SHAs and a SHA-keyed entry could never be hit.\n\t\tlet stashTree: string;\n\t\tlet stashParent: string;\n\t\ttry {\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t'rev-parse',\n\t\t\t\t`${stashSha}^{tree}`,\n\t\t\t\t`${stashSha}^`,\n\t\t\t);\n\t\t\t[stashTree, stashParent] = result.stdout.trim().split('\\n');\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn createConflictDetectionError('other');\n\t\t}\n\n\t\tconst cacheKey: ConflictDetectionCacheKey = `reapply:${ontoTreeOid}:${stashTree}.${stashParent}`;\n\t\treturn this.cache.conflictDetection.getOrCreate(\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tasync (_cacheable, signal) => {\n\t\t\t\t// The stash commit's first parent is the HEAD it was taken against, which is the correct merge\n\t\t\t\t// base for a reapply — ours is the post-integration tree, theirs is the stash\n\t\t\t\tconst step = await this.runMergeTreeStep(repoPath, `${stashSha}^`, ontoTreeOid, stashSha, signal);\n\t\t\t\tif (!step.ok) return createConflictDetectionError(step.reason);\n\n\t\t\t\tif (!step.result.conflicts.length) return { status: 'clean', treeOid: step.result.treeOid };\n\n\t\t\t\treturn {\n\t\t\t\t\tstatus: 'conflicts',\n\t\t\t\t\tconflict: {\n\t\t\t\t\t\trepoPath: repoPath,\n\t\t\t\t\t\tbranch: stashSha,\n\t\t\t\t\t\ttarget: ontoTreeOid,\n\t\t\t\t\t\tfiles: step.result.conflicts,\n\t\t\t\t\t\tshas: undefined,\n\t\t\t\t\t},\n\t\t\t\t\ttreeOid: step.result.treeOid,\n\t\t\t\t};\n\t\t\t},\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\tprivate async runMergeTreeStep(\n\t\trepoPath: string,\n\t\tbase: string,\n\t\tours: string,\n\t\ttheirs: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<{ ok: true; result: GitMergeConflict } | { ok: false; reason: ConflictDetectionErrorReason }> {\n\t\tconst scope = getScopedLogger();\n\n\t\tlet data;\n\t\ttry {\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t'merge-tree',\n\t\t\t\t'--write-tree',\n\t\t\t\t'-z',\n\t\t\t\t'--name-only',\n\t\t\t\t'--no-messages',\n\t\t\t\t`--merge-base=${base}`,\n\t\t\t\tours,\n\t\t\t\ttheirs,\n\t\t\t);\n\t\t\tdata = result.stdout;\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\tconst msg: string = ex?.toString() ?? '';\n\t\t\tif (GitErrors.notAValidObjectName.test(msg)) {\n\t\t\t\tscope?.error(ex, `'${ours}' or '${theirs}' not found - ensure the branches/commits exist`);\n\t\t\t\treturn { ok: false, reason: 'refNotFound' };\n\t\t\t} else if (GitErrors.badRevision.test(msg)) {\n\t\t\t\tscope?.error(ex, `Invalid revision: ${msg.slice(msg.indexOf(\"'\"))}`);\n\t\t\t\treturn { ok: false, reason: 'refNotFound' };\n\t\t\t} else if (GitErrors.noMergeBase.test(msg)) {\n\t\t\t\tscope?.error(ex, `Unable to merge '${ours}' and '${theirs}' as they have no common ancestor`);\n\t\t\t\treturn { ok: false, reason: 'noMergeBase' };\n\t\t\t} else if (ex instanceof GitError) {\n\t\t\t\tdata = ex.stdout;\n\t\t\t} else {\n\t\t\t\tscope?.error(ex, 'Failed to execute merge-tree for conflict check');\n\t\t\t\treturn { ok: false, reason: 'other' };\n\t\t\t}\n\t\t}\n\n\t\treturn { ok: true, result: parseMergeTreeConflict(data ?? '') };\n\t}\n\n\tprivate async checkForPotentialConflicts(\n\t\trepoPath: string,\n\t\tcommits: Iterable<{ sha: string; parent: string }>,\n\t\ttargetBranch: string,\n\t\tcancellation?: AbortSignal,\n\t\toptions?: { stopOnFirstConflict?: boolean },\n\t): Promise<ConflictDetectionResult> {\n\t\tconst scope = getScopedLogger();\n\n\t\t// Requires Git v2.38+ for --write-tree with 3-arg form\n\t\t// `runMergeTreeStep` relies on `--merge-base`\n\t\tif (!(await this.git.supports('git:merge-tree:merge-base'))) {\n\t\t\treturn createConflictDetectionError('unsupported');\n\t\t}\n\n\t\tlet currentTreeOid: string;\n\t\ttry {\n\t\t\t// Get the initial target branch tree OID\n\t\t\tconst treeResult = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t'rev-parse',\n\t\t\t\t`${targetBranch}^{tree}`,\n\t\t\t);\n\t\t\tcurrentTreeOid = treeResult.stdout.trim();\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\tscope?.error(ex, `Failed to resolve target branch '${targetBranch}'`);\n\t\t\treturn createConflictDetectionError('refNotFound');\n\t\t}\n\n\t\tconst conflictingShas: string[] = [];\n\t\tconst conflictingFilePaths = new Set<string>();\n\n\t\tfor (const commit of commits) {\n\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t// Use merge-tree --write-tree with --merge-base to simulate cherry-pick:\n\t\t\t// merge-tree --write-tree --merge-base=<commit-parent> <current-tree> <commit>\n\t\t\t// This performs a 3-way merge where:\n\t\t\t// - base = commit.parent (where the commit started)\n\t\t\t// - ours = currentTreeOid (current state of the target)\n\t\t\t// - theirs = commit.sha (what we're cherry-picking)\n\t\t\tconst step = await this.runMergeTreeStep(repoPath, commit.parent, currentTreeOid, commit.sha, cancellation);\n\t\t\tif (!step.ok) return createConflictDetectionError(step.reason);\n\n\t\t\tconst mergeConflict = step.result;\n\n\t\t\tif (mergeConflict.conflicts.length) {\n\t\t\t\tconflictingShas.push(commit.sha);\n\t\t\t\tfor (const file of mergeConflict.conflicts) {\n\t\t\t\t\tconflictingFilePaths.add(file.path);\n\t\t\t\t}\n\n\t\t\t\tif (options?.stopOnFirstConflict) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstatus: 'conflicts',\n\t\t\t\t\t\tconflict: {\n\t\t\t\t\t\t\trepoPath: repoPath,\n\t\t\t\t\t\t\tbranch: commit.sha,\n\t\t\t\t\t\t\ttarget: targetBranch,\n\t\t\t\t\t\t\tfiles: mergeConflict.conflicts,\n\t\t\t\t\t\t\tshas: [commit.sha],\n\t\t\t\t\t\t},\n\t\t\t\t\t\tstoppedOnFirstConflict: true,\n\t\t\t\t\t\ttreeOid: mergeConflict.treeOid || undefined,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Update currentTreeOid to the result tree OID for the next iteration\n\t\t\t// This works even when there are conflicts - the tree contains conflict markers\n\t\t\tif (mergeConflict.treeOid) {\n\t\t\t\tcurrentTreeOid = mergeConflict.treeOid;\n\t\t\t}\n\t\t}\n\n\t\tif (conflictingShas.length) {\n\t\t\treturn {\n\t\t\t\tstatus: 'conflicts',\n\t\t\t\tconflict: {\n\t\t\t\t\trepoPath: repoPath,\n\t\t\t\t\tbranch: conflictingShas[0],\n\t\t\t\t\ttarget: targetBranch,\n\t\t\t\t\tfiles: Array.from(conflictingFilePaths, path => ({ path: path })),\n\t\t\t\t\tshas: conflictingShas,\n\t\t\t\t},\n\t\t\t\tstoppedOnFirstConflict: false,\n\t\t\t\ttreeOid: currentTreeOid,\n\t\t\t};\n\t\t}\n\n\t\treturn { status: 'clean', treeOid: currentTreeOid };\n\t}\n\n\t@debug({ exit: true })\n\tgetBaseBranchName(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: { priority?: GitCommandPriority },\n\t\tcancellation?: AbortSignal,\n\t): Promise<string | undefined> {\n\t\tconst priority = options?.priority;\n\t\tconst priorityOpts = priority != null ? { priority: priority } : undefined;\n\n\t\treturn this.cache.getBaseBranchName(\n\t\t\trepoPath,\n\t\t\tref,\n\t\t\tasync (commonPath, cacheable, signal) => {\n\t\t\t\ttry {\n\t\t\t\t\t// getGkConfig has built-in fallback to regular config for backward compatibility\n\t\t\t\t\tlet mergeBase = await this.provider.config.getGkConfig(commonPath, `branch.${ref}.gk-merge-base`);\n\t\t\t\t\tlet update = false;\n\n\t\t\t\t\t// Also check vscode-merge-base in regular config (VS Code compatibility)\n\t\t\t\t\tif (mergeBase == null) {\n\t\t\t\t\t\tmergeBase = await this.provider.config.getConfig(commonPath, `branch.${ref}.vscode-merge-base`);\n\t\t\t\t\t\tupdate = mergeBase != null;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (mergeBase != null) {\n\t\t\t\t\t\tconst branch = await this.provider.refs.getSymbolicReferenceName(\n\t\t\t\t\t\t\tcommonPath,\n\t\t\t\t\t\t\tmergeBase,\n\t\t\t\t\t\t\tpriorityOpts,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (branch != null) {\n\t\t\t\t\t\t\tif (update) {\n\t\t\t\t\t\t\t\t// Self-write: the value we're storing is exactly what this factory is\n\t\t\t\t\t\t\t\t// returning, so any in-flight `branchOverviews` or `baseBranchName` entry\n\t\t\t\t\t\t\t\t// being populated against this resolution should NOT be evicted.\n\t\t\t\t\t\t\t\tvoid this.storeBaseBranchName(commonPath, ref, branch, {\n\t\t\t\t\t\t\t\t\tskipInvalidation: ['branchOverviews', 'baseBranchName'],\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn branch;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch {}\n\n\t\t\t\tconst reflog = await this.getBaseBranchFromReflog(\n\t\t\t\t\tcommonPath,\n\t\t\t\t\tref,\n\t\t\t\t\t{ upstream: true, priority: priority },\n\t\t\t\t\tsignal,\n\t\t\t\t);\n\t\t\t\tif (reflog.branch != null) {\n\t\t\t\t\t// Self-write: see comment on the migration path above.\n\t\t\t\t\tvoid this.storeBaseBranchName(commonPath, ref, reflog.branch, {\n\t\t\t\t\t\tskipInvalidation: ['branchOverviews', 'baseBranchName'],\n\t\t\t\t\t});\n\t\t\t\t\treturn reflog.branch;\n\t\t\t\t}\n\n\t\t\t\t// This entry has no TTL and the `'branches'` cascade no longer clears it (a tip move can't\n\t\t\t\t// change a base), so a failed read cached as `undefined` would read as \"no base branch\" for\n\t\t\t\t// the rest of the session. Only a reflog that actually RAN and found nothing is an answer.\n\t\t\t\tif (reflog.failed) {\n\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\t/**\n\t * `failed` separates \"the reflog ran and had no answer\" from \"the read never happened\" — the caller\n\t * caches the former forever and must not cache the latter.\n\t */\n\tprivate async getBaseBranchFromReflog(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: { upstream: true; priority?: GitCommandPriority },\n\t\tcancellation?: AbortSignal,\n\t): Promise<{ branch: string | undefined; failed: boolean }> {\n\t\tconst priority = options?.priority;\n\t\tconst priorityOpts = priority != null ? { priority: priority } : undefined;\n\n\t\ttry {\n\t\t\tlet entries = await this.provider.refs.getReflogEntries(\n\t\t\t\trepoPath,\n\t\t\t\tref,\n\t\t\t\t{ grep: 'branch: Created from *.', priority: priority },\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (entries.length !== 1) return { branch: undefined, failed: false };\n\n\t\t\t// Check if branch created from an explicit branch\n\t\t\tlet match = entries[0].message.match(/branch: Created from (.*)$/);\n\t\t\tif (match?.length === 2) {\n\t\t\t\tlet name: string | undefined = match[1];\n\t\t\t\tif (name !== 'HEAD') {\n\t\t\t\t\tif (options?.upstream) {\n\t\t\t\t\t\tconst upstream = await this.provider.refs.getSymbolicReferenceName(\n\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\t`${name}@{u}`,\n\t\t\t\t\t\t\tpriorityOpts,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (upstream) return { branch: upstream, failed: false };\n\t\t\t\t\t}\n\n\t\t\t\t\tname = await this.provider.refs.getSymbolicReferenceName(repoPath, name, priorityOpts);\n\t\t\t\t\tif (name) return { branch: name, failed: false };\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Check if branch was created from HEAD\n\t\t\tentries = await this.provider.refs.getReflogEntries(\n\t\t\t\trepoPath,\n\t\t\t\t'HEAD',\n\t\t\t\t{ grep: `checkout: moving from .* to ${ref.replace('refs/heads/', '')}`, priority: priority },\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (!entries.length) return { branch: undefined, failed: false };\n\n\t\t\tmatch = entries.at(-1)!.message.match(/checkout: moving from ([^\\s]+)\\s/);\n\t\t\tif (match?.length === 2) {\n\t\t\t\tlet name: string | undefined = match[1];\n\t\t\t\tif (options?.upstream) {\n\t\t\t\t\tconst upstream = await this.provider.refs.getSymbolicReferenceName(\n\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t`${name}@{u}`,\n\t\t\t\t\t\tpriorityOpts,\n\t\t\t\t\t);\n\t\t\t\t\tif (upstream) return { branch: upstream, failed: false };\n\t\t\t\t}\n\n\t\t\t\tname = await this.provider.refs.getSymbolicReferenceName(repoPath, name, priorityOpts);\n\t\t\t\tif (name) return { branch: name, failed: false };\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t// A ref that is unborn, or gone since it was listed, has no reflog to read: an answer, not a failure\n\t\t\tconst msg: string = ex?.toString() ?? '';\n\t\t\tconst stderr = ex instanceof GitError ? ex.stderr : undefined;\n\t\t\tif (\n\t\t\t\t[GitErrors.badRevision, GitErrors.ambiguousArgument].some(\n\t\t\t\t\terror => error.test(msg) || (stderr != null && error.test(stderr)),\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn { branch: undefined, failed: false };\n\t\t\t}\n\n\t\t\t// `getReflogEntries` rejects on a failed read, so a read that never happened isn't taken as \"no base\"\n\t\t\treturn { branch: undefined, failed: true };\n\t\t}\n\n\t\treturn { branch: undefined, failed: false };\n\t}\n\n\t@debug({ exit: true })\n\tasync getAheadOfBase(repoPath: string, branch: string, cancellation?: AbortSignal): Promise<AheadOfBase> {\n\t\tif (isDetachedHead(branch)) return { base: undefined, dependsOn: [] };\n\n\t\tconst dependsOn = new Set<string>([`refs/heads/${branch}`]);\n\n\t\tlet target: string | undefined;\n\t\tfor (const candidate of await this.getRecordedBaseCandidates(repoPath, branch)) {\n\t\t\ttarget = await this.getNearestForkTarget(repoPath, branch, candidate, dependsOn, cancellation);\n\t\t\tif (target != null) break;\n\t\t}\n\n\t\tif (target == null) {\n\t\t\tconst defaultBranch = await this.getLocalDefaultBranchName(repoPath, dependsOn, cancellation);\n\t\t\ttarget = await this.getNearestForkTarget(repoPath, branch, defaultBranch, dependsOn, cancellation);\n\t\t}\n\n\t\t// The tolerant reads above answer a cancelled run as \"nothing there\"; that is no answer\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\t\tif (target == null) return { base: undefined, dependsOn: [...dependsOn] };\n\n\t\t// A base that is the branch itself, locally or as its copy on one of the repo's remotes, at HEAD's own commit has\n\t\t// nothing to measure against: no base, not \"0 ahead\" (an up-to-date `main` targeting `origin/main`). At a different\n\t\t// commit it stays the base, since the work ahead of it is work not yet pushed\n\t\tif (await this.isSelfAtHead(repoPath, target, branch, cancellation)) {\n\t\t\treturn { base: undefined, dependsOn: [...dependsOn] };\n\t\t}\n\n\t\t// `...` counts from the merge base, so only the branch's own commits count, not what the base moved on with\n\t\tconst range = createRevisionRange(target, 'HEAD', '...');\n\t\tconst [countsResult, refsResult] = await Promise.allSettled([\n\t\t\tthis.provider.commits.getLeftRightCommitCount(repoPath, range, undefined, cancellation),\n\t\t\t// The same cached `for-each-ref` the branch list reads, so the tip usually costs nothing\n\t\t\tthis.provider.refs.getRefs(repoPath, cancellation),\n\t\t]);\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tlet counts = getSettledValue(countsResult);\n\t\tif (counts == null) {\n\t\t\t// The cached count keeps a failure, so re-run it uncached. Before HEAD's first commit there is nothing to\n\t\t\t// count, so no base; any other failure rejects with git's error\n\t\t\ttry {\n\t\t\t\tcounts = await this.getLeftRightCountUncached(repoPath, range, cancellation);\n\t\t\t} catch (ex) {\n\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\tif (await this.isUnbornHead(repoPath, cancellation)) {\n\t\t\t\t\treturn { base: undefined, dependsOn: [...dependsOn] };\n\t\t\t\t}\n\n\t\t\t\tthrow ex;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tbase: { ref: target, ahead: counts.right, sha: findRefTip(getSettledValue(refsResult, []), target) },\n\t\t\tdependsOn: [...dependsOn],\n\t\t};\n\t}\n\n\t/** Counts `range` with a fresh `rev-list`, bypassing the cached count. Rejects on any failure, with git's error */\n\tprivate async getLeftRightCountUncached(\n\t\trepoPath: string,\n\t\trange: GitRevisionRange,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<{ left: number; right: number }> {\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t'rev-list',\n\t\t\t'--left-right',\n\t\t\t'--count',\n\t\t\trange,\n\t\t\t'--',\n\t\t);\n\t\tif (result.completion.status === 'cancelled' || cancellation?.aborted) throw new CancellationError();\n\n\t\tconst parts = result.stdout.split('\\t');\n\t\tconst left = parseInt(parts[0], 10);\n\t\tconst right = parseInt(parts[1], 10);\n\t\tif (parts.length !== 2 || isNaN(left) || isNaN(right)) {\n\t\t\tthrow new Error(`Unexpected output counting the commits in '${range}': ${result.stdout}`);\n\t\t}\n\n\t\treturn { left: left, right: right };\n\t}\n\n\t/** Whether HEAD names a branch with no commit yet. Rejects when that can't be read, so a failure isn't taken for an empty branch */\n\tprivate async isUnbornHead(repoPath: string, cancellation: AbortSignal | undefined): Promise<boolean> {\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw', expectedExitCodes: [1] },\n\t\t\t'rev-parse',\n\t\t\t'--verify',\n\t\t\t'--quiet',\n\t\t\t'HEAD',\n\t\t);\n\t\treturn result.exitCode === 1;\n\t}\n\n\t/**\n\t * Whether `ref` names `branch` itself: the same name, or `<remote>/<branch>` for one of the repo's actual remotes.\n\t * Splitting at the first slash instead would call a local `release/main` the same branch as `main`.\n\t */\n\tprivate async isSelfRef(\n\t\trepoPath: string,\n\t\tref: string,\n\t\tbranch: string,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<boolean> {\n\t\tif (ref === branch) return true;\n\n\t\tconst suffix = `/${branch}`;\n\t\tif (!ref.endsWith(suffix)) return false;\n\n\t\tconst remoteName = ref.slice(0, -suffix.length);\n\t\tif (!remoteName) return false;\n\n\t\ttry {\n\t\t\tconst remotes = await this.provider.remotes.getRemotes(repoPath, undefined, cancellation);\n\t\t\treturn remotes.some(r => r.name === remoteName);\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/** Whether `ref` names `branch` itself (see {@link isSelfRef}) and sits at HEAD's commit; tips are read only after the name matched */\n\tprivate async isSelfAtHead(\n\t\trepoPath: string,\n\t\tref: string,\n\t\tbranch: string,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<boolean> {\n\t\tif (!(await this.isSelfRef(repoPath, ref, branch, cancellation))) return false;\n\n\t\tconst [refSha, headSha] = await Promise.all([\n\t\t\tthis.provider.refs.validateReference(repoPath, ref, undefined, cancellation),\n\t\t\tthis.provider.refs.validateReference(repoPath, 'HEAD', undefined, cancellation),\n\t\t]);\n\t\treturn refSha != null && refSha === headSha;\n\t}\n\n\t/**\n\t * The bases recorded against a branch, most trusted first: the user's merge target, the detected one, then the\n\t * base a launch recorded. Only the stored value of the latter — `getBaseBranchName` would fall back to a reflog\n\t * guess, which on a long-lived checkout names whatever branch was last checked out from. A failed read is absent.\n\t */\n\tprivate async getRecordedBaseCandidates(repoPath: string, branch: string): Promise<string[]> {\n\t\tconst tolerate = async (read: () => Promise<string | undefined>): Promise<string | undefined> => {\n\t\t\ttry {\n\t\t\t\treturn (await read())?.trim() || undefined;\n\t\t\t} catch (ex) {\n\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t};\n\n\t\tconst reads = await Promise.all([\n\t\t\ttolerate(() => this.getStoredUserMergeTargetBranchName(repoPath, branch)),\n\t\t\ttolerate(() => this.getStoredDetectedMergeTargetBranchName(repoPath, branch)),\n\t\t\ttolerate(() => this.provider.config.getGkConfig(repoPath, `branch.${branch}.gk-merge-base`)),\n\t\t]);\n\n\t\tconst candidates: string[] = [];\n\t\tfor (const candidate of reads) {\n\t\t\tif (candidate && !candidates.includes(candidate)) {\n\t\t\t\tcandidates.push(candidate);\n\t\t\t}\n\t\t}\n\t\treturn candidates;\n\t}\n\n\t/**\n\t * The repo's default branch from local refs only: the `origin/HEAD` symref as its local name, else\n\t * `init.defaultBranch`, else `main`, else `master` — each only if it names a commit.\n\t */\n\tprivate async getLocalDefaultBranchName(\n\t\trepoPath: string,\n\t\tdependsOn: Set<string>,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<string | undefined> {\n\t\tdependsOn.add('refs/remotes/origin/HEAD');\n\n\t\tconst symref = await this.getDefaultBranchName(repoPath, 'origin', { local: true }, cancellation);\n\t\tif (symref) {\n\t\t\tconst slash = symref.indexOf('/');\n\t\t\tconst local = slash >= 0 ? symref.slice(slash + 1) : symref;\n\t\t\tif (local) {\n\t\t\t\taddRefDependencies(dependsOn, local);\n\t\t\t\tif (await this.provider.refs.validateReference(repoPath, local, undefined, cancellation)) return local;\n\t\t\t}\n\t\t}\n\n\t\tlet fromConfig: string | undefined;\n\t\ttry {\n\t\t\tfromConfig = (await this.provider.config.getConfig(repoPath, 'init.defaultBranch'))?.trim() || undefined;\n\t\t} catch {}\n\n\t\tfor (const candidate of [fromConfig, 'main', 'master']) {\n\t\t\tif (!candidate) continue;\n\n\t\t\taddRefDependencies(dependsOn, candidate);\n\t\t\tif (await this.provider.refs.validateReference(repoPath, candidate, undefined, cancellation)) {\n\t\t\t\treturn candidate;\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * A candidate base as the ref HEAD is measured against: the candidate or its tracking ref, whichever forked\n\t * nearer HEAD, so a stale local base defers to its upstream while one carrying unpushed work wins over it. A\n\t * candidate neither forks from is used as-is if it names a commit. `undefined` when the candidate is unusable.\n\t */\n\tprivate async getNearestForkTarget(\n\t\trepoPath: string,\n\t\tbranch: string,\n\t\tcandidate: string | undefined,\n\t\tdependsOn: Set<string>,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<string | undefined> {\n\t\t// A ref starting with `-` would be parsed as a git flag\n\t\tif (!candidate || candidate.startsWith('-')) return undefined;\n\t\t// A branch measured against itself says nothing\n\t\tif (candidate === branch) return undefined;\n\n\t\taddRefDependencies(dependsOn, candidate);\n\n\t\tconst getUpstreamFork = async (): Promise<{ ref: string; mergeBase: string | undefined } | undefined> => {\n\t\t\tconst upstream = await this.provider.refs.getSymbolicReferenceName(\n\t\t\t\trepoPath,\n\t\t\t\t`${candidate}@{u}`,\n\t\t\t\tundefined,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (!upstream || upstream.startsWith('-')) return undefined;\n\n\t\t\taddRefDependencies(dependsOn, upstream);\n\t\t\treturn { ref: upstream, mergeBase: await this.getForkPoint(repoPath, upstream, cancellation) };\n\t\t};\n\n\t\tconst [candidateMergeBase, upstreamFork] = await Promise.all([\n\t\t\tthis.getForkPoint(repoPath, candidate, cancellation),\n\t\t\tgetUpstreamFork(),\n\t\t]);\n\n\t\tlet nearest: { ref: string; mergeBase: string } | undefined;\n\t\tfor (const fork of [{ ref: candidate, mergeBase: candidateMergeBase }, upstreamFork]) {\n\t\t\tif (fork?.mergeBase == null) continue;\n\n\t\t\t// A later ref wins only when it forked at or past the nearest so far\n\t\t\tif (\n\t\t\t\tnearest == null ||\n\t\t\t\tnearest.mergeBase === fork.mergeBase ||\n\t\t\t\t(await this.provider.commits.isAncestorOf(repoPath, nearest.mergeBase, fork.mergeBase, cancellation))\n\t\t\t) {\n\t\t\t\tnearest = { ref: fork.ref, mergeBase: fork.mergeBase };\n\t\t\t}\n\t\t}\n\t\tif (nearest != null) return nearest.ref;\n\n\t\treturn (await this.provider.refs.validateReference(repoPath, candidate, undefined, cancellation))\n\t\t\t? candidate\n\t\t\t: undefined;\n\t}\n\n\t/** The merge base of HEAD and `ref`, preferring git's fork-point reading of `ref`'s reflog when it has one */\n\tprivate async getForkPoint(\n\t\trepoPath: string,\n\t\tref: string,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<string | undefined> {\n\t\tconst forkPoint = await this.provider.refs.getMergeBase(\n\t\t\trepoPath,\n\t\t\tref,\n\t\t\t'HEAD',\n\t\t\t{ forkPoint: true },\n\t\t\tcancellation,\n\t\t);\n\t\treturn forkPoint ?? this.provider.refs.getMergeBase(repoPath, 'HEAD', ref, undefined, cancellation);\n\t}\n\n\t/**\n\t * The stored merge target — the user's pick, else the one detected from its PR — skipping any whose branch git\n\t * confirms is gone so resolution falls through to the next source. A target that couldn't be checked is kept.\n\t * The stored keys are never rewritten here: the user pick is the user's, and Kepler shares the file.\n\t */\n\t@debug({ exit: true })\n\tasync getStoredMergeTargetBranchName(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: { detectedOnly?: boolean; priority?: GitCommandPriority },\n\t\tcancellation?: AbortSignal,\n\t): Promise<string | undefined> {\n\t\tconst priority = options?.priority;\n\n\t\tlet goneUserTarget: string | undefined;\n\t\tif (!options?.detectedOnly) {\n\t\t\tconst userTarget = await this.getStoredUserMergeTargetBranchName(repoPath, ref);\n\t\t\tif (userTarget) {\n\t\t\t\tconst resolved = await this.resolveStoredMergeTarget(repoPath, userTarget, priority, cancellation);\n\t\t\t\tif (resolved) return resolved;\n\n\t\t\t\tgoneUserTarget = userTarget;\n\t\t\t}\n\t\t}\n\n\t\tconst detectedTarget = await this.getStoredDetectedMergeTargetBranchName(repoPath, ref);\n\t\tif (!detectedTarget || detectedTarget === goneUserTarget) return undefined;\n\n\t\treturn this.resolveStoredMergeTarget(repoPath, detectedTarget, priority, cancellation);\n\t}\n\n\tprivate async resolveStoredMergeTarget(\n\t\trepoPath: string,\n\t\ttarget: string,\n\t\tpriority: GitCommandPriority | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<string | undefined> {\n\t\tconst { name, missing } = await this.provider.refs.getSymbolicReferenceNameOrMissing(\n\t\t\trepoPath,\n\t\t\ttarget,\n\t\t\tpriority != null ? { priority: priority } : undefined,\n\t\t\tcancellation,\n\t\t);\n\t\treturn missing ? undefined : name || target;\n\t}\n\n\t@debug({ exit: true })\n\tasync getStoredDetectedMergeTargetBranchName(repoPath: string, ref: string): Promise<string | undefined> {\n\t\tconst target =\n\t\t\t(await this.provider.config.getGkConfig(repoPath, `branch.${ref}.gk-merge-target`)) ??\n\t\t\t(await this.provider.config.getGkConfig(repoPath, `branch.${ref}.gk-target-base`)); // legacy key\n\t\treturn target?.trim() || undefined;\n\t}\n\n\t@debug()\n\tasync getStoredUserMergeTargetBranchName(repoPath: string, ref: string): Promise<string | undefined> {\n\t\tconst target = await this.provider.config.getGkConfig(repoPath, `branch.${ref}.gk-merge-target-user`);\n\t\treturn target?.trim() || undefined;\n\t}\n\n\t/** Updates the last accessed timestamp for the current branch */\n\t@debounce(2.5 * 60 * 1000)\n\t@debug()\n\tasync onCurrentBranchAccessed(repoPath: string): Promise<void> {\n\t\tconst branch = await this.getBranch(repoPath);\n\t\tif (branch == null || branch.remote || branch.detached) return;\n\n\t\tawait this.storeBranchMetadata(repoPath, 'gk-last-accessed', branch.name, new Date());\n\t}\n\n\t/** Updates the last accessed and modified timestamp for the current branch */\n\t@debounce(2.5 * 60 * 1000)\n\t@debug()\n\tasync onCurrentBranchModified(repoPath: string): Promise<void> {\n\t\tconst branch = await this.getBranch(repoPath);\n\t\tif (branch == null || branch.remote || branch.detached) return;\n\n\t\tconst now = new Date();\n\t\tawait this.storeBranchMetadata(repoPath, 'gk-last-accessed', branch.name, now);\n\t\tawait this.storeBranchMetadata(repoPath, 'gk-last-modified', branch.name, now);\n\t}\n\n\t/** Updates the agent last activity timestamp for the current branch */\n\t@debounce(2.5 * 60 * 1000)\n\t@debug()\n\tasync onCurrentBranchAgentActivity(repoPath: string): Promise<void> {\n\t\tconst branch = await this.getBranch(repoPath);\n\t\tif (branch == null || branch.remote || branch.detached) return;\n\n\t\tawait this.storeBranchMetadata(repoPath, 'gk-agent-last-activity', branch.name, new Date());\n\t}\n\n\t@debug()\n\tasync renameBranch(repoPath: string, oldName: string, newName: string): Promise<void> {\n\t\tconst args = ['branch', '-m', oldName, newName];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t\t// The branch keeps its identity across a rename, so move its stored gk metadata with it —\n\t\t\t// otherwise the new name re-derives a base it already had, and the old name is left holding\n\t\t\t// metadata for a branch that no longer exists under it.\n\t\t\tawait this.provider.config.renameGkConfigBranchSection(repoPath, oldName, newName);\n\t\t\t// Old name's entry is now orphaned; the new name must not inherit a predecessor's base\n\t\t\tthis.cache.deleteBaseBranchName(repoPath, oldName);\n\t\t\tthis.cache.deleteBaseBranchName(repoPath, newName);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['heads']);\n\t\t} catch (ex) {\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'branch',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew BranchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\taction: 'rename',\n\t\t\t\t\t\t\tbranch: oldName,\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,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t@debug()\n\tasync setUpstreamBranch(repoPath: string, name: string, upstream: string | undefined): Promise<void> {\n\t\tconst args =\n\t\t\tupstream == null ? ['branch', '--unset-upstream', name] : ['branch', '--set-upstream-to', upstream, name];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['heads']);\n\t\t} catch (ex) {\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'branch',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew BranchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\taction: upstream == null ? 'unset upstream of' : `set upstream to '${upstream}' for`,\n\t\t\t\t\t\t\tbranch: name,\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,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t@debug()\n\tasync storeBaseBranchName(\n\t\trepoPath: string,\n\t\tref: string,\n\t\tbase: string,\n\t\toptions?: { skipInvalidation?: readonly GkConfigInvalidationTarget[] },\n\t): Promise<void> {\n\t\tawait this.provider.config.setGkConfig(repoPath, `branch.${ref}.gk-merge-base`, base, options);\n\t}\n\n\t@debug()\n\tasync storeMergeTargetBranchName(\n\t\trepoPath: string,\n\t\tref: string,\n\t\ttarget: string,\n\t\toptions?: { skipInvalidation?: readonly GkConfigInvalidationTarget[] },\n\t): Promise<void> {\n\t\t// An unchanged value isn't rewritten: the write would churn the file Kepler shares and drop the cached gk config\n\t\tif ((await this.provider.config.getGkConfig(repoPath, `branch.${ref}.gk-merge-target`)) === target) return;\n\n\t\tawait this.provider.config.setGkConfig(repoPath, `branch.${ref}.gk-merge-target`, target, options);\n\t}\n\n\t@debug()\n\tasync storeUserMergeTargetBranchName(repoPath: string, ref: string, target: string | undefined): Promise<void> {\n\t\tawait this.provider.config.setGkConfig(repoPath, `branch.${ref}.gk-merge-target-user`, target);\n\t}\n\n\t/**\n\t * Gets all branch metadata (dates and disposition) from git config in a single batch operation.\n\t * @returns A map of branch name to metadata.\n\t */\n\tprivate getBranchMetadataMap(repoPath: string): Promise<Map<string, BranchMetadata>> {\n\t\treturn this.cache.getBranchMetadataMap(repoPath, async commonPath => {\n\t\t\tconst scope = getScopedLogger();\n\t\t\tconst metadataMap = new Map<string, BranchMetadata>();\n\n\t\t\ttry {\n\t\t\t\t// Use git config --get-regexp to load all gk-* branch metadata in one call\n\t\t\t\tconst configMap = await this.provider.config.getGkConfigRegex(\n\t\t\t\t\tcommonPath,\n\t\t\t\t\t'^branch\\\\..*\\\\.gk-(last-(accessed|modified)|disposition|agent-last-activity)$',\n\t\t\t\t);\n\t\t\t\tif (!configMap.size) return metadataMap;\n\n\t\t\t\tfor (const [key, value] of configMap) {\n\t\t\t\t\t// Extract branch name and metadata key from \"branch.{name}.gk-{key}\"\n\t\t\t\t\tif (!key.startsWith('branch.')) continue;\n\n\t\t\t\t\tconst keyParts = key.split('.');\n\t\t\t\t\tif (keyParts.length < 3) continue;\n\n\t\t\t\t\t// Branch name is everything between \"branch.\" and the last \".gk-*\"\n\t\t\t\t\tconst metaKey = keyParts.at(-1);\n\t\t\t\t\tconst branchName = keyParts.slice(1, -1).join('.');\n\n\t\t\t\t\tlet metadata = metadataMap.get(branchName);\n\t\t\t\t\tif (metadata == null) {\n\t\t\t\t\t\tmetadata = {};\n\t\t\t\t\t\tmetadataMap.set(branchName, metadata);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (metaKey === 'gk-last-accessed') {\n\t\t\t\t\t\tmetadata.lastAccessedAt = value;\n\t\t\t\t\t} else if (metaKey === 'gk-last-modified') {\n\t\t\t\t\t\tmetadata.lastModifiedAt = value;\n\t\t\t\t\t} else if (metaKey === 'gk-agent-last-activity') {\n\t\t\t\t\t\tmetadata.agentLastActivityAt = value;\n\t\t\t\t\t} else if (metaKey === 'gk-disposition') {\n\t\t\t\t\t\tif (value === 'starred' || value === 'archived') {\n\t\t\t\t\t\t\tmetadata.disposition = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (ex) {\n\t\t\t\tdebugger;\n\t\t\t\tscope?.error(ex);\n\t\t\t}\n\n\t\t\treturn metadataMap;\n\t\t});\n\t}\n\n\tprivate async storeBranchMetadata(\n\t\trepoPath: string,\n\t\tkey: 'gk-last-accessed' | 'gk-last-modified' | 'gk-agent-last-activity',\n\t\tref: string,\n\t\tdate: Date,\n\t): Promise<void> {\n\t\tconst value = await this.provider.config.getGkConfig(repoPath, `branch.${ref}.${key}`);\n\t\t// Skip if incoming date is not at least 5 minutes newer than stored date\n\t\tif (value != null && date.getTime() - new Date(value).getTime() < dateMetadataStaleThresholdMs) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn this.provider.config.setGkConfig(repoPath, `branch.${ref}.${key}`, date.toISOString());\n\t}\n\n\tasync setBranchDisposition(\n\t\trepoPath: string,\n\t\tbranchName: string,\n\t\tdisposition: BranchDisposition | undefined,\n\t): Promise<void> {\n\t\tawait this.provider.config.setGkConfig(repoPath, `branch.${branchName}.gk-disposition`, disposition);\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['starred']);\n\t}\n}\n\n/**\n * The commit `name` resolves to among `records`, tried in git's own order for a short name (`refs/tags/` before\n * `refs/heads/` before `refs/remotes/`); annotated tags peel to their commit. `undefined` when no listed ref matches.\n */\nfunction findRefTip(records: readonly RefRecord[], name: string): string | undefined {\n\tfor (const candidate of [\n\t\tname,\n\t\t`refs/${name}`,\n\t\t`refs/tags/${name}`,\n\t\t`refs/heads/${name}`,\n\t\t`refs/remotes/${name}`,\n\t\t`refs/remotes/${name}/HEAD`,\n\t]) {\n\t\tconst record = records.find(r => r.name === candidate);\n\t\tif (record != null) return record.peeledObjectname || record.objectname;\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Adds the full ref names a `.git/refs` watcher would report for `name`. A short name can't be told tag from local\n * from remote without a spawn, so it adds every form, including the tag git resolves it to first; a spurious one\n * only costs a recompute.\n */\nfunction addRefDependencies(dependsOn: Set<string>, name: string): void {\n\tif (name.startsWith('refs/')) {\n\t\tdependsOn.add(name);\n\t\treturn;\n\t}\n\n\tdependsOn.add(`refs/tags/${name}`);\n\tdependsOn.add(`refs/heads/${name}`);\n\tdependsOn.add(`refs/remotes/${name}`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;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M,CAAA,GAAA,uBAAA,WAAA,qBAAA,IAAA;AA0BN,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,uBAAA,IAAA;AAUN,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,8BAAA,IAAA;AAaN,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,kCAAA,IAAA;;;;;AA0FR,SAAS,WAAW,SAA+B,MAAkC;CACpF,KAAK,MAAM,aAAa;EACvB;EACA,QAAQ;EACR,aAAa;EACb,cAAc;EACd,gBAAgB;EAChB,gBAAgB,KAAK;CACtB,GAAG;EACF,MAAM,SAAS,QAAQ,MAAK,MAAK,EAAE,SAAS,SAAS;EACrD,IAAI,UAAU,MAAM,OAAO,OAAO,oBAAoB,OAAO;CAC9D;AAGD;;;;;;AAOA,SAAS,mBAAmB,WAAwB,MAAoB;CACvE,IAAI,KAAK,WAAW,OAAO,GAAG;EAC7B,UAAU,IAAI,IAAI;EAClB;CACD;CAEA,UAAU,IAAI,aAAa,MAAM;CACjC,UAAU,IAAI,cAAc,MAAM;CAClC,UAAU,IAAI,gBAAgB,MAAM;AACrC"}
|
|
1
|
+
{"version":3,"file":"branches.js","names":["Logger"],"sources":["../../../../git-cli/src/providers/branches.ts"],"sourcesContent":["import type { Cache, ConflictDetectionCacheKey, GkConfigInvalidationTarget } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport { BranchError } from '@gitlens/git/errors.js';\nimport type { BranchDisposition, BranchMetadata } from '@gitlens/git/models/branch.js';\nimport { GitBranch } from '@gitlens/git/models/branch.js';\nimport type { ConflictDetectionErrorReason, ConflictDetectionResult } from '@gitlens/git/models/mergeConflicts.js';\nimport type { GitBranchReference, RefRecord } from '@gitlens/git/models/reference.js';\nimport type { GitRevisionRange } from '@gitlens/git/models/revision.js';\nimport type {\n\tAheadOfBase,\n\tAheadOfBaseTier,\n\tBranchContributionsOverview,\n\tGitBranchesSubProvider,\n\tGitBranchMergedStatus,\n} from '@gitlens/git/providers/branches.js';\nimport type { GitCommandPriority, GitRunOptions } from '@gitlens/git/run.types.js';\nimport {\n\tformatDetachedHeadName,\n\tgetLocalBranchByUpstream,\n\tisDetachedHead,\n\tisRemoteHEAD,\n\tparseBranchMetadataGkConfigKey,\n\tparseRefName,\n\tparseUpstream,\n\tsetBranchMetadataValue,\n} from '@gitlens/git/utils/branch.utils.js';\nimport { createConflictDetectionError } from '@gitlens/git/utils/mergeConflicts.utils.js';\nimport { createReference } from '@gitlens/git/utils/reference.utils.js';\nimport { createRevisionRange, shortenRevision } from '@gitlens/git/utils/revision.utils.js';\nimport type { BranchSortOptions } from '@gitlens/git/utils/sorting.js';\nimport { sortBranches, sortContributors } from '@gitlens/git/utils/sorting.js';\nimport { ensureArray, filterMap } from '@gitlens/utils/array.js';\nimport { CancellationError, isCancellationError } from '@gitlens/utils/cancellation.js';\nimport { debug, trace } from '@gitlens/utils/decorators/log.js';\nimport { getBranchId } from '@gitlens/utils/gitRefs.js';\nimport { sum } from '@gitlens/utils/iterable.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { LruMap } from '@gitlens/utils/lruMap.js';\nimport type { PagedResult, PagingOptions } from '@gitlens/utils/paging.js';\nimport { emptyPagedResult, PageableResult } from '@gitlens/utils/paging.js';\nimport { normalizePath } from '@gitlens/utils/path.js';\nimport { getSettledValue, mapBounded } from '@gitlens/utils/promise.js';\nimport type { CacheController } from '@gitlens/utils/promiseCache.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport { mayWriteTracking } from '../exec/commandClassifier.js';\nimport type { GitResult } from '../exec/exec.types.js';\nimport type { Git } from '../exec/git.js';\nimport {\n\tgetGitCommandError,\n\tgitConfigsBranch,\n\tgitConfigsLog,\n\tGitError,\n\tGitErrors,\n\tGitWarnings,\n\tmaxGitCliLength,\n} from '../exec/git.js';\nimport { KeyedSequencer } from '../exec/indexLock.js';\nimport type { GitMergeConflict } from '../parsers/mergeTreeParser.js';\nimport { parseMergeTreeConflict } from '../parsers/mergeTreeParser.js';\n\n/** Minimum time between writes to the config for last accessed/modified dates */\nconst dateMetadataStaleThresholdMs = 5 * 60 * 1000; // 5 minutes\n\n/**\n * Run options that keep an unrequested remote read from prompting for credentials or hanging on a dead host.\n * An empty `GIT_ASKPASS` also stops git consulting `core.askPass` and `SSH_ASKPASS` itself.\n */\nconst nonInteractiveNetworkOptions = {\n\tconfigs: ['-c', 'credential.interactive=false'],\n\tenv: {\n\t\tGIT_TERMINAL_PROMPT: '0',\n\t\tGIT_ASKPASS: '',\n\t\tSSH_ASKPASS: '',\n\t\tSSH_ASKPASS_REQUIRE: 'never',\n\t\tGCM_INTERACTIVE: 'never',\n\t},\n\ttimeout: 10_000,\n} as const satisfies GitRunOptions;\n\nconst branchActivityKeys = ['gk-last-accessed', 'gk-last-modified', 'gk-agent-last-activity'] as const;\ntype BranchActivityKey = (typeof branchActivityKeys)[number];\n\nexport class BranchesGitSubProvider implements GitBranchesSubProvider {\n\t/** Ahead/behind counts by `<baseSha>...<tipSha>` range, from the per-tip fallback; a pair of commits always counts the same */\n\tprivate readonly aheadBehindBySha = new LruMap<string, { ahead: number; behind: number }>(4096);\n\t/**\n\t * When each `commonPath\\0branch\\0key` was last stamped by this process. Bounded: a dropped entry only costs a\n\t * read of the stored stamp, which still holds off a write under 5 minutes old\n\t */\n\tprivate readonly _branchActivityStamps = new LruMap<string, number>(1024);\n\t/** One call per `commonPath\\0branch` at a time, so a call held off by another's write in flight settles after it */\n\tprivate readonly _branchActivityCalls = new KeyedSequencer();\n\t/**\n\t * What each `commonPath\\0branch`'s reflog says it was created from, as git wrote it; `undefined` when it says\n\t * nothing. A branch's creation never changes, so the base read, which reruns on every commit and ref move, reads\n\t * it once\n\t */\n\tprivate readonly _branchCreatedFrom = new LruMap<string, string | undefined>(1024);\n\t/** Bumped each time a key's created-from is forgotten, so a reflog read in flight across that doesn't store it */\n\tprivate readonly _branchCreatedFromGenerations = new LruMap<string, number>(1024);\n\n\tconstructor(\n\t\tprivate readonly context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t) {}\n\n\t@debug()\n\tasync getBranch(\n\t\trepoPath: string,\n\t\tname?: string,\n\t\toptions?: { force?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranch | undefined> {\n\t\tif (options?.force) {\n\t\t\tthis.cache.evictCaches(repoPath, 'branches');\n\t\t}\n\n\t\tif (name != null) {\n\t\t\tconst {\n\t\t\t\tvalues: [branch],\n\t\t\t} = await this.getBranches(repoPath, { filter: b => b.name === name }, cancellation);\n\t\t\treturn branch;\n\t\t}\n\n\t\tconst branchPromise = this.cache.branch.getOrCreate(\n\t\t\trepoPath,\n\t\t\tasync (_cacheable, signal) => {\n\t\t\t\tconst {\n\t\t\t\t\tvalues: [branch],\n\t\t\t\t} = await this.getBranches(repoPath, { filter: b => b.current }, signal);\n\t\t\t\treturn branch ?? this.getCurrentBranch(repoPath, undefined, undefined, signal);\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\n\t\tif (branchPromise == null) {\n\t\t\tconst {\n\t\t\t\tvalues: [branch],\n\t\t\t} = await this.getBranches(repoPath, { filter: b => b.current }, cancellation);\n\t\t\treturn branch ?? this.getCurrentBranch(repoPath, undefined, undefined, cancellation);\n\t\t}\n\n\t\treturn branchPromise;\n\t}\n\n\tprivate async getCurrentBranch(\n\t\trepoPath: string,\n\t\tmetadataMap: Map<string, BranchMetadata> | undefined,\n\t\tordering: string | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranch | undefined> {\n\t\tconst ref = await this.getCurrentBranchReferenceCore(repoPath, ordering, cancellation);\n\t\tif (ref == null) return undefined;\n\n\t\tconst [pausedOpStatusResult, committerDateResult, defaultWorktreePathResult, metadataMapResult] =\n\t\t\tawait Promise.allSettled([\n\t\t\t\tisDetachedHead(ref.name)\n\t\t\t\t\t? this.provider.pausedOps?.getPausedOperationStatus(repoPath, undefined, cancellation)\n\t\t\t\t\t: undefined,\n\t\t\t\tthis.git\n\t\t\t\t\t.run(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcwd: repoPath,\n\t\t\t\t\t\t\tcancellation: cancellation,\n\t\t\t\t\t\t\tconfigs: gitConfigsLog,\n\t\t\t\t\t\t\terrors: 'ignore',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'log',\n\t\t\t\t\t\t'-n1',\n\t\t\t\t\t\t'--format=%ct',\n\t\t\t\t\t\tordering ? `--${ordering}-order` : undefined,\n\t\t\t\t\t\t'--',\n\t\t\t\t\t)\n\t\t\t\t\t.then(result => (result.stdout ? result.stdout.trim() : undefined)),\n\t\t\t\tthis.provider.config.getDefaultWorktreePath?.(repoPath),\n\t\t\t\tmetadataMap != null ? Promise.resolve(metadataMap) : this.getBranchMetadataMap(repoPath),\n\t\t\t]);\n\n\t\tconst committerDate = getSettledValue(committerDateResult);\n\t\tconst pausedOpStatus = getSettledValue(pausedOpStatusResult);\n\t\tconst rebaseStatus = pausedOpStatus?.type === 'rebase' ? pausedOpStatus : undefined;\n\t\tconst defaultWorktreePath = getSettledValue(defaultWorktreePathResult);\n\t\tmetadataMap ??= getSettledValue(metadataMapResult);\n\t\tconst metadata = metadataMap?.get(ref.name);\n\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst branchRefName = rebaseStatus?.incoming.name ?? `refs/heads/${ref.name}`;\n\n\t\tconst branch = new GitBranch(\n\t\t\trepoPath, // Use worktree-specific path for consistent IDs within each worktree\n\t\t\tbranchRefName,\n\t\t\ttrue,\n\t\t\tcommitterDate != null ? new Date(Number(committerDate) * 1000) : undefined,\n\t\t\tmetadata,\n\t\t\tref.sha,\n\t\t\tref.upstream ? { ...ref.upstream, state: { ahead: 0, behind: 0 } } : undefined,\n\t\t\t{ path: repoPath, isDefault: repoPath === defaultWorktreePath },\n\t\t\tundefined,\n\t\t\trebaseStatus != null,\n\t\t);\n\n\t\treturn branch;\n\t}\n\n\t@debug({ args: repoPath => ({ repoPath: repoPath }) })\n\tasync getBranches(\n\t\trepoPath: string,\n\t\toptions?: {\n\t\t\tfilter?: (b: GitBranch) => boolean;\n\t\t\tordering?: 'date' | 'author-date' | 'topo' | null;\n\t\t\tpaging?: PagingOptions;\n\t\t\tsort?: boolean | BranchSortOptions;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<PagedResult<GitBranch>> {\n\t\tif (repoPath == null) return emptyPagedResult;\n\n\t\tconst scope = getScopedLogger();\n\n\t\tconst getCore = async (\n\t\t\tcommonPath: string,\n\t\t\tcacheable?: CacheController,\n\t\t\tsignal?: AbortSignal,\n\t\t): Promise<PagedResult<GitBranch>> => {\n\t\t\t// Prefer the aggregate signal from the cache when present; fall back to the caller's\n\t\t\t// own cancellation when bypassing the cache (e.g. paging-cursor path).\n\t\t\tsignal ??= cancellation;\n\t\t\ttry {\n\t\t\t\tconst [recordsResult, supportedResult, defaultWorktreePathResult, metadataMapResult] =\n\t\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\t\tthis.provider.refs.getRefs(commonPath, signal),\n\t\t\t\t\t\tthis.git.supported('git:for-each-ref'),\n\t\t\t\t\t\tthis.provider.config.getDefaultWorktreePath?.(commonPath),\n\t\t\t\t\t\tthis.getBranchMetadataMap(commonPath),\n\t\t\t\t\t]);\n\n\t\t\t\tconst records = getSettledValue(recordsResult) ?? [];\n\t\t\t\tconst supported = getSettledValue(supportedResult) ?? [];\n\t\t\t\tconst metadataMap = getSettledValue(metadataMapResult) ?? new Map<string, BranchMetadata>();\n\t\t\t\tconst defaultWorktreePath = getSettledValue(defaultWorktreePathResult);\n\t\t\t\tconst worktreePathSupported = supported.includes('git:for-each-ref:worktreePath');\n\n\t\t\t\t// If we don't get any data, assume the repo doesn't have any commits yet so check if we have a current branch\n\t\t\t\tif (!records.length) {\n\t\t\t\t\t// Never CACHE that conclusion. `getRefs` reports a failed enumeration the same way as a\n\t\t\t\t\t// genuinely ref-less repo — an empty array (it invalidates its own entry but doesn't\n\t\t\t\t\t// throw) — so a transient `for-each-ref` failure would otherwise pin this degraded\n\t\t\t\t\t// current-branch-only list in a map with no TTL, and every branch consumer would see a\n\t\t\t\t\t// one-branch repo for the session. A truly empty repo re-reads cheaply, so refusing the\n\t\t\t\t\t// entry costs nothing in the case this is actually meant to serve.\n\t\t\t\t\tcacheable?.invalidate();\n\n\t\t\t\t\tconst current = await this.getCurrentBranch(\n\t\t\t\t\t\tcommonPath,\n\t\t\t\t\t\tmetadataMap,\n\t\t\t\t\t\toptions?.ordering ?? this.context.config?.commits.ordering ?? undefined,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t);\n\t\t\t\t\treturn current != null ? { values: [current] } : emptyPagedResult;\n\t\t\t\t}\n\n\t\t\t\tusing sw = maybeStopWatch(scope, { log: { onlyExit: true, level: 'debug' } });\n\n\t\t\t\tconst branches: GitBranch[] = [];\n\n\t\t\t\tfor (const record of records) {\n\t\t\t\t\tconst fullName = record.name;\n\t\t\t\t\t// Filter to branches and remote-tracking branches; skip tags from the unified records.\n\t\t\t\t\tif (!fullName.startsWith('refs/heads/') && !fullName.startsWith('refs/remotes/')) continue;\n\t\t\t\t\t// Skip HEAD refs in remote branches\n\t\t\t\t\tif (isRemoteHEAD(fullName)) continue;\n\n\t\t\t\t\tconst upstream = parseUpstream(record.upstream, record.upstreamTracking);\n\n\t\t\t\t\tconst metadata = metadataMap.get(parseRefName(fullName).name);\n\t\t\t\t\tconst worktreePath = record.worktreePath ? normalizePath(record.worktreePath) : undefined;\n\n\t\t\t\t\tbranches.push(\n\t\t\t\t\t\tnew GitBranch(\n\t\t\t\t\t\t\tcommonPath,\n\t\t\t\t\t\t\tfullName,\n\t\t\t\t\t\t\tfalse, // Don't trust %(HEAD) for current as it's per-worktree -- we will set it later\n\t\t\t\t\t\t\trecord.committerDate ? new Date(record.committerDate) : undefined,\n\t\t\t\t\t\t\tmetadata,\n\t\t\t\t\t\t\trecord.objectname,\n\t\t\t\t\t\t\tupstream,\n\t\t\t\t\t\t\tworktreePathSupported\n\t\t\t\t\t\t\t\t? worktreePath\n\t\t\t\t\t\t\t\t\t? { path: worktreePath, isDefault: worktreePath === defaultWorktreePath }\n\t\t\t\t\t\t\t\t\t: false\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tsw?.stop({ suffix: ` parsed ${branches.length} branches` });\n\n\t\t\t\t// Pre-populate current branch cache for worktrees based on worktreePath info\n\t\t\t\t// This eliminates the need for rev-parse calls during branch reconstruction\n\t\t\t\tfor (const branch of branches) {\n\t\t\t\t\t// oxlint-disable-next-line typescript/prefer-optional-chain\n\t\t\t\t\tif (branch.worktree && branch.worktree.path) {\n\t\t\t\t\t\tconst { name } = parseRefName(branch.refName);\n\t\t\t\t\t\tconst reference = createReference(name, branch.worktree.path, {\n\t\t\t\t\t\t\trefType: 'branch',\n\t\t\t\t\t\t\tname: name,\n\t\t\t\t\t\t\tid: getBranchId(branch.worktree.path, false, name),\n\t\t\t\t\t\t\tremote: false,\n\t\t\t\t\t\t\tupstream: branch.upstream?.name\n\t\t\t\t\t\t\t\t? { name: branch.upstream.name, missing: branch.upstream.missing }\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\tsha: branch.sha,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.cache.setCurrentBranchReferenceIfAbsent(branch.worktree.path, reference);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn branches.length ? { values: branches } : emptyPagedResult;\n\t\t\t} catch (ex) {\n\t\t\t\t// Signal cache invalidation so the shared cache entry is cleaned up\n\t\t\t\tcacheable?.invalidate();\n\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\treturn emptyPagedResult;\n\t\t\t}\n\t\t};\n\n\t\t// Mapper function that adjusts branches for a specific worktree\n\t\tconst mapBranches = async (\n\t\t\tshared: PagedResult<GitBranch>,\n\t\t\ttargetRepoPath: string,\n\t\t\tcommonPath: string,\n\t\t\tmapperSignal?: AbortSignal,\n\t\t): Promise<PagedResult<GitBranch>> => {\n\t\t\tif (!shared.values.length) return shared;\n\n\t\t\t// Prefer the mapper's per-entry aggregate signal when present; fall back to the\n\t\t\t// caller's own cancellation when bypassing the cache (paging-cursor path).\n\t\t\tmapperSignal ??= cancellation;\n\n\t\t\t// Get current branch info and default worktree path for the target worktree\n\t\t\tconst [currentRefResult, defaultWorktreePathResult] = await Promise.allSettled([\n\t\t\t\tthis.getCurrentBranchReferenceCore(targetRepoPath, undefined, mapperSignal),\n\t\t\t\tthis.provider.config.getDefaultWorktreePath?.(commonPath),\n\t\t\t]);\n\t\t\tconst currentRef = getSettledValue(currentRefResult);\n\t\t\tconst defaultWorktreePath = getSettledValue(defaultWorktreePathResult);\n\t\t\tconst isDetached = currentRef != null && isDetachedHead(currentRef.name);\n\n\t\t\t// Clone branches with correct repoPath and current flag\n\t\t\tconst branches: GitBranch[] = shared.values.map(b => {\n\t\t\t\t// Check if this branch is current in the target worktree\n\t\t\t\tconst isCurrent = !b.remote && b.name === currentRef?.name && !isDetached;\n\n\t\t\t\t// Only create new object if something changed\n\t\t\t\tif (!isCurrent && targetRepoPath === commonPath) return b;\n\n\t\t\t\treturn new GitBranch(\n\t\t\t\t\ttargetRepoPath, // Use target worktree path\n\t\t\t\t\tb.refName,\n\t\t\t\t\tisCurrent,\n\t\t\t\t\tb.date,\n\t\t\t\t\tb.metadata,\n\t\t\t\t\tb.sha,\n\t\t\t\t\tb.upstream,\n\t\t\t\t\t// For current branch, ensure worktree is set (fallback when git doesn't support worktreePath)\n\t\t\t\t\tisCurrent\n\t\t\t\t\t\t? (b.worktree ?? { path: targetRepoPath, isDefault: targetRepoPath === defaultWorktreePath })\n\t\t\t\t\t\t: b.worktree,\n\t\t\t\t\tfalse, // detached - only true for detached HEAD branch itself\n\t\t\t\t\tfalse, // rebasing - only true for detached HEAD branch in rebase\n\t\t\t\t);\n\t\t\t});\n\n\t\t\t// Handle detached HEAD - need to create a special branch for it\n\t\t\tif (isDetached || (currentRef != null && !branches.some(b => b.current))) {\n\t\t\t\tconst metadataMap = await this.getBranchMetadataMap(commonPath);\n\t\t\t\tconst current = await this.getCurrentBranch(\n\t\t\t\t\ttargetRepoPath,\n\t\t\t\t\tmetadataMap,\n\t\t\t\t\toptions?.ordering ?? this.context.config?.commits.ordering ?? undefined,\n\t\t\t\t\tmapperSignal,\n\t\t\t\t);\n\t\t\t\tif (current != null) {\n\t\t\t\t\t// Replace if exists (by id), otherwise prepend\n\t\t\t\t\tconst index = branches.findIndex(b => b.id === current.id);\n\t\t\t\t\tif (index !== -1) {\n\t\t\t\t\t\tbranches[index] = current;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbranches.unshift(current);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { ...shared, values: branches };\n\t\t};\n\n\t\tlet result: PagedResult<GitBranch>;\n\n\t\t// Use paging cursor to bypass cache if paginating\n\t\tif (options?.paging?.cursor != null) {\n\t\t\tconst commonPath = this.cache.getCommonPath(repoPath);\n\t\t\tconst shared = await getCore(commonPath);\n\t\t\t// Still apply the mapper to ensure correct repoPath and current flag for the requesting worktree\n\t\t\tresult = await mapBranches(shared, repoPath, commonPath);\n\t\t} else {\n\t\t\tresult = await this.cache.getBranches(repoPath, getCore, mapBranches, cancellation);\n\t\t}\n\n\t\tif (options?.filter != null) {\n\t\t\tresult = {\n\t\t\t\t...result,\n\t\t\t\tvalues: result.values.filter(options.filter),\n\t\t\t};\n\t\t}\n\n\t\tif (options?.sort) {\n\t\t\tsortBranches(result.values, typeof options.sort === 'boolean' ? undefined : options.sort);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t@debug()\n\tasync getBranchContributionsOverview(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: {\n\t\t\tassociatedPullRequest?: Promise<\n\t\t\t\t{ refs?: { base?: { branch: string } }; stack?: { position: number } } | undefined\n\t\t\t>;\n\t\t\tpriority?: GitCommandPriority;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<BranchContributionsOverview | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst priority = options?.priority;\n\t\tconst priorityOpts = priority != null ? { priority: priority } : undefined;\n\n\t\t// Expensive body — runs only on cache miss. Closes over `mergeTarget` so the cache key\n\t\t// (`${ref}|${mergeTarget}`) fully captures every input that affects the result.\n\t\tconst fetchBody = async (\n\t\t\tmergeTarget: string,\n\t\t\tsignal: AbortSignal | undefined,\n\t\t): Promise<BranchContributionsOverview | undefined> => {\n\t\t\tconst mergeBase = await this.provider.refs.getMergeBase(repoPath, ref, mergeTarget, priorityOpts, signal);\n\t\t\tif (mergeBase == null) return undefined;\n\n\t\t\t// Fetch the merge-base commit's dates in parallel with contributors so consumers\n\t\t\t// (e.g. the graph minimap scope window) don't pay a separate round-trip for them.\n\t\t\t// `allSettled` so a transient failure in one side doesn't drop the overview entirely.\n\t\t\tconst [contributorsSettled, mergeBaseDatesSettled] = await Promise.allSettled([\n\t\t\t\tthis.provider.contributors.getContributors(\n\t\t\t\t\trepoPath,\n\t\t\t\t\tcreateRevisionRange(mergeBase, ref, '..'),\n\t\t\t\t\t{ stats: true },\n\t\t\t\t\tsignal,\n\t\t\t\t),\n\t\t\t\tthis.provider.commits.getCommitDates(repoPath, mergeBase, signal),\n\t\t\t]);\n\n\t\t\tif (signal?.aborted) throw new CancellationError();\n\n\t\t\tconst result = getSettledValue(contributorsSettled) ?? { contributors: [] };\n\t\t\tconst mergeBaseDates = getSettledValue(mergeBaseDatesSettled);\n\n\t\t\tsortContributors(result.contributors, { orderBy: 'score:desc' });\n\n\t\t\tlet totalCommits = 0;\n\t\t\tlet totalFiles = 0;\n\t\t\tlet totalAdditions = 0;\n\t\t\tlet totalDeletions = 0;\n\t\t\tlet firstCommitTimestamp;\n\t\t\tlet latestCommitTimestamp;\n\n\t\t\tfor (const c of result.contributors) {\n\t\t\t\ttotalCommits += c.contributionCount;\n\t\t\t\ttotalFiles += c.stats?.files ?? 0;\n\t\t\t\ttotalAdditions += c.stats?.additions ?? 0;\n\t\t\t\ttotalDeletions += c.stats?.deletions ?? 0;\n\n\t\t\t\tconst firstTimestamp = c.firstCommitDate?.getTime();\n\t\t\t\tconst latestTimestamp = c.latestCommitDate?.getTime();\n\n\t\t\t\tif (firstTimestamp != null || latestTimestamp != null) {\n\t\t\t\t\tfirstCommitTimestamp =\n\t\t\t\t\t\tfirstCommitTimestamp != null\n\t\t\t\t\t\t\t? Math.min(firstCommitTimestamp, firstTimestamp ?? Infinity, latestTimestamp ?? Infinity)\n\t\t\t\t\t\t\t: (firstTimestamp ?? latestTimestamp);\n\n\t\t\t\t\tlatestCommitTimestamp =\n\t\t\t\t\t\tlatestCommitTimestamp != null\n\t\t\t\t\t\t\t? Math.max(latestCommitTimestamp, firstTimestamp ?? -Infinity, latestTimestamp ?? -Infinity)\n\t\t\t\t\t\t\t: (latestTimestamp ?? firstTimestamp);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\trepoPath: repoPath,\n\t\t\t\tbranch: ref,\n\t\t\t\tmergeTarget: mergeTarget,\n\t\t\t\tmergeBase: mergeBase,\n\t\t\t\tmergeBaseDate: mergeBaseDates?.committerDate,\n\n\t\t\t\tcommits: totalCommits,\n\t\t\t\tfiles: totalFiles,\n\t\t\t\tadditions: totalAdditions,\n\t\t\t\tdeletions: totalDeletions,\n\n\t\t\t\tlatestCommitDate: latestCommitTimestamp != null ? new Date(latestCommitTimestamp) : undefined,\n\t\t\t\tfirstCommitDate: firstCommitTimestamp != null ? new Date(firstCommitTimestamp) : undefined,\n\n\t\t\t\tcontributors: result.contributors,\n\t\t\t};\n\t\t};\n\n\t\ttry {\n\t\t\t// Resolve `mergeTarget` through Tier 1 → Tier 2 → Tier 3. The pieces of each tier are\n\t\t\t// already individually cached (`getStoredMergeTargetBranchName`, `getBaseBranchName`,\n\t\t\t// `getDefaultBranchName`), so this resolution path is cheap on warm caches. Only the\n\t\t\t// expensive body below (`getMergeBase` + `getContributors` w/ stats + `getCommitDates`)\n\t\t\t// is wrapped by `cache.getBranchOverview`, keyed on the resolved `mergeTarget` so any\n\t\t\t// caller that resolves to the same target shares; differing targets get independent\n\t\t\t// slots, which is the correctness constraint that previously forced the Tier 2/3 paths\n\t\t\t// to bypass the cache entirely.\n\t\t\tlet mergeTarget: string | undefined;\n\n\t\t\t// Tier 1: Stored merge target (user-set or previously detected from PR). A target whose\n\t\t\t// branch is gone is skipped, so resolution falls through to the next tier.\n\t\t\tmergeTarget = await this.getStoredMergeTargetBranchName(repoPath, ref, priorityOpts, cancellation);\n\n\t\t\t// Tier 2: PR-based lookup. The branch object is only needed here (for `remoteName`),\n\t\t\t// so lazy-load it on the cold path instead of paying for it on every call.\n\t\t\tif (mergeTarget == null && options?.associatedPullRequest != null) {\n\t\t\t\tconst pr = await options.associatedPullRequest;\n\t\t\t\tif (pr?.refs?.base != null) {\n\t\t\t\t\tconst branch = await this.getBranch(repoPath, ref, undefined, cancellation);\n\t\t\t\t\tif (branch == null) return undefined;\n\n\t\t\t\t\tconst prTarget = `${branch.remoteName}/${pr.refs.base.branch}`;\n\t\t\t\t\t// A PR's base can be gone too (e.g. a stale PR read still naming a merged stack layer),\n\t\t\t\t\t// so a confirmed-gone base is skipped like a stored target.\n\t\t\t\t\tconst { missing } = await this.provider.refs.getSymbolicReferenceNameOrMissing(\n\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\tprTarget,\n\t\t\t\t\t\tpriorityOpts,\n\t\t\t\t\t\tcancellation,\n\t\t\t\t\t);\n\t\t\t\t\tif (!missing) {\n\t\t\t\t\t\tmergeTarget = prTarget;\n\n\t\t\t\t\t\t// A stacked PR's base is the layer below it, which is deleted when the stack merges.\n\t\t\t\t\t\t// A stored target beats every other tier for as long as its branch exists, and a merged\n\t\t\t\t\t\t// layer's branch can linger (an unpruned remote-tracking ref, or a repo that keeps merged\n\t\t\t\t\t\t// branches). Use it for this lookup, but don't persist it.\n\t\t\t\t\t\tif (pr.stack == null) {\n\t\t\t\t\t\t\t// Store for future reuse — turns the next call into a Tier 1 path. Skip the\n\t\t\t\t\t\t\t// `branchOverviews` invalidation that the write would otherwise trigger: we're\n\t\t\t\t\t\t\t// about to populate `${ref}|${mergeTarget}` with this exact target, so evicting\n\t\t\t\t\t\t\t// it would just force the next caller to redo the body. (gk-merge-target writes\n\t\t\t\t\t\t\t// do not affect `baseBranchName`, so no need to skip that target.)\n\t\t\t\t\t\t\tvoid this.storeMergeTargetBranchName(repoPath, ref, prTarget, {\n\t\t\t\t\t\t\t\tskipInvalidation: ['branchOverviews'],\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Tier 3: Base branch, then default branch.\n\t\t\tmergeTarget ??= await this.getBaseBranchName(repoPath, ref, priorityOpts, cancellation);\n\t\t\tmergeTarget ??= await this.getDefaultBranchName(repoPath, undefined, priorityOpts, cancellation);\n\n\t\t\tif (mergeTarget == null) return undefined;\n\n\t\t\tconst resolvedTarget = mergeTarget;\n\t\t\treturn await this.cache.getBranchOverview(\n\t\t\t\trepoPath,\n\t\t\t\t`${ref}|${resolvedTarget}`,\n\t\t\t\t(_commonPath, _cacheable, signal) => fetchBody(resolvedTarget, signal ?? cancellation),\n\t\t\t\t{ cancellation: cancellation },\n\t\t\t);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@debug()\n\tasync getBranchesWithCommits(\n\t\trepoPath: string,\n\t\tcommits: string[],\n\t\tbranch?: string,\n\t\toptions?:\n\t\t\t| { all?: boolean; commitDate?: Date; mode?: 'contains' | 'pointsAt' }\n\t\t\t| { commitDate?: Date; mode?: 'contains' | 'pointsAt'; remotes?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<string[]> {\n\t\tif (branch != null) {\n\t\t\tconst result = await this.branchesContainingCore(\n\t\t\t\trepoPath,\n\t\t\t\tcommits,\n\t\t\t\t{ mode: 'contains', name: branch },\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst data = result.stdout.trim();\n\t\t\treturn data ? [data] : [];\n\t\t}\n\n\t\tconst result = await this.branchesContainingCore(repoPath, commits, options, cancellation);\n\t\tif (!result.stdout) return [];\n\n\t\treturn filterMap(result.stdout.split('\\n'), b => b.trim() || undefined);\n\t}\n\n\tprivate async branchesContainingCore(\n\t\trepoPath: string,\n\t\trefs: string[],\n\t\toptions?: {\n\t\t\tall?: boolean;\n\t\t\tmode?: 'contains' | 'pointsAt';\n\t\t\tname?: string;\n\t\t\tremotes?: boolean;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitResult> {\n\t\tconst params: string[] = ['branch'];\n\t\tif (options?.all) {\n\t\t\tparams.push('-a');\n\t\t} else if (options?.remotes) {\n\t\t\tparams.push('-r');\n\t\t}\n\n\t\tparams.push('--format=%(refname:short)');\n\n\t\tfor (const ref of refs) {\n\t\t\tparams.push(options?.mode === 'pointsAt' ? `--points-at=${ref}` : `--contains=${ref}`);\n\t\t}\n\n\t\tif (options?.name != null) {\n\t\t\tparams.push(options.name);\n\t\t}\n\n\t\treturn this.git.run(\n\t\t\t{\n\t\t\t\tcwd: repoPath,\n\t\t\t\tcancellation: cancellation,\n\t\t\t\tconfigs: gitConfigsBranch,\n\t\t\t\terrors: 'ignore',\n\t\t\t},\n\t\t\t...params,\n\t\t);\n\t}\n\n\t@debug()\n\tasync getCurrentBranchReference(\n\t\trepoPath: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranchReference | undefined> {\n\t\tlet ref = await this.getCurrentBranchReferenceCore(repoPath, undefined, cancellation);\n\t\tif (ref != null && isDetachedHead(ref.name)) {\n\t\t\tref = createReference(ref.sha!, repoPath, {\n\t\t\t\trefType: 'branch',\n\t\t\t\tname: formatDetachedHeadName(ref.sha!),\n\t\t\t\tid: getBranchId(repoPath, ref.remote, ref.sha!),\n\t\t\t\tremote: ref.remote,\n\t\t\t\tupstream: ref.upstream,\n\t\t\t\tsha: ref.sha,\n\t\t\t});\n\t\t}\n\t\treturn ref;\n\t}\n\n\tprivate getCurrentBranchReferenceCore(\n\t\trepoPath: string,\n\t\tordering?: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranchReference | undefined> {\n\t\treturn this.cache.currentBranchReference.getOrCreate(\n\t\t\trepoPath,\n\t\t\tasync (_cacheable, signal) => {\n\t\t\t\tconst commitOrdering = ordering;\n\n\t\t\t\tlet data: [string, string | undefined] | undefined;\n\t\t\t\tlet result;\n\t\t\t\ttry {\n\t\t\t\t\tresult = await this.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, cancellation: signal, errors: 'throw' },\n\t\t\t\t\t\t'rev-parse',\n\t\t\t\t\t\t'--abbrev-ref',\n\t\t\t\t\t\t'--symbolic-full-name',\n\t\t\t\t\t\t'@',\n\t\t\t\t\t\t'@{u}',\n\t\t\t\t\t\t'--',\n\t\t\t\t\t);\n\t\t\t\t\tdata = [result.stdout, undefined];\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\t\tconst msg: string = ex?.toString() ?? '';\n\t\t\t\t\tif (GitErrors.badRevision.test(msg) || GitWarnings.noUpstream.test(msg)) {\n\t\t\t\t\t\tif (ex.stdout != null && ex.stdout.length !== 0) {\n\t\t\t\t\t\t\tdata = [ex.stdout, undefined];\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tresult = await this.git.run(\n\t\t\t\t\t\t\t\t\t{ cwd: repoPath, cancellation: signal },\n\t\t\t\t\t\t\t\t\t'symbolic-ref',\n\t\t\t\t\t\t\t\t\t'--short',\n\t\t\t\t\t\t\t\t\t'HEAD',\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (result.stdout) {\n\t\t\t\t\t\t\t\t\tdata = [result.stdout.trim(), undefined];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (data == null) {\n\t\t\t\t\t\t\t\tconst symbolicRef = await this.getDefaultBranchName(\n\t\t\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\t\t\t'origin',\n\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (symbolicRef != null) {\n\t\t\t\t\t\t\t\t\tdata = [\n\t\t\t\t\t\t\t\t\t\tsymbolicRef.startsWith('origin/')\n\t\t\t\t\t\t\t\t\t\t\t? symbolicRef.substring('origin/'.length)\n\t\t\t\t\t\t\t\t\t\t\t: symbolicRef,\n\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (data == null) {\n\t\t\t\t\t\t\t\tconst defaultBranch =\n\t\t\t\t\t\t\t\t\t(await this.provider.config.getConfig(repoPath, 'init.defaultBranch')) ?? 'main';\n\t\t\t\t\t\t\t\tconst configMap = await this.provider.config.getConfigRegex(\n\t\t\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\t\t\t`branch\\\\.${defaultBranch}\\\\.+`,\n\t\t\t\t\t\t\t\t\t{ runGitLocally: true },\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tconst remote = configMap.get(`branch.${defaultBranch}.remote`);\n\t\t\t\t\t\t\t\tconst merge = configMap.get(`branch.${defaultBranch}.merge`);\n\t\t\t\t\t\t\t\tconst remoteBranch = merge?.startsWith('refs/heads/')\n\t\t\t\t\t\t\t\t\t? merge.substring('refs/heads/'.length)\n\t\t\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\t\t\t\tdata = [\n\t\t\t\t\t\t\t\t\t`${defaultBranch}${remote && remoteBranch ? `\\n${remote}/${remoteBranch}` : ''}`,\n\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (GitWarnings.headNotABranch.test(msg)) {\n\t\t\t\t\t\tresult = await this.git.run(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcwd: repoPath,\n\t\t\t\t\t\t\t\tcancellation: signal,\n\t\t\t\t\t\t\t\tconfigs: gitConfigsLog,\n\t\t\t\t\t\t\t\terrors: 'ignore',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'log',\n\t\t\t\t\t\t\t'-n1',\n\t\t\t\t\t\t\t'--format=%H',\n\t\t\t\t\t\t\tcommitOrdering ? `--${commitOrdering}-order` : undefined,\n\t\t\t\t\t\t\t'--',\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif (result.completion.status === 'cancelled' || signal?.aborted) {\n\t\t\t\t\t\t\tthrow new CancellationError();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst sha = result.stdout.trim();\n\t\t\t\t\t\tif (sha) {\n\t\t\t\t\t\t\tdata = [`(HEAD detached at ${shortenRevision(sha)})`, sha];\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tLogger.warn(`[${repoPath}] Unable to get current branch: ${ex}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (data == null) return undefined;\n\n\t\t\t\tconst [name, upstream] = data[0].split('\\n');\n\n\t\t\t\treturn createReference(name, repoPath, {\n\t\t\t\t\trefType: 'branch',\n\t\t\t\t\tname: name,\n\t\t\t\t\tid: getBranchId(repoPath, false, name),\n\t\t\t\t\tremote: false,\n\t\t\t\t\tupstream: upstream ? { name: upstream, missing: false } : undefined,\n\t\t\t\t\tsha: data[1],\n\t\t\t\t});\n\t\t\t},\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\t@debug({ exit: true })\n\tasync getDefaultBranchName(\n\t\trepoPath: string | undefined,\n\t\tremote?: string,\n\t\toptions?: { priority?: GitCommandPriority; local?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<string | undefined> {\n\t\tif (repoPath == null) return undefined;\n\n\t\tremote ??= 'origin';\n\t\tconst priority = options?.priority;\n\t\tconst priorityOpts = priority != null ? { priority: priority } : undefined;\n\n\t\t// Local-only: read just the existing local symref, never contacting the remote. Cached under a\n\t\t// `${remote}:local` key — a colon can't appear in a refname component, so it can never collide\n\t\t// with a real remote name used by the networked variant below. Invalidated by the same\n\t\t// remotes/branches cache cascades as the networked lookup.\n\t\tif (options?.local) {\n\t\t\treturn this.cache.getDefaultBranchName(\n\t\t\t\trepoPath,\n\t\t\t\t`${remote}:local`,\n\t\t\t\tasync (commonPath, cacheable, signal) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Bind to the aggregate `signal` (fires only when ALL current callers abort), not\n\t\t\t\t\t\t// this-caller's `cancellation` — otherwise a superseded caller's abort would kill the\n\t\t\t\t\t\t// shared command and reject concurrent riders that never cancelled.\n\t\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t\t{ cwd: commonPath, cancellation: signal ?? cancellation, ...priorityOpts },\n\t\t\t\t\t\t\t'symbolic-ref',\n\t\t\t\t\t\t\t'--short',\n\t\t\t\t\t\t\t`refs/remotes/${remote}/HEAD`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn result.stdout.trim() || undefined;\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\t\t\t// `symbolic-ref` on an absent `refs/remotes/<remote>/HEAD` exits fatal rather than\n\t\t\t\t\t\t// empty, and that message matches no `GitWarnings` entry, so it arrives here as a\n\t\t\t\t\t\t// throw. It is still an ANSWER — the ref genuinely isn't set — and the overwhelmingly\n\t\t\t\t\t\t// common one, so cache it. Invalidating instead means every caller re-probes and the\n\t\t\t\t\t\t// whole point of caching this lookup is lost.\n\t\t\t\t\t\tconst stderr = (ex as { stderr?: string }).stderr ?? '';\n\t\t\t\t\t\tif (stderr.includes('is not a symbolic ref')) return undefined;\n\n\t\t\t\t\t\t// Anything else never produced an answer (spawn failure, queue rejection). This entry\n\t\t\t\t\t\t// has no TTL, so caching that would pin \"no default branch\" for the session.\n\t\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t}\n\n\t\treturn this.cache.getDefaultBranchName(\n\t\t\trepoPath,\n\t\t\tremote,\n\t\t\tasync (commonPath, cacheable, signal) => {\n\t\t\t\tlet retried = false;\n\t\t\t\twhile (true) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t\t{ cwd: commonPath, cancellation: signal ?? cancellation, ...priorityOpts },\n\t\t\t\t\t\t\t'symbolic-ref',\n\t\t\t\t\t\t\t'--short',\n\t\t\t\t\t\t\t`refs/remotes/${remote}/HEAD`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn result.stdout.trim() || undefined;\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\t// Only \"no HEAD ref configured\" is an ANSWER here; every other throw means the lookup\n\t\t\t\t\t\t// never happened. This entry has no TTL, so caching a failure — an offline `ls-remote`\n\t\t\t\t\t\t// being the likely one — would pin \"no default branch\" for the session.\n\t\t\t\t\t\tlet answered = false;\n\t\t\t\t\t\tif (/is not a symbolic ref/.test(ex.stderr)) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tif (!retried) {\n\t\t\t\t\t\t\t\t\tretried = true;\n\t\t\t\t\t\t\t\t\tawait this.git.run(\n\t\t\t\t\t\t\t\t\t\t{ cwd: commonPath, cancellation: signal ?? cancellation, ...priorityOpts },\n\t\t\t\t\t\t\t\t\t\t'remote',\n\t\t\t\t\t\t\t\t\t\t'set-head',\n\t\t\t\t\t\t\t\t\t\t'-a',\n\t\t\t\t\t\t\t\t\t\tremote,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t// This just created `refs/remotes/<remote>/HEAD`, which the `local` variant\n\t\t\t\t\t\t\t\t\t// may already have cached a miss for. The watcher would also catch the new\n\t\t\t\t\t\t\t\t\t// ref, but evict directly so consumers of this package that don't wire up a\n\t\t\t\t\t\t\t\t\t// watcher aren't stuck with that miss.\n\t\t\t\t\t\t\t\t\tthis.cache.deleteDefaultBranchName(commonPath, `${remote}:local`);\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t\t\t\t{ cwd: commonPath, cancellation: signal ?? cancellation, ...priorityOpts },\n\t\t\t\t\t\t\t\t\t'ls-remote',\n\t\t\t\t\t\t\t\t\t'--symref',\n\t\t\t\t\t\t\t\t\tremote,\n\t\t\t\t\t\t\t\t\t'HEAD',\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (result.stdout) {\n\t\t\t\t\t\t\t\t\tconst match = /ref:\\s(\\S+)\\s+HEAD/m.exec(result.stdout);\n\t\t\t\t\t\t\t\t\tif (match != null) {\n\t\t\t\t\t\t\t\t\t\tconst [, branch] = match;\n\t\t\t\t\t\t\t\t\t\treturn `${remote}/${branch.substring('refs/heads/'.length).trim()}`;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// `ls-remote` ran and the remote advertised no HEAD — a real \"none\".\n\t\t\t\t\t\t\t\tanswered = true;\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!answered) {\n\t\t\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\t/**\n\t * Writes the missing `refs/remotes/<remote>/HEAD` symref from the remote (`remote set-head -a`) in the background,\n\t * never prompting for credentials; nothing runs past the cached local check when the symref exists. Rejects when\n\t * the remote can't be read.\n\t */\n\t@debug()\n\tasync setRemoteHeadIfMissing(repoPath: string, remote: string): Promise<void> {\n\t\tif ((await this.getDefaultBranchName(repoPath, remote, { priority: 'background', local: true })) != null) {\n\t\t\treturn;\n\t\t}\n\n\t\tawait this.git.run(\n\t\t\t{ cwd: repoPath, priority: 'background', ...nonInteractiveNetworkOptions },\n\t\t\t'remote',\n\t\t\t'set-head',\n\t\t\t'-a',\n\t\t\tremote,\n\t\t);\n\t\t// The `local` lookup above cached the miss; a host without a ref watcher would otherwise keep it\n\t\tthis.cache.deleteDefaultBranchName(repoPath, `${remote}:local`);\n\t}\n\n\t@debug()\n\tasync createBranch(repoPath: string, name: string, ref: string, options?: { noTracking?: boolean }): Promise<void> {\n\t\tconst args = ['branch', name, ref];\n\t\tif (options?.noTracking) {\n\t\t\targs.push('--no-track');\n\t\t}\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t\t// Evict the cached base so the new branch re-derives its own. The PERSISTED `branch.<ref>.gk-*`\n\t\t\t// keys are left alone: they're dropped when GitLens deletes a branch, never when one is created.\n\t\t\t// Removing them here would mean treating a reused name as proof of a different branch, which\n\t\t\t// nothing can establish — so the trade is that a branch reusing a name deleted outside GitLens\n\t\t\t// inherits the orphaned section.\n\t\t\tthis.cache.deleteBaseBranchName(repoPath, name);\n\t\t\t// Unlike the gk keys, the reflog is the new branch's own: a name deleted outside GitLens left its\n\t\t\t// predecessor's start point cached\n\t\t\tthis.forgetBranchCreatedFrom(repoPath, name);\n\t\t} catch (ex) {\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'branch',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew BranchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\taction: 'create',\n\t\t\t\t\t\t\tbranch: name,\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,\n\t\t\t\t\t),\n\t\t\t);\n\t\t} finally {\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\tmayWriteTracking(ref, options?.noTracking) ? ['config', 'heads'] : ['heads'],\n\t\t\t);\n\t\t}\n\t}\n\n\t@debug()\n\tasync deleteLocalBranch(repoPath: string, names: string | string[], options?: { force?: boolean }): Promise<void> {\n\t\tconst branches = ensureArray(names);\n\t\tconst args = ['branch', options?.force ? '-D' : '-d', ...branches];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t\tfor (const branch of branches) {\n\t\t\t\tawait this.forgetDeletedBranch(repoPath, branch);\n\t\t\t}\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['config', 'heads']);\n\t\t} catch (ex) {\n\t\t\t// A multi-name delete partially succeeds: `git branch -d a bad c` removes `a` and `c`, refuses\n\t\t\t// `bad`, and still exits non-zero — so the loop above never ran for the branches that did go.\n\t\t\t// Clean those up here rather than leave persisted gk metadata behind for a name a later branch\n\t\t\t// can reuse.\n\t\t\tconst anyDeleted = await this.cleanupDeletedBranchMetadata(repoPath, branches);\n\n\t\t\t// The success path's notifications never ran, but some branches DID go — without these the\n\t\t\t// branch caches stay stale and consumers wait on the filesystem watcher (which never fires\n\t\t\t// for a packed ref).\n\t\t\tif (anyDeleted) {\n\t\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['config', 'heads']);\n\t\t\t}\n\n\t\t\tif (ex instanceof BranchError) {\n\t\t\t\tthrow ex.update({\n\t\t\t\t\taction: options?.force ? 'force delete' : 'delete',\n\t\t\t\t\tbranch: branches.join(', '),\n\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Classify the failure (e.g. not fully merged) so consumers like the delete wizard can offer a\n\t\t\t// force retry — without this the reason would be undefined and every failure reads as 'other'.\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'branch',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew BranchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\taction: options?.force ? 'force delete' : 'delete',\n\t\t\t\t\t\t\tbranch: branches.join(', '),\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,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Drops what GitLens keeps for a local branch beyond its ref, for both ways one is deleted\n\t * (`deleteLocalBranch` and `refs.deleteReference`). The persisted gk metadata goes too, not just the\n\t * cached resolution: `getBaseBranchName` reads `branch.<ref>.gk-merge-base` before falling back to the\n\t * reflog, so leaving it behind would hand a later branch reusing this name its predecessor's base.\n\t */\n\tasync forgetDeletedBranch(repoPath: string, name: string): Promise<void> {\n\t\tthis.cache.deleteBaseBranchName(repoPath, name);\n\t\tawait this.provider.config.removeGkConfigBranchSection(repoPath, name);\n\t\tthis.clearBranchActivityStamps(repoPath, name);\n\t\tthis.forgetBranchCreatedFrom(repoPath, name);\n\t}\n\n\t/**\n\t * Drops the cached and persisted per-branch metadata for whichever of `names` no longer exists. Only\n\t * for the partial-failure path — one extra `for-each-ref` is cheap while already handling an error,\n\t * and keeps the success path free of it.\n\t *\n\t * Returns whether any of `names` is confirmed gone; `false` when the probe couldn't answer, so a\n\t * spurious notification is never fired on an unrelated failure.\n\t */\n\tprivate async cleanupDeletedBranchMetadata(repoPath: string, names: string[]): Promise<boolean> {\n\t\ttry {\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, errors: 'ignore' },\n\t\t\t\t'for-each-ref',\n\t\t\t\t// Full refname, stripped here rather than by git. NOT `%(refname:short)`: that yields the\n\t\t\t\t// shortest UNAMBIGUOUS name, so a branch with a same-named tag comes back as `heads/<name>`,\n\t\t\t\t// never matches the requested name, and would read as deleted — wiping a live branch's\n\t\t\t\t// metadata. `%(refname:strip=2)` also solves that, but `%(refname)` is the oldest, plainest\n\t\t\t\t// field and needs no assumption about which git version gained `strip`.\n\t\t\t\t'--format=%(refname)',\n\t\t\t\t...names.map(n => `refs/heads/${n}`),\n\t\t\t);\n\t\t\t// `errors: 'ignore'` means a failed probe RESOLVES empty, which is indistinguishable from \"none\n\t\t\t// of them survived\" — and would delete every name's metadata, including user-owned keys like\n\t\t\t// `gk-disposition` and `gk-associated-issues`. Only act on a genuine answer.\n\t\t\t//\n\t\t\t// BOTH conditions: `exitCode !== 0` catches a probe git ran and rejected, `status !== 'exited'`\n\t\t\t// catches one that never produced an answer — a spawn failure or queue rejection (no exit code at\n\t\t\t// all), or a swallowed warning (which carries git's real code, so the exit-code test alone can\n\t\t\t// still read it as \"none survived\").\n\t\t\tif (result.completion.status !== 'exited' || result.exitCode !== 0) return false;\n\n\t\t\tconst prefix = 'refs/heads/';\n\t\t\tconst surviving = new Set(\n\t\t\t\tresult.stdout\n\t\t\t\t\t.split('\\n')\n\t\t\t\t\t.map(l => l.trim())\n\t\t\t\t\t.filter(l => l.startsWith(prefix))\n\t\t\t\t\t.map(l => l.substring(prefix.length)),\n\t\t\t);\n\n\t\t\tlet anyDeleted = false;\n\t\t\tfor (const name of names) {\n\t\t\t\tif (surviving.has(name)) continue;\n\n\t\t\t\tanyDeleted = true;\n\t\t\t\tawait this.forgetDeletedBranch(repoPath, name);\n\t\t\t}\n\n\t\t\treturn anyDeleted;\n\t\t} catch {\n\t\t\t// Best-effort bookkeeping while already unwinding a failure — never mask the original error.\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t@debug()\n\tasync deleteRemoteBranch(repoPath: string, names: string | string[], remote: string): Promise<void> {\n\t\tconst branches = ensureArray(names);\n\t\tconst args = ['push', '-d', remote, ...branches];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof BranchError) {\n\t\t\t\tthrow ex.update({\n\t\t\t\t\taction: 'delete',\n\t\t\t\t\tbranch: branches.join(', '),\n\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Classify against the underlying `git push -d` failure modes; map the \"remote ref does not\n\t\t\t// exist\" case onto BranchError's noRemoteReference so consumers get an actionable reason.\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'push',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew BranchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason === 'rejectedRefDoesNotExist' ? 'noRemoteReference' : 'other',\n\t\t\t\t\t\t\taction: 'delete',\n\t\t\t\t\t\t\tbranch: branches.join(', '),\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,\n\t\t\t\t\t),\n\t\t\t);\n\t\t} finally {\n\t\t\t// A rejected push may have deleted some of its refs\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['remotes']);\n\t\t}\n\t}\n\n\t@debug()\n\tasync getBranchMergedStatus(\n\t\trepoPath: string,\n\t\tbranch: GitBranchReference,\n\t\tinto: GitBranchReference,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranchMergedStatus> {\n\t\tif (branch.name === into.name || branch.upstream?.name === into.name) {\n\t\t\treturn { merged: false };\n\t\t}\n\n\t\t// Hoisted so it can feed the cache key below (its tip is a 3rd key input) and the mapper\n\t\t// below reuses it instead of resolving it a second time.\n\t\tconst localInto = into.remote\n\t\t\t? await this.getLocalBranchByUpstream(repoPath, into.name, cancellation)\n\t\t\t: undefined;\n\n\t\t// Cache key omits repoPath so worktrees of the same common repo share the cached answer.\n\t\t// Content-keyed on the involved tip shas (the result is a pure function of them), so tip\n\t\t// movement mints a new key instead of relying on eviction; falls back to the name-only\n\t\t// identity when a sha is missing (defensive — the sole caller always supplies both tips).\n\t\tconst cacheKey =\n\t\t\tbranch.sha != null && into.sha != null\n\t\t\t\t? `${branch.remote ? 'r' : 'l'}:${branch.name}@${branch.sha}|${into.remote ? 'r' : 'l'}:${into.name}@${into.sha}${\n\t\t\t\t\t\tlocalInto?.sha != null ? `|L:${localInto.name}@${localInto.sha}` : ''\n\t\t\t\t\t}`\n\t\t\t\t: `${branch.remote ? 'r' : 'l'}:${branch.name}|${into.remote ? 'r' : 'l'}:${into.name}`;\n\n\t\treturn this.cache.getBranchMergedStatus(\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tasync (commonPath, _cacheable, signal) => {\n\t\t\t\tconst result = await this.getBranchMergedStatusCore(commonPath, branch, into, signal);\n\t\t\t\tif (result.merged) return result;\n\n\t\t\t\t// If there is a local branch and it is not the branch we are checking, check if it has been merged into it\n\t\t\t\tif (localInto != null && localInto.name !== branch.name) {\n\t\t\t\t\t// Skip the second full merge-check cycle when the local branch points at the same commit as the remote —\n\t\t\t\t\t// the merge-base/cherry/diff/apply pipeline would produce the same answer we already got for `into` above\n\t\t\t\t\tif (localInto.sha != null && localInto.sha === into.sha) {\n\t\t\t\t\t\treturn { merged: false };\n\t\t\t\t\t}\n\n\t\t\t\t\tconst result = await this.getBranchMergedStatusCore(commonPath, branch, localInto, signal);\n\t\t\t\t\tif (result.merged) {\n\t\t\t\t\t\t// `localBranchOnly` is built against `commonPath` here; the cache mapper rewrites\n\t\t\t\t\t\t// `repoPath`/`id` to the requesting worktree on retrieval.\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\tlocalBranchOnly: createReference(localInto.ref, commonPath, {\n\t\t\t\t\t\t\t\tid: getBranchId(commonPath, localInto.remote, localInto.name),\n\t\t\t\t\t\t\t\trefType: 'branch',\n\t\t\t\t\t\t\t\tname: localInto.name,\n\t\t\t\t\t\t\t\tremote: localInto.remote,\n\t\t\t\t\t\t\t\tupstream: localInto.upstream,\n\t\t\t\t\t\t\t\tsha: localInto.sha,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn { merged: false };\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate async getBranchMergedStatusCore(\n\t\trepoPath: string,\n\t\tbranch: GitBranchReference,\n\t\tinto: GitBranchReference,\n\t\tcancellation?: AbortSignal,\n\t): Promise<Exclude<GitBranchMergedStatus, 'localBranchOnly'>> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\t// Check if branch is direct ancestor (handles FF merges)\n\t\t\ttry {\n\t\t\t\tawait this.git.run(\n\t\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t\t'merge-base',\n\t\t\t\t\t'--is-ancestor',\n\t\t\t\t\tbranch.name,\n\t\t\t\t\tinto.name,\n\t\t\t\t);\n\t\t\t\treturn { merged: true, confidence: 'highest' };\n\t\t\t} catch (ex) {\n\t\t\t\tif (isCancellationError(ex)) throw ex;\n\t\t\t}\n\n\t\t\t// Cherry-pick detection (handles cherry-picks, rebases, etc)\n\t\t\tlet result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation },\n\t\t\t\t'cherry',\n\t\t\t\t'--abbrev',\n\t\t\t\t'-v',\n\t\t\t\tinto.name,\n\t\t\t\tbranch.name,\n\t\t\t);\n\t\t\t// Check if there are no lines or all lines startwith a `-` (i.e. likely merged)\n\t\t\tif (\n\t\t\t\t!result.stdout ||\n\t\t\t\tresult.stdout\n\t\t\t\t\t.trim()\n\t\t\t\t\t.split('\\n')\n\t\t\t\t\t.every(l => l.startsWith('-'))\n\t\t\t) {\n\t\t\t\treturn { merged: true, confidence: 'high' };\n\t\t\t}\n\n\t\t\t// Attempt to detect squash merges by checking if the diff of the branch can be cleanly removed from the target\n\t\t\tconst mergeBase = await this.provider.refs.getMergeBase(\n\t\t\t\trepoPath,\n\t\t\t\tinto.name,\n\t\t\t\tbranch.name,\n\t\t\t\tundefined,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tresult = await this.git.run({ cwd: repoPath, cancellation: cancellation }, 'diff', mergeBase, branch.name);\n\t\t\tif (result.stdout) {\n\t\t\t\t// Create a temporary index file\n\t\t\t\tawait using disposableIndex = await this.provider.staging.createTemporaryIndex(\n\t\t\t\t\trepoPath,\n\t\t\t\t\t'ref',\n\t\t\t\t\tinto.name,\n\t\t\t\t);\n\t\t\t\tconst { env } = disposableIndex;\n\n\t\t\t\tresult = await this.git.run(\n\t\t\t\t\t{\n\t\t\t\t\t\tcwd: repoPath,\n\t\t\t\t\t\tcancellation: cancellation,\n\t\t\t\t\t\tenv: env,\n\t\t\t\t\t\terrors: 'ignore',\n\t\t\t\t\t\tstdin: result.stdout,\n\t\t\t\t\t},\n\t\t\t\t\t'apply',\n\t\t\t\t\t'--cached',\n\t\t\t\t\t'--reverse',\n\t\t\t\t\t'--check',\n\t\t\t\t\t'-',\n\t\t\t\t);\n\n\t\t\t\tif (result.exitCode === 0 && !result.stdout.trim() && !result.stderr?.trim()) {\n\t\t\t\t\treturn { merged: true, confidence: 'medium' };\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { merged: false };\n\t\t} catch (ex) {\n\t\t\tif (Logger.enabled('trace')) {\n\t\t\t\tscope?.error(ex);\n\t\t\t}\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn { merged: false };\n\t\t}\n\t}\n\n\t@debug()\n\tasync getLocalBranchByUpstream(\n\t\trepoPath: string,\n\t\tremoteBranchName: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranch | undefined> {\n\t\tconst branches = new PageableResult<GitBranch>(p =>\n\t\t\tthis.getBranches(repoPath, p != null ? { paging: p } : undefined, cancellation),\n\t\t);\n\t\treturn getLocalBranchByUpstream(remoteBranchName, branches);\n\t}\n\n\t/** Detects potential conflicts when applying commits onto a target branch (git rebase and cherry-pick) */\n\t@debug()\n\tasync getPotentialApplyConflicts(\n\t\trepoPath: string,\n\t\ttargetBranch: string,\n\t\tshas: string[],\n\t\toptions?: { stopOnFirstConflict?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<ConflictDetectionResult> {\n\t\tif (!shas.length) return { status: 'clean' };\n\n\t\tconst cacheKey: ConflictDetectionCacheKey = `apply:${targetBranch}:${shas.join(',')}:${options?.stopOnFirstConflict ?? false}`;\n\t\treturn this.cache.conflictDetection.getOrCreate(\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tasync (_cacheable, signal) => {\n\t\t\t\t// Resolve all parent refs in a single call - fails if any commit is a root commit (no parent)\n\t\t\t\tconst parentRefs = shas.map(c => `${c}^`);\n\t\t\t\tlet parentShas: string[];\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, cancellation: signal, errors: 'throw' },\n\t\t\t\t\t\t'rev-parse',\n\t\t\t\t\t\t...parentRefs,\n\t\t\t\t\t);\n\t\t\t\t\tparentShas = result.stdout.trim().split('\\n');\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\t\t\t\t\t// If any commit doesn't have a parent (root commit), we can't do conflict detection\n\t\t\t\t\treturn createConflictDetectionError('noParent');\n\t\t\t\t}\n\n\t\t\t\tif (parentShas.length !== shas.length) {\n\t\t\t\t\treturn createConflictDetectionError('refNotFound');\n\t\t\t\t}\n\n\t\t\t\tconst commitsWithParents = shas.map((c, i) => ({ sha: c, parent: parentShas[i] }));\n\t\t\t\treturn this.checkForPotentialConflicts(repoPath, commitsWithParents, targetBranch, signal, options);\n\t\t\t},\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\t/** Detects potential conflict when merge a branch into a target branch (git merge) */\n\t@debug()\n\tasync getPotentialMergeConflicts(\n\t\trepoPath: string,\n\t\tbranch: string,\n\t\ttargetBranch: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<ConflictDetectionResult> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst cacheKey: ConflictDetectionCacheKey = `merge:${branch}:${targetBranch}`;\n\t\treturn this.cache.conflictDetection.getOrCreate(\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tasync (_cacheable, signal) => {\n\t\t\t\tif (!(await this.git.supports('git:merge-tree:write-tree'))) {\n\t\t\t\t\treturn createConflictDetectionError('unsupported');\n\t\t\t\t}\n\n\t\t\t\tlet data;\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, cancellation: signal, errors: 'throw' },\n\t\t\t\t\t\t'merge-tree',\n\t\t\t\t\t\t'-z',\n\t\t\t\t\t\t'--name-only',\n\t\t\t\t\t\t'--no-messages',\n\t\t\t\t\t\tbranch,\n\t\t\t\t\t\ttargetBranch,\n\t\t\t\t\t);\n\t\t\t\t\tdata = result.stdout;\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\t\tconst msg: string = ex?.toString() ?? '';\n\t\t\t\t\tif (GitErrors.notAValidObjectName.test(msg)) {\n\t\t\t\t\t\tscope?.error(\n\t\t\t\t\t\t\tex,\n\t\t\t\t\t\t\t`'${targetBranch}' or '${branch}' not found - ensure the branches exist and are fully qualified (e.g. 'refs/heads/main')`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn createConflictDetectionError('refNotFound');\n\t\t\t\t\t} else if (GitErrors.badRevision.test(msg)) {\n\t\t\t\t\t\tscope?.error(ex, `Invalid branch name: ${msg.slice(msg.indexOf(\"'\"))}`);\n\t\t\t\t\t\treturn createConflictDetectionError('refNotFound');\n\t\t\t\t\t} else if (GitErrors.noMergeBase.test(msg)) {\n\t\t\t\t\t\tscope?.error(\n\t\t\t\t\t\t\tex,\n\t\t\t\t\t\t\t`Unable to merge '${branch}' and '${targetBranch}' as they have no common ancestor`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn createConflictDetectionError('noMergeBase');\n\t\t\t\t\t} else if (ex instanceof GitError) {\n\t\t\t\t\t\tdata = ex.stdout;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tscope?.error(ex);\n\t\t\t\t\t\treturn createConflictDetectionError('other');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!data) return { status: 'clean' };\n\n\t\t\t\tconst mergeConflict = parseMergeTreeConflict(data);\n\t\t\t\tif (!mergeConflict.conflicts.length) return { status: 'clean', treeOid: mergeConflict.treeOid };\n\n\t\t\t\treturn {\n\t\t\t\t\tstatus: 'conflicts',\n\t\t\t\t\tconflict: {\n\t\t\t\t\t\trepoPath: repoPath,\n\t\t\t\t\t\tbranch: branch,\n\t\t\t\t\t\ttarget: targetBranch,\n\t\t\t\t\t\tfiles: mergeConflict.conflicts,\n\t\t\t\t\t\tshas: undefined, // Merge conflicts don't have a specific commit SHA\n\t\t\t\t\t},\n\t\t\t\t\ttreeOid: mergeConflict.treeOid,\n\t\t\t\t};\n\t\t\t},\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\t/** Detects conflicts when an autostash is reapplied onto the tree an integration produced */\n\t@debug()\n\tasync getPotentialStashReapplyConflicts(\n\t\trepoPath: string,\n\t\tontoTreeOid: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<ConflictDetectionResult> {\n\t\t// Requires Git v2.38+ for --write-tree with 3-arg form\n\t\t// `runMergeTreeStep` relies on `--merge-base`\n\t\tif (!(await this.git.supports('git:merge-tree:merge-base'))) {\n\t\t\treturn createConflictDetectionError('unsupported');\n\t\t}\n\n\t\t// git stash create writes commit objects but touches neither the working tree nor the stash ref, and\n\t\t// captures tracked changes only — which is exactly what autostash does\n\t\tlet stashSha: string;\n\t\ttry {\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t'stash',\n\t\t\t\t'create',\n\t\t\t);\n\t\t\tstashSha = result.stdout.trim();\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn createConflictDetectionError('other');\n\t\t}\n\n\t\tif (!stashSha) return { status: 'clean' };\n\n\t\t// Key on what the simulation actually consumes — the stash's tree and its first parent (the HEAD it was\n\t\t// taken against, and so the merge base). The stash SHA itself embeds a commit timestamp, so two runs over\n\t\t// an identical tree produce different SHAs and a SHA-keyed entry could never be hit.\n\t\tlet stashTree: string;\n\t\tlet stashParent: string;\n\t\ttry {\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t'rev-parse',\n\t\t\t\t`${stashSha}^{tree}`,\n\t\t\t\t`${stashSha}^`,\n\t\t\t);\n\t\t\t[stashTree, stashParent] = result.stdout.trim().split('\\n');\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn createConflictDetectionError('other');\n\t\t}\n\n\t\tconst cacheKey: ConflictDetectionCacheKey = `reapply:${ontoTreeOid}:${stashTree}.${stashParent}`;\n\t\treturn this.cache.conflictDetection.getOrCreate(\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tasync (_cacheable, signal) => {\n\t\t\t\t// The stash commit's first parent is the HEAD it was taken against, which is the correct merge\n\t\t\t\t// base for a reapply — ours is the post-integration tree, theirs is the stash\n\t\t\t\tconst step = await this.runMergeTreeStep(repoPath, `${stashSha}^`, ontoTreeOid, stashSha, signal);\n\t\t\t\tif (!step.ok) return createConflictDetectionError(step.reason);\n\n\t\t\t\tif (!step.result.conflicts.length) return { status: 'clean', treeOid: step.result.treeOid };\n\n\t\t\t\treturn {\n\t\t\t\t\tstatus: 'conflicts',\n\t\t\t\t\tconflict: {\n\t\t\t\t\t\trepoPath: repoPath,\n\t\t\t\t\t\tbranch: stashSha,\n\t\t\t\t\t\ttarget: ontoTreeOid,\n\t\t\t\t\t\tfiles: step.result.conflicts,\n\t\t\t\t\t\tshas: undefined,\n\t\t\t\t\t},\n\t\t\t\t\ttreeOid: step.result.treeOid,\n\t\t\t\t};\n\t\t\t},\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\tprivate async runMergeTreeStep(\n\t\trepoPath: string,\n\t\tbase: string,\n\t\tours: string,\n\t\ttheirs: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<{ ok: true; result: GitMergeConflict } | { ok: false; reason: ConflictDetectionErrorReason }> {\n\t\tconst scope = getScopedLogger();\n\n\t\tlet data;\n\t\ttry {\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t'merge-tree',\n\t\t\t\t'--write-tree',\n\t\t\t\t'-z',\n\t\t\t\t'--name-only',\n\t\t\t\t'--no-messages',\n\t\t\t\t`--merge-base=${base}`,\n\t\t\t\tours,\n\t\t\t\ttheirs,\n\t\t\t);\n\t\t\tdata = result.stdout;\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\tconst msg: string = ex?.toString() ?? '';\n\t\t\tif (GitErrors.notAValidObjectName.test(msg)) {\n\t\t\t\tscope?.error(ex, `'${ours}' or '${theirs}' not found - ensure the branches/commits exist`);\n\t\t\t\treturn { ok: false, reason: 'refNotFound' };\n\t\t\t} else if (GitErrors.badRevision.test(msg)) {\n\t\t\t\tscope?.error(ex, `Invalid revision: ${msg.slice(msg.indexOf(\"'\"))}`);\n\t\t\t\treturn { ok: false, reason: 'refNotFound' };\n\t\t\t} else if (GitErrors.noMergeBase.test(msg)) {\n\t\t\t\tscope?.error(ex, `Unable to merge '${ours}' and '${theirs}' as they have no common ancestor`);\n\t\t\t\treturn { ok: false, reason: 'noMergeBase' };\n\t\t\t} else if (ex instanceof GitError) {\n\t\t\t\tdata = ex.stdout;\n\t\t\t} else {\n\t\t\t\tscope?.error(ex, 'Failed to execute merge-tree for conflict check');\n\t\t\t\treturn { ok: false, reason: 'other' };\n\t\t\t}\n\t\t}\n\n\t\treturn { ok: true, result: parseMergeTreeConflict(data ?? '') };\n\t}\n\n\tprivate async checkForPotentialConflicts(\n\t\trepoPath: string,\n\t\tcommits: Iterable<{ sha: string; parent: string }>,\n\t\ttargetBranch: string,\n\t\tcancellation?: AbortSignal,\n\t\toptions?: { stopOnFirstConflict?: boolean },\n\t): Promise<ConflictDetectionResult> {\n\t\tconst scope = getScopedLogger();\n\n\t\t// Requires Git v2.38+ for --write-tree with 3-arg form\n\t\t// `runMergeTreeStep` relies on `--merge-base`\n\t\tif (!(await this.git.supports('git:merge-tree:merge-base'))) {\n\t\t\treturn createConflictDetectionError('unsupported');\n\t\t}\n\n\t\tlet currentTreeOid: string;\n\t\ttry {\n\t\t\t// Get the initial target branch tree OID\n\t\t\tconst treeResult = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t'rev-parse',\n\t\t\t\t`${targetBranch}^{tree}`,\n\t\t\t);\n\t\t\tcurrentTreeOid = treeResult.stdout.trim();\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\tscope?.error(ex, `Failed to resolve target branch '${targetBranch}'`);\n\t\t\treturn createConflictDetectionError('refNotFound');\n\t\t}\n\n\t\tconst conflictingShas: string[] = [];\n\t\tconst conflictingFilePaths = new Set<string>();\n\n\t\tfor (const commit of commits) {\n\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t// Use merge-tree --write-tree with --merge-base to simulate cherry-pick:\n\t\t\t// merge-tree --write-tree --merge-base=<commit-parent> <current-tree> <commit>\n\t\t\t// This performs a 3-way merge where:\n\t\t\t// - base = commit.parent (where the commit started)\n\t\t\t// - ours = currentTreeOid (current state of the target)\n\t\t\t// - theirs = commit.sha (what we're cherry-picking)\n\t\t\tconst step = await this.runMergeTreeStep(repoPath, commit.parent, currentTreeOid, commit.sha, cancellation);\n\t\t\tif (!step.ok) return createConflictDetectionError(step.reason);\n\n\t\t\tconst mergeConflict = step.result;\n\n\t\t\tif (mergeConflict.conflicts.length) {\n\t\t\t\tconflictingShas.push(commit.sha);\n\t\t\t\tfor (const file of mergeConflict.conflicts) {\n\t\t\t\t\tconflictingFilePaths.add(file.path);\n\t\t\t\t}\n\n\t\t\t\tif (options?.stopOnFirstConflict) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstatus: 'conflicts',\n\t\t\t\t\t\tconflict: {\n\t\t\t\t\t\t\trepoPath: repoPath,\n\t\t\t\t\t\t\tbranch: commit.sha,\n\t\t\t\t\t\t\ttarget: targetBranch,\n\t\t\t\t\t\t\tfiles: mergeConflict.conflicts,\n\t\t\t\t\t\t\tshas: [commit.sha],\n\t\t\t\t\t\t},\n\t\t\t\t\t\tstoppedOnFirstConflict: true,\n\t\t\t\t\t\ttreeOid: mergeConflict.treeOid || undefined,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Update currentTreeOid to the result tree OID for the next iteration\n\t\t\t// This works even when there are conflicts - the tree contains conflict markers\n\t\t\tif (mergeConflict.treeOid) {\n\t\t\t\tcurrentTreeOid = mergeConflict.treeOid;\n\t\t\t}\n\t\t}\n\n\t\tif (conflictingShas.length) {\n\t\t\treturn {\n\t\t\t\tstatus: 'conflicts',\n\t\t\t\tconflict: {\n\t\t\t\t\trepoPath: repoPath,\n\t\t\t\t\tbranch: conflictingShas[0],\n\t\t\t\t\ttarget: targetBranch,\n\t\t\t\t\tfiles: Array.from(conflictingFilePaths, path => ({ path: path })),\n\t\t\t\t\tshas: conflictingShas,\n\t\t\t\t},\n\t\t\t\tstoppedOnFirstConflict: false,\n\t\t\t\ttreeOid: currentTreeOid,\n\t\t\t};\n\t\t}\n\n\t\treturn { status: 'clean', treeOid: currentTreeOid };\n\t}\n\n\t@debug({ exit: true })\n\tgetBaseBranchName(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: { priority?: GitCommandPriority },\n\t\tcancellation?: AbortSignal,\n\t): Promise<string | undefined> {\n\t\tconst priority = options?.priority;\n\t\tconst priorityOpts = priority != null ? { priority: priority } : undefined;\n\n\t\treturn this.cache.getBaseBranchName(\n\t\t\trepoPath,\n\t\t\tref,\n\t\t\tasync (commonPath, cacheable, signal) => {\n\t\t\t\ttry {\n\t\t\t\t\t// getGkConfig has built-in fallback to regular config for backward compatibility\n\t\t\t\t\tlet mergeBase = await this.provider.config.getGkConfig(commonPath, `branch.${ref}.gk-merge-base`);\n\t\t\t\t\tlet update = false;\n\n\t\t\t\t\t// Also check vscode-merge-base in regular config (VS Code compatibility)\n\t\t\t\t\tif (mergeBase == null) {\n\t\t\t\t\t\tmergeBase = await this.provider.config.getConfig(commonPath, `branch.${ref}.vscode-merge-base`);\n\t\t\t\t\t\tupdate = mergeBase != null;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (mergeBase != null) {\n\t\t\t\t\t\tconst branch = await this.provider.refs.getSymbolicReferenceName(\n\t\t\t\t\t\t\tcommonPath,\n\t\t\t\t\t\t\tmergeBase,\n\t\t\t\t\t\t\tpriorityOpts,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (branch != null) {\n\t\t\t\t\t\t\tif (update) {\n\t\t\t\t\t\t\t\t// Self-write: the value we're storing is exactly what this factory is\n\t\t\t\t\t\t\t\t// returning, so any in-flight `branchOverviews` or `baseBranchName` entry\n\t\t\t\t\t\t\t\t// being populated against this resolution should NOT be evicted.\n\t\t\t\t\t\t\t\tvoid this.storeBaseBranchName(commonPath, ref, branch, {\n\t\t\t\t\t\t\t\t\tskipInvalidation: ['branchOverviews', 'baseBranchName'],\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn branch;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch {}\n\n\t\t\t\tconst reflog = await this.getBaseBranchFromReflog(\n\t\t\t\t\tcommonPath,\n\t\t\t\t\tref,\n\t\t\t\t\t{ upstream: true, priority: priority },\n\t\t\t\t\tsignal,\n\t\t\t\t);\n\t\t\t\tif (reflog.branch != null) {\n\t\t\t\t\t// Self-write: see comment on the migration path above.\n\t\t\t\t\tvoid this.storeBaseBranchName(commonPath, ref, reflog.branch, {\n\t\t\t\t\t\tskipInvalidation: ['branchOverviews', 'baseBranchName'],\n\t\t\t\t\t});\n\t\t\t\t\treturn reflog.branch;\n\t\t\t\t}\n\n\t\t\t\t// This entry has no TTL and the `'branches'` cascade no longer clears it (a tip move can't\n\t\t\t\t// change a base), so a failed read cached as `undefined` would read as \"no base branch\" for\n\t\t\t\t// the rest of the session. Only a reflog that actually RAN and found nothing is an answer.\n\t\t\t\tif (reflog.failed) {\n\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\t/**\n\t * `failed` separates \"the reflog ran and had no answer\" from \"the read never happened\" — the caller\n\t * caches the former forever and must not cache the latter.\n\t */\n\tprivate async getBaseBranchFromReflog(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: { upstream: true; priority?: GitCommandPriority },\n\t\tcancellation?: AbortSignal,\n\t): Promise<{ branch: string | undefined; failed: boolean }> {\n\t\tconst priority = options?.priority;\n\t\tconst priorityOpts = priority != null ? { priority: priority } : undefined;\n\n\t\ttry {\n\t\t\tconst createdFrom = await this.getReflogCreatedFrom(repoPath, ref, priority, cancellation);\n\t\t\tif (createdFrom == null) return { branch: undefined, failed: false };\n\n\t\t\t// Check if branch created from an explicit branch\n\t\t\tif (createdFrom !== 'HEAD') {\n\t\t\t\tif (options?.upstream) {\n\t\t\t\t\tconst upstream = await this.provider.refs.getSymbolicReferenceName(\n\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t`${createdFrom}@{u}`,\n\t\t\t\t\t\tpriorityOpts,\n\t\t\t\t\t);\n\t\t\t\t\tif (upstream) return { branch: upstream, failed: false };\n\t\t\t\t}\n\n\t\t\t\tconst name = await this.provider.refs.getSymbolicReferenceName(repoPath, createdFrom, priorityOpts);\n\t\t\t\tif (name) return { branch: name, failed: false };\n\t\t\t}\n\n\t\t\t// Check if branch was created from HEAD\n\t\t\tconst entries = await this.provider.refs.getReflogEntries(\n\t\t\t\trepoPath,\n\t\t\t\t'HEAD',\n\t\t\t\t{ grep: `checkout: moving from .* to ${ref.replace('refs/heads/', '')}`, priority: priority },\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (!entries.length) return { branch: undefined, failed: false };\n\n\t\t\tconst match = entries.at(-1)!.message.match(/checkout: moving from ([^\\s]+)\\s/);\n\t\t\tif (match?.length === 2) {\n\t\t\t\tlet name: string | undefined = match[1];\n\t\t\t\tif (options?.upstream) {\n\t\t\t\t\tconst upstream = await this.provider.refs.getSymbolicReferenceName(\n\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t`${name}@{u}`,\n\t\t\t\t\t\tpriorityOpts,\n\t\t\t\t\t);\n\t\t\t\t\tif (upstream) return { branch: upstream, failed: false };\n\t\t\t\t}\n\n\t\t\t\tname = await this.provider.refs.getSymbolicReferenceName(repoPath, name, priorityOpts);\n\t\t\t\tif (name) return { branch: name, failed: false };\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t// A ref that is unborn, or gone since it was listed, has no reflog to read: an answer, not a failure\n\t\t\tconst msg: string = ex?.toString() ?? '';\n\t\t\tconst stderr = ex instanceof GitError ? ex.stderr : undefined;\n\t\t\tif (\n\t\t\t\t[GitErrors.badRevision, GitErrors.ambiguousArgument].some(\n\t\t\t\t\terror => error.test(msg) || (stderr != null && error.test(stderr)),\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn { branch: undefined, failed: false };\n\t\t\t}\n\n\t\t\t// `getReflogEntries` rejects on a failed read, so a read that never happened isn't taken as \"no base\"\n\t\t\treturn { branch: undefined, failed: true };\n\t\t}\n\n\t\treturn { branch: undefined, failed: false };\n\t}\n\n\t/**\n\t * The start point `ref`'s own reflog says it was created from (`branch: Created from <name>`), as git wrote it:\n\t * a branch, `HEAD`, a sha, a tag or any other revision. `undefined` unless exactly one entry says so. Rejects\n\t * when the reflog can't be read, including for a ref that doesn't exist.\n\t */\n\tprivate async getReflogCreatedFrom(\n\t\trepoPath: string,\n\t\tref: string,\n\t\tpriority: GitCommandPriority | undefined,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<string | undefined> {\n\t\tconst entries = await this.provider.refs.getReflogEntries(\n\t\t\trepoPath,\n\t\t\tref,\n\t\t\t{ grep: 'branch: Created from *.', priority: priority },\n\t\t\tcancellation,\n\t\t);\n\t\tif (entries.length !== 1) return undefined;\n\n\t\treturn entries[0].message.match(/branch: Created from (.*)$/)?.[1];\n\t}\n\n\t/**\n\t * The branch `branch` was created from, as a base for {@link getAheadOfBaseInOrder}: the name its own reflog\n\t * gives, when that is a local or remote-tracking branch in the cached ref list and not `branch` itself or its\n\t * copy on a remote (`git switch <branch>` creates it from `<remote>/<branch>`). Never the checkout history in\n\t * HEAD's reflog, which on a long-lived checkout names whatever was checked out last.\n\t */\n\tprivate async getCreatedFromTarget(\n\t\trepoPath: string,\n\t\tbranch: string,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<string | undefined> {\n\t\tconst key = this.getBranchActivityKey(repoPath, branch);\n\n\t\tlet name: string | undefined;\n\t\tif (this._branchCreatedFrom.has(key)) {\n\t\t\tname = this._branchCreatedFrom.get(key);\n\t\t} else {\n\t\t\tconst generation = this._branchCreatedFromGenerations.get(key);\n\t\t\ttry {\n\t\t\t\tname = await this.getReflogCreatedFrom(repoPath, `refs/heads/${branch}`, undefined, cancellation);\n\t\t\t} catch (ex) {\n\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\t// Not remembered: a failed read is no answer, and a branch with no ref yet has no creation to read\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\tif (this._branchCreatedFromGenerations.get(key) === generation) {\n\t\t\t\tthis._branchCreatedFrom.set(key, name);\n\t\t\t}\n\t\t}\n\n\t\t// A ref starting with `-` would be parsed as a git flag\n\t\tif (!name || name === 'HEAD' || name.startsWith('-')) return undefined;\n\n\t\t// Only a listed branch: a sha, a tag or a revision expression (`main~2`) names no `refs/heads/` or\n\t\t// `refs/remotes/` ref\n\t\tconst records = await this.provider.refs.getRefs(repoPath, cancellation);\n\t\tconst fullNames =\n\t\t\tname.startsWith('refs/heads/') || name.startsWith('refs/remotes/')\n\t\t\t\t? [name]\n\t\t\t\t: [`refs/heads/${name}`, `refs/remotes/${name}`];\n\t\tlet listed = false;\n\t\tfor (const fullName of fullNames) {\n\t\t\tif ((await this.getRefTip(repoPath, records, fullName, cancellation)) != null) {\n\t\t\t\tlisted = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!listed) return undefined;\n\n\t\tif (await this.isSelfRef(repoPath, name, branch, cancellation)) return undefined;\n\n\t\treturn name;\n\t}\n\n\t@debug({ exit: true })\n\tasync getAheadOfBase(\n\t\trepoPath: string,\n\t\tbranch: string | undefined,\n\t\toptions?: { skipUserTarget?: boolean; preferredTarget?: string },\n\t\tcancellation?: AbortSignal,\n\t): Promise<AheadOfBase> {\n\t\t// `undefined`, or a name that stands for a detached HEAD, has no branch to be recorded against or to be its own base\n\t\tif (branch != null && isDetachedHead(branch)) {\n\t\t\tbranch = undefined;\n\t\t}\n\n\t\tconst dependsOn = new Set<string>(branch != null ? [`refs/heads/${branch}`] : []);\n\n\t\tconst preferredTarget = options?.preferredTarget?.trim() || undefined;\n\t\tif (preferredTarget == null) {\n\t\t\treturn this.getAheadOfBaseInOrder(repoPath, branch, options?.skipUserTarget, dependsOn, cancellation);\n\t\t}\n\n\t\tlet target = await this.getNearestForkTarget(repoPath, branch, preferredTarget, dependsOn, cancellation);\n\t\tif (target != null && branch != null && (await this.isSelfAtHead(repoPath, target.ref, branch, cancellation))) {\n\t\t\ttarget = undefined;\n\t\t}\n\n\t\t// The tolerant reads above answer a cancelled run as \"nothing there\"; that is no answer\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tif (target != null) {\n\t\t\treturn this.measureAheadOfBase(repoPath, target, 'preferred', dependsOn, cancellation);\n\t\t}\n\n\t\treturn this.getAheadOfBaseInOrder(repoPath, branch, options?.skipUserTarget, dependsOn, cancellation);\n\t}\n\n\t/**\n\t * Resolves the base from the recorded candidates, then the branch it was created from or the default branch, for\n\t * {@link getAheadOfBase}\n\t */\n\tprivate async getAheadOfBaseInOrder(\n\t\trepoPath: string,\n\t\tbranch: string | undefined,\n\t\tskipUserTarget: boolean | undefined,\n\t\tdependsOn: Set<string>,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<AheadOfBase> {\n\t\tlet target: { ref: string; forkPoint: string | undefined } | undefined;\n\t\tlet tier: AheadOfBaseTier = 'default';\n\t\tif (branch != null) {\n\t\t\tfor (const candidate of await this.getRecordedBaseCandidates(repoPath, branch, skipUserTarget)) {\n\t\t\t\ttarget = await this.getNearestForkTarget(repoPath, branch, candidate.ref, dependsOn, cancellation);\n\t\t\t\tif (target != null) {\n\t\t\t\t\ttier = candidate.tier;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (target == null) {\n\t\t\tconst defaultBranch = await this.getLocalDefaultBranchName(repoPath, dependsOn, cancellation);\n\t\t\t// Before the reflog read: the default branch measures against its own upstream, even a gitflow `develop`\n\t\t\t// created from `main`\n\t\t\tif (branch != null && defaultBranch === branch) {\n\t\t\t\treturn this.measureAheadOfSelfUpstream(repoPath, branch, dependsOn, cancellation);\n\t\t\t}\n\n\t\t\tconst createdFrom =\n\t\t\t\tbranch != null ? await this.getCreatedFromTarget(repoPath, branch, cancellation) : undefined;\n\t\t\tif (createdFrom != null) {\n\t\t\t\tconst created = await this.getCreatedFromForkTarget(\n\t\t\t\t\trepoPath,\n\t\t\t\t\tbranch,\n\t\t\t\t\tcreatedFrom,\n\t\t\t\t\tdefaultBranch,\n\t\t\t\t\tdependsOn,\n\t\t\t\t\tcancellation,\n\t\t\t\t);\n\t\t\t\tif (created != null) {\n\t\t\t\t\t({ target, tier } = created);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttarget = await this.getUpstreamNearestForkTarget(\n\t\t\t\t\trepoPath,\n\t\t\t\t\tbranch,\n\t\t\t\t\tdefaultBranch,\n\t\t\t\t\tdependsOn,\n\t\t\t\t\tcancellation,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// The tolerant reads above answer a cancelled run as \"nothing there\"; that is no answer\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\t\tif (target == null) {\n\t\t\tlet unborn = false;\n\t\t\t// A detached HEAD always has a commit, and so does a branch the cached refs list\n\t\t\tif (branch != null) {\n\t\t\t\ttry {\n\t\t\t\t\tconst records = await this.provider.refs.getRefs(repoPath, cancellation);\n\t\t\t\t\tunborn =\n\t\t\t\t\t\tfindRefTip(records, `refs/heads/${branch}`) == null &&\n\t\t\t\t\t\t(await this.isUnbornHead(repoPath, cancellation));\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { base: undefined, reason: unborn ? 'unborn' : 'none', dependsOn: [...dependsOn] };\n\t\t}\n\n\t\t// A base that is the branch itself, locally or as its copy on one of the repo's remotes, at HEAD's own commit has\n\t\t// nothing to measure against: no base, not \"0 ahead\" (an up-to-date `main` targeting `origin/main`). At a different\n\t\t// commit it stays the base, since the work ahead of it is work not yet pushed\n\t\tif (branch != null && (await this.isSelfAtHead(repoPath, target.ref, branch, cancellation))) {\n\t\t\treturn { base: undefined, reason: 'self', dependsOn: [...dependsOn] };\n\t\t}\n\n\t\treturn this.measureAheadOfBase(repoPath, target, tier, dependsOn, cancellation);\n\t}\n\n\t/**\n\t * The base for a branch created from `createdFrom`: that branch, unless the default branch forked strictly nearer\n\t * HEAD, as it does once `createdFrom` merged into it and the branch was rebased onto it. A stacked branch's\n\t * unmerged parent forked nearer, and stays its base. `undefined` when neither is usable.\n\t */\n\tprivate async getCreatedFromForkTarget(\n\t\trepoPath: string,\n\t\tbranch: string | undefined,\n\t\tcreatedFrom: string,\n\t\tdefaultBranch: string | undefined,\n\t\tdependsOn: Set<string>,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<{ target: { ref: string; forkPoint: string | undefined }; tier: AheadOfBaseTier } | undefined> {\n\t\tconst skipDefault =\n\t\t\tdefaultBranch == null ||\n\t\t\tcreatedFrom === defaultBranch ||\n\t\t\tcreatedFrom === `refs/heads/${defaultBranch}` ||\n\t\t\tcreatedFrom === `refs/remotes/${defaultBranch}`;\n\t\tconst [created, fallback] = await Promise.all([\n\t\t\tthis.getUpstreamNearestForkTarget(repoPath, branch, createdFrom, dependsOn, cancellation),\n\t\t\tskipDefault\n\t\t\t\t? undefined\n\t\t\t\t: this.getUpstreamNearestForkTarget(repoPath, branch, defaultBranch, dependsOn, cancellation),\n\t\t]);\n\t\tif (created == null) return fallback != null ? { target: fallback, tier: 'default' } : undefined;\n\n\t\tif (\n\t\t\tcreated.forkPoint != null &&\n\t\t\tfallback?.forkPoint != null &&\n\t\t\tcreated.forkPoint !== fallback.forkPoint &&\n\t\t\t(await this.provider.commits.isAncestorOf(repoPath, created.forkPoint, fallback.forkPoint, cancellation))\n\t\t) {\n\t\t\treturn { target: fallback, tier: 'default' };\n\t\t}\n\t\treturn { target: created, tier: 'created' };\n\t}\n\n\t/** Counts HEAD's commits past `target` for {@link getAheadOfBase} */\n\tprivate async measureAheadOfBase(\n\t\trepoPath: string,\n\t\ttarget: { ref: string; forkPoint: string | undefined },\n\t\ttier: AheadOfBaseTier,\n\t\tdependsOn: Set<string>,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<AheadOfBase> {\n\t\tconst [countsResult, refsResult] = await Promise.allSettled([\n\t\t\tthis.countAgainstBase(repoPath, target.ref, cancellation),\n\t\t\t// The same cached `for-each-ref` the branch list reads, so the tip usually costs nothing\n\t\t\tthis.provider.refs.getRefs(repoPath, cancellation),\n\t\t]);\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\t\tif (countsResult.status === 'rejected') throw countsResult.reason;\n\n\t\tconst counts = countsResult.value;\n\t\tif (counts == null) return { base: undefined, reason: 'unborn', dependsOn: [...dependsOn] };\n\n\t\treturn {\n\t\t\tbase: {\n\t\t\t\tref: target.ref,\n\t\t\t\tahead: counts.right,\n\t\t\t\tsha: findRefTip(getSettledValue(refsResult, []), target.ref),\n\t\t\t\tforkPoint: target.forkPoint,\n\t\t\t\ttier: tier,\n\t\t\t},\n\t\t\tdependsOn: [...dependsOn],\n\t\t};\n\t}\n\n\t/** Counts the default branch's own commits past its upstream (see {@link getSelfUpstreamTarget}) for {@link getAheadOfBase} */\n\tprivate async measureAheadOfSelfUpstream(\n\t\trepoPath: string,\n\t\tbranch: string,\n\t\tdependsOn: Set<string>,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<AheadOfBase> {\n\t\tconst upstream = await this.getSelfUpstreamTarget(repoPath, branch, dependsOn, cancellation);\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\t\tif (upstream == null) return { base: undefined, reason: 'self', dependsOn: [...dependsOn] };\n\n\t\tconst counts = await this.countAgainstBase(repoPath, upstream.ref, cancellation);\n\t\tif (counts == null) return { base: undefined, reason: 'unborn', dependsOn: [...dependsOn] };\n\t\t// Only the same commit leaves neither side a commit the other lacks\n\t\tif (counts.left === 0 && counts.right === 0) {\n\t\t\treturn { base: undefined, reason: 'self', dependsOn: [...dependsOn] };\n\t\t}\n\n\t\t// An upstream with nothing HEAD lacks is an ancestor of HEAD, so its tip is where HEAD forked from it\n\t\tconst forkPoint =\n\t\t\tcounts.left === 0 ? upstream.sha : await this.getForkPoint(repoPath, upstream.ref, cancellation);\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\treturn {\n\t\t\tbase: { ref: upstream.ref, ahead: counts.right, sha: upstream.sha, forkPoint: forkPoint, tier: 'upstream' },\n\t\t\tdependsOn: [...dependsOn],\n\t\t};\n\t}\n\n\t/**\n\t * HEAD's count against `ref` from their merge base: `left` only `ref` has, `right` only HEAD has. `undefined`\n\t * before HEAD's first commit, when there is nothing to count; any other failure rejects with git's error.\n\t */\n\tprivate async countAgainstBase(\n\t\trepoPath: string,\n\t\tref: string,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<{ left: number; right: number } | undefined> {\n\t\t// `...` counts from the merge base, so only the branch's own commits count, not what the base moved on with\n\t\tconst range = createRevisionRange(ref, 'HEAD', '...');\n\n\t\tlet counts: { left: number; right: number } | undefined;\n\t\ttry {\n\t\t\tcounts = await this.provider.commits.getLeftRightCommitCount(repoPath, range, undefined, cancellation);\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\t\t}\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\t\tif (counts != null) return counts;\n\n\t\t// The cached count keeps a failure, so re-run it uncached\n\t\ttry {\n\t\t\treturn await this.getLeftRightCountUncached(repoPath, range, cancellation);\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\t\t\tif (await this.isUnbornHead(repoPath, cancellation)) return undefined;\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t@debug({ exit: true })\n\tasync getAheadBehindCounts(\n\t\trepoPath: string,\n\t\tbase: string,\n\t\toptions?: { remotes?: boolean; refs?: readonly string[] },\n\t\tcancellation?: AbortSignal,\n\t): Promise<Map<string, { ahead: number; behind: number }>> {\n\t\tconst counts = new Map<string, { ahead: number; behind: number }>();\n\n\t\tconst refs = options?.refs != null ? new Set(options.refs) : undefined;\n\t\tif (refs?.size === 0) return counts;\n\n\t\t// for-each-ref also matches below a pattern (`refs/heads/a` matches `refs/heads/a/b`), so named refs are kept\n\t\t// to the exact set; a list too long for the command line is read whole and filtered\n\t\tlet patterns: string[];\n\t\tif (refs == null) {\n\t\t\tpatterns = options?.remotes ? ['refs/heads', 'refs/remotes'] : ['refs/heads'];\n\t\t} else if (sum(refs, r => r.length + 1) < maxGitCliLength / 2) {\n\t\t\tpatterns = [...refs];\n\t\t} else {\n\t\t\tpatterns = ['refs/heads', 'refs/remotes'];\n\t\t}\n\n\t\t// The format atom ends at the first `)`, which a ref name may contain, so such a base is counted per branch\n\t\tif (!base.includes(')') && (await this.git.supports('git:for-each-ref:ahead-behind'))) {\n\t\t\t// Tab-separated: ref names can't contain control characters, so no field or line can hold one\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t'for-each-ref',\n\t\t\t\t`--format=%(refname)%09%(symref)%09%(ahead-behind:${base})`,\n\t\t\t\t...patterns,\n\t\t\t);\n\t\t\tif (result.completion.status === 'cancelled' || cancellation?.aborted) throw new CancellationError();\n\n\t\t\tfor (const line of result.stdout.split('\\n')) {\n\t\t\t\tif (!line) continue;\n\n\t\t\t\tconst [ref, symref, counted] = line.split('\\t');\n\t\t\t\tif (symref || (refs != null && !refs.has(ref))) continue;\n\n\t\t\t\tconst [ahead, behind] = (counted ?? '').split(' ').map(n => parseInt(n, 10));\n\t\t\t\tif (isNaN(ahead) || isNaN(behind)) {\n\t\t\t\t\tthrow new Error(`Unexpected output counting the commits ahead of and behind '${base}': ${line}`);\n\t\t\t\t}\n\n\t\t\t\tcounts.set(ref, { ahead: ahead, behind: behind });\n\t\t\t}\n\n\t\t\treturn counts;\n\t\t}\n\n\t\t// A leading dash would be read as an option by the `rev-parse` and `rev-list` below\n\t\tif (base.startsWith('-')) throw new Error(`Invalid base '${base}'`);\n\n\t\tconst [refsResult, baseResult] = await Promise.allSettled([\n\t\t\tthis.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t'for-each-ref',\n\t\t\t\t'--format=%(refname)%09%(symref)%09%(objectname)',\n\t\t\t\t...patterns,\n\t\t\t),\n\t\t\tthis.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t'rev-parse',\n\t\t\t\t'--is-shallow-repository',\n\t\t\t\t'--verify',\n\t\t\t\t`${base}^{commit}`,\n\t\t\t),\n\t\t]);\n\t\tif (refsResult.status === 'rejected') throw refsResult.reason;\n\n\t\tconst result = refsResult.value;\n\t\tif (result.completion.status === 'cancelled' || cancellation?.aborted) throw new CancellationError();\n\n\t\t// Refs grouped by the commit they point at, so each tip is counted once\n\t\tconst refsByTip = new Map<string, string[]>();\n\t\tfor (const line of result.stdout.split('\\n')) {\n\t\t\tconst [ref, symref, sha] = line.split('\\t');\n\t\t\tif (!ref || symref || !sha || (refs != null && !refs.has(ref))) continue;\n\n\t\t\tconst tipRefs = refsByTip.get(sha);\n\t\t\tif (tipRefs == null) {\n\t\t\t\trefsByTip.set(sha, [ref]);\n\t\t\t} else {\n\t\t\t\ttipRefs.push(ref);\n\t\t\t}\n\t\t}\n\t\tif (!refsByTip.size) return counts;\n\n\t\tif (baseResult.status === 'rejected') throw baseResult.reason;\n\t\tif (baseResult.value.completion.status === 'cancelled' || cancellation?.aborted) {\n\t\t\tthrow new CancellationError();\n\t\t}\n\n\t\tconst [shallow, baseSha] = baseResult.value.stdout.trim().split('\\n');\n\t\t// Deepening a shallow clone changes what a pair of commits counts; git before 2.15 echoes the unknown option\n\t\tconst cacheable = shallow === 'false';\n\t\tconst countsByTip = new Map<string, { ahead: number; behind: number }>();\n\t\tconst uncounted: string[] = [];\n\t\tfor (const sha of refsByTip.keys()) {\n\t\t\tif (sha === baseSha) {\n\t\t\t\tcountsByTip.set(sha, { ahead: 0, behind: 0 });\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst range = createRevisionRange(baseSha, sha, '...');\n\t\t\tconst cached = cacheable ? this.aheadBehindBySha.get(range) : undefined;\n\t\t\tif (cached != null) {\n\t\t\t\tthis.aheadBehindBySha.touch(range);\n\t\t\t\tcountsByTip.set(sha, cached);\n\t\t\t} else {\n\t\t\t\tuncounted.push(sha);\n\t\t\t}\n\t\t}\n\n\t\tconst results = await mapBounded(uncounted, 8, async sha => {\n\t\t\tconst range = createRevisionRange(baseSha, sha, '...');\n\t\t\t// The base is the left side of the range, so `left` is what the branch lacks and `right` what it adds\n\t\t\tconst lr = await this.getLeftRightCountUncached(repoPath, range, cancellation, 'background');\n\t\t\tconst tipCounts = { ahead: lr.right, behind: lr.left };\n\t\t\t// Remembered as each lands, so a tip that fails doesn't cost the next call the counts that didn't\n\t\t\tif (cacheable) {\n\t\t\t\tthis.aheadBehindBySha.set(range, tipCounts);\n\t\t\t}\n\t\t\treturn { sha: sha, counts: tipCounts };\n\t\t});\n\t\tfor (const { sha, counts: tipCounts } of results) {\n\t\t\tcountsByTip.set(sha, tipCounts);\n\t\t}\n\n\t\tfor (const [sha, tipRefs] of refsByTip) {\n\t\t\tconst tipCounts = countsByTip.get(sha)!;\n\t\t\tfor (const ref of tipRefs) {\n\t\t\t\tcounts.set(ref, { ...tipCounts });\n\t\t\t}\n\t\t}\n\n\t\treturn counts;\n\t}\n\n\t@debug({ exit: true })\n\tasync getMergedBranches(\n\t\trepoPath: string,\n\t\tinto: string,\n\t\toptions?: { remotes?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<Set<string>> {\n\t\tconst patterns = options?.remotes ? ['refs/heads', 'refs/remotes'] : ['refs/heads'];\n\n\t\t// Tab-separated: ref names can't contain control characters, so no field or line can hold one\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t'for-each-ref',\n\t\t\t`--merged=${into}`,\n\t\t\t'--format=%(refname)%09%(symref)',\n\t\t\t...patterns,\n\t\t);\n\t\tif (result.completion.status === 'cancelled' || cancellation?.aborted) throw new CancellationError();\n\n\t\tconst merged = new Set<string>();\n\t\tfor (const line of result.stdout.split('\\n')) {\n\t\t\tif (!line) continue;\n\n\t\t\tconst [ref, symref] = line.split('\\t');\n\t\t\tif (symref) continue;\n\n\t\t\tmerged.add(ref);\n\t\t}\n\n\t\treturn merged;\n\t}\n\n\t/** Counts `range` with a fresh `rev-list`, bypassing the cached count. Rejects on any failure, with git's error */\n\tprivate async getLeftRightCountUncached(\n\t\trepoPath: string,\n\t\trange: GitRevisionRange,\n\t\tcancellation: AbortSignal | undefined,\n\t\tpriority?: GitCommandPriority,\n\t): Promise<{ left: number; right: number }> {\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw', priority: priority },\n\t\t\t'rev-list',\n\t\t\t'--left-right',\n\t\t\t'--count',\n\t\t\trange,\n\t\t\t'--',\n\t\t);\n\t\tif (result.completion.status === 'cancelled' || cancellation?.aborted) throw new CancellationError();\n\n\t\tconst parts = result.stdout.split('\\t');\n\t\tconst left = parseInt(parts[0], 10);\n\t\tconst right = parseInt(parts[1], 10);\n\t\tif (parts.length !== 2 || isNaN(left) || isNaN(right)) {\n\t\t\tthrow new Error(`Unexpected output counting the commits in '${range}': ${result.stdout}`);\n\t\t}\n\n\t\treturn { left: left, right: right };\n\t}\n\n\t/** Whether HEAD names a branch with no commit yet. Rejects when that can't be read, so a failure isn't taken for an empty branch */\n\tprivate async isUnbornHead(repoPath: string, cancellation: AbortSignal | undefined): Promise<boolean> {\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw', expectedExitCodes: [1] },\n\t\t\t'rev-parse',\n\t\t\t'--verify',\n\t\t\t'--quiet',\n\t\t\t'HEAD',\n\t\t);\n\t\treturn result.exitCode === 1;\n\t}\n\n\t/**\n\t * Whether `ref` names `branch` itself: the same name, or `<remote>/<branch>` for one of the repo's actual remotes,\n\t * short or as a full ref. Splitting at the first slash instead would call a local `release/main` the same branch\n\t * as `main`.\n\t */\n\tprivate async isSelfRef(\n\t\trepoPath: string,\n\t\tref: string,\n\t\tbranch: string,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<boolean> {\n\t\t// A full local ref is never a remote copy, even one named like `origin/<branch>`\n\t\tif (ref.startsWith('refs/heads/')) return ref.slice('refs/heads/'.length) === branch;\n\n\t\tif (ref.startsWith('refs/remotes/')) {\n\t\t\tref = ref.slice('refs/remotes/'.length);\n\t\t}\n\n\t\tif (ref === branch) return true;\n\n\t\tconst suffix = `/${branch}`;\n\t\tif (!ref.endsWith(suffix)) return false;\n\n\t\tconst remoteName = ref.slice(0, -suffix.length);\n\t\tif (!remoteName) return false;\n\n\t\treturn (await this.getRemoteNames(repoPath, cancellation)).includes(remoteName);\n\t}\n\n\t/** The repo's remote names from the cached remote list; empty when it can't be read */\n\tprivate async getRemoteNames(repoPath: string, cancellation: AbortSignal | undefined): Promise<string[]> {\n\t\ttry {\n\t\t\tconst remotes = await this.provider.remotes.getRemotes(repoPath, undefined, cancellation);\n\t\t\treturn remotes.map(r => r.name);\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn [];\n\t\t}\n\t}\n\n\t/** Whether `ref` names `branch` itself (see {@link isSelfRef}) and sits at HEAD's commit; tips are read only after the name matched */\n\tprivate async isSelfAtHead(\n\t\trepoPath: string,\n\t\tref: string,\n\t\tbranch: string,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<boolean> {\n\t\tif (!(await this.isSelfRef(repoPath, ref, branch, cancellation))) return false;\n\n\t\tconst [refSha, headSha] = await Promise.all([\n\t\t\tthis.provider.refs.validateReference(repoPath, ref, undefined, cancellation),\n\t\t\tthis.provider.refs.validateReference(repoPath, 'HEAD', undefined, cancellation),\n\t\t]);\n\t\treturn refSha != null && refSha === headSha;\n\t}\n\n\t/**\n\t * The bases recorded against a branch, most trusted first: the user's merge target, the detected one, then the\n\t * base a launch recorded. Only the stored value of the latter — `getBaseBranchName` would fall back to a reflog\n\t * guess, which on a long-lived checkout names whatever branch was last checked out from. A failed read is absent.\n\t */\n\tprivate async getRecordedBaseCandidates(\n\t\trepoPath: string,\n\t\tbranch: string,\n\t\tskipUserTarget: boolean | undefined,\n\t): Promise<{ ref: string; tier: AheadOfBaseTier }[]> {\n\t\tconst tolerate = async (read: () => Promise<string | undefined>): Promise<string | undefined> => {\n\t\t\ttry {\n\t\t\t\treturn (await read())?.trim() || undefined;\n\t\t\t} catch (ex) {\n\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t};\n\n\t\tconst reads = await Promise.all([\n\t\t\tskipUserTarget ? undefined : tolerate(() => this.getStoredUserMergeTargetBranchName(repoPath, branch)),\n\t\t\ttolerate(() => this.getStoredDetectedMergeTargetBranchName(repoPath, branch)),\n\t\t\ttolerate(() => this.provider.config.getGkConfig(repoPath, `branch.${branch}.gk-merge-base`)),\n\t\t]);\n\n\t\tconst tiers: AheadOfBaseTier[] = ['user', 'detected', 'recorded'];\n\n\t\tconst candidates: { ref: string; tier: AheadOfBaseTier }[] = [];\n\t\tfor (const [i, ref] of reads.entries()) {\n\t\t\tif (ref && !candidates.some(c => c.ref === ref)) {\n\t\t\t\tcandidates.push({ ref: ref, tier: tiers[i] });\n\t\t\t}\n\t\t}\n\t\treturn candidates;\n\t}\n\n\t/**\n\t * The repo's default branch from local refs only, never the network: the `HEAD` symref of the `upstream` remote,\n\t * else of `origin`, else of the first remote, as its local branch or else as the remote ref; then, in the same\n\t * remote order, `<remote>/main` or `<remote>/master`, again as the local branch of that name or else the remote\n\t * ref; then `init.defaultBranch`, `main`, `master` — each only if it names a commit.\n\t */\n\tprivate async getLocalDefaultBranchName(\n\t\trepoPath: string,\n\t\tdependsOn: Set<string>,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<string | undefined> {\n\t\t// From the cached ref list the base reads anyway, so naming a branch spawns nothing\n\t\tlet records: readonly RefRecord[] | undefined;\n\t\tconst exists = async (ref: string): Promise<boolean> => {\n\t\t\trecords ??= await this.provider.refs.getRefs(repoPath, cancellation);\n\t\t\treturn (await this.getRefTip(repoPath, records, ref, cancellation)) != null;\n\t\t};\n\n\t\tconst remotes = await this.getRemoteNames(repoPath, cancellation);\n\t\t// Each in turn: a remote added after the clone (`upstream`, typically) has no `HEAD` symref until\n\t\t// `remote set-head` writes one, and must not hide `origin`'s\n\t\tconst preferred = new Set(\n\t\t\t[remotes.find(r => r === 'upstream'), remotes.find(r => r === 'origin'), remotes.at(0)].filter(\n\t\t\t\tr => r != null,\n\t\t\t),\n\t\t);\n\t\tfor (const remote of preferred) {\n\t\t\tdependsOn.add(`refs/remotes/${remote}/HEAD`);\n\n\t\t\tconst symref = await this.getDefaultBranchName(repoPath, remote, { local: true }, cancellation);\n\t\t\t// A remote name can hold a slash, so strip exactly the remote's own prefix\n\t\t\tconst local = symref?.startsWith(`${remote}/`) ? symref.slice(remote.length + 1) : undefined;\n\t\t\tif (!symref || !local) continue;\n\n\t\t\taddRefDependencies(dependsOn, local);\n\t\t\tif (await exists(local)) return local;\n\n\t\t\taddRefDependencies(dependsOn, symref);\n\t\t\tif (await exists(symref)) return symref;\n\t\t}\n\n\t\t// A missing symref is common (git < 2.48 fetches don't create it, nor do fetches of explicit refspecs), so\n\t\t// guess from the remote's usual default names\n\t\tfor (const remote of preferred) {\n\t\t\tfor (const name of ['main', 'master']) {\n\t\t\t\tconst remoteRef = `refs/remotes/${remote}/${name}`;\n\t\t\t\tdependsOn.add(remoteRef);\n\t\t\t\tif (!(await exists(remoteRef))) continue;\n\n\t\t\t\taddRefDependencies(dependsOn, name);\n\t\t\t\treturn (await exists(name)) ? name : `${remote}/${name}`;\n\t\t\t}\n\t\t}\n\n\t\tlet fromConfig: string | undefined;\n\t\ttry {\n\t\t\tfromConfig = (await this.provider.config.getConfig(repoPath, 'init.defaultBranch'))?.trim() || undefined;\n\t\t} catch {}\n\n\t\tfor (const candidate of [fromConfig, 'main', 'master']) {\n\t\t\tif (!candidate) continue;\n\n\t\t\taddRefDependencies(dependsOn, candidate);\n\t\t\tif (await exists(candidate)) return candidate;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * `upstream/<name>` for a created-from or default base `<name>` (or `<remote>/<name>`), as another ref that base\n\t * is measured against: in a fork whose `main` tracks `origin/main`, a branch taken off (or since rebased onto) a\n\t * newer `upstream/main` would otherwise count the commits `origin` hasn't caught up on. Read from the cached\n\t * remote and ref lists; `undefined` when there is no `upstream` remote, it lacks the branch, or the base is that\n\t * ref itself.\n\t */\n\tprivate async getUpstreamContender(\n\t\trepoPath: string,\n\t\tbase: string | undefined,\n\t\tdependsOn: Set<string>,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<string | undefined> {\n\t\tif (!base) return undefined;\n\n\t\tconst remotes = await this.getRemoteNames(repoPath, cancellation);\n\t\tif (!remotes.includes('upstream')) return undefined;\n\n\t\tconst records = await this.provider.refs.getRefs(repoPath, cancellation);\n\n\t\t// The reflog keeps a start point as typed, so a created-from base can be a full ref\n\t\tlet name = base;\n\t\tif (name.startsWith('refs/heads/')) {\n\t\t\tname = name.slice('refs/heads/'.length);\n\t\t} else {\n\t\t\tconst isRemoteRef = name.startsWith('refs/remotes/');\n\t\t\tif (isRemoteRef) {\n\t\t\t\tname = name.slice('refs/remotes/'.length);\n\t\t\t}\n\n\t\t\tif (isRemoteRef || findRefTip(records, `refs/heads/${name}`) == null) {\n\t\t\t\t// A remote name can hold a slash, so strip exactly a remote's own prefix\n\t\t\t\tconst remote = remotes.find(r => name.startsWith(`${r}/`));\n\t\t\t\tif (remote != null) {\n\t\t\t\t\tname = name.slice(remote.length + 1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst contender = `upstream/${name}`;\n\t\tconst remoteRef = `refs/remotes/${contender}`;\n\t\tif (contender === base || remoteRef === base || findRefTip(records, remoteRef) == null) return undefined;\n\n\t\tdependsOn.add(remoteRef);\n\t\treturn contender;\n\t}\n\n\t/** {@link getNearestForkTarget} with the `upstream` remote's copy of `candidate` as its contender */\n\tprivate async getUpstreamNearestForkTarget(\n\t\trepoPath: string,\n\t\tbranch: string | undefined,\n\t\tcandidate: string | undefined,\n\t\tdependsOn: Set<string>,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<{ ref: string; forkPoint: string | undefined } | undefined> {\n\t\treturn this.getNearestForkTarget(repoPath, branch, candidate, dependsOn, cancellation, {\n\t\t\tcontender: await this.getUpstreamContender(repoPath, candidate, dependsOn, cancellation),\n\t\t});\n\t}\n\n\t/**\n\t * A candidate base as the ref HEAD is measured against: the candidate or its tracking ref, whichever forked\n\t * nearer HEAD, so a stale local base defers to its upstream while one carrying unpushed work wins over it. A\n\t * `contender` other than the tracking ref is taken only when it forked strictly nearer than both, so a tie keeps\n\t * the candidate's own pick. A candidate none forks from is used as-is if it names a commit. `undefined` when the\n\t * candidate is unusable.\n\t */\n\tprivate async getNearestForkTarget(\n\t\trepoPath: string,\n\t\tbranch: string | undefined,\n\t\tcandidate: string | undefined,\n\t\tdependsOn: Set<string>,\n\t\tcancellation: AbortSignal | undefined,\n\t\toptions?: { contender?: string },\n\t): Promise<{ ref: string; forkPoint: string | undefined } | undefined> {\n\t\t// A ref starting with `-` would be parsed as a git flag\n\t\tif (!candidate || candidate.startsWith('-')) return undefined;\n\t\t// A branch measured against itself says nothing\n\t\tif (candidate === branch || candidate === `refs/heads/${branch}`) return undefined;\n\n\t\taddRefDependencies(dependsOn, candidate);\n\n\t\tconst upstreamName = this.provider.refs.getSymbolicReferenceName(\n\t\t\trepoPath,\n\t\t\t`${candidate}@{u}`,\n\t\t\tundefined,\n\t\t\tcancellation,\n\t\t);\n\t\tconst getUpstreamFork = async (): Promise<{ ref: string; mergeBase: string | undefined } | undefined> => {\n\t\t\tconst upstream = await upstreamName;\n\t\t\tif (!upstream || upstream.startsWith('-')) return undefined;\n\n\t\t\taddRefDependencies(dependsOn, upstream);\n\t\t\treturn { ref: upstream, mergeBase: await this.getForkPoint(repoPath, upstream, cancellation) };\n\t\t};\n\n\t\tconst contender = options?.contender;\n\t\tconst getContenderMergeBase = async (): Promise<string | undefined> => {\n\t\t\tif (contender == null) return undefined;\n\n\t\t\t// At the candidate's or its tracking ref's tip it can only tie, and a tie isn't the contender's\n\t\t\tconst records = await this.provider.refs.getRefs(repoPath, cancellation);\n\t\t\tconst tip = findRefTip(records, contender);\n\t\t\tif (tip != null) {\n\t\t\t\tif (tip === findRefTip(records, candidate)) return undefined;\n\n\t\t\t\tconst upstream = await upstreamName;\n\t\t\t\tif (upstream && tip === findRefTip(records, upstream)) return undefined;\n\t\t\t}\n\t\t\treturn this.getForkPoint(repoPath, contender, cancellation);\n\t\t};\n\n\t\tconst [candidateMergeBase, upstreamFork, contenderMergeBase] = await Promise.all([\n\t\t\tthis.getForkPoint(repoPath, candidate, cancellation),\n\t\t\tgetUpstreamFork(),\n\t\t\tgetContenderMergeBase(),\n\t\t]);\n\n\t\tlet nearest: { ref: string; mergeBase: string } | undefined;\n\t\tfor (const fork of [{ ref: candidate, mergeBase: candidateMergeBase }, upstreamFork]) {\n\t\t\tif (fork?.mergeBase == null) continue;\n\n\t\t\t// A later ref wins only when it forked at or past the nearest so far\n\t\t\tif (\n\t\t\t\tnearest == null ||\n\t\t\t\tnearest.mergeBase === fork.mergeBase ||\n\t\t\t\t(await this.provider.commits.isAncestorOf(repoPath, nearest.mergeBase, fork.mergeBase, cancellation))\n\t\t\t) {\n\t\t\t\tnearest = { ref: fork.ref, mergeBase: fork.mergeBase };\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tcontender != null &&\n\t\t\tcontender !== upstreamFork?.ref &&\n\t\t\tcontenderMergeBase != null &&\n\t\t\tnearest != null &&\n\t\t\tnearest.mergeBase !== contenderMergeBase &&\n\t\t\t(await this.provider.commits.isAncestorOf(repoPath, nearest.mergeBase, contenderMergeBase, cancellation))\n\t\t) {\n\t\t\tnearest = { ref: contender, mergeBase: contenderMergeBase };\n\t\t}\n\t\tif (nearest != null) return { ref: nearest.ref, forkPoint: nearest.mergeBase };\n\n\t\treturn (await this.provider.refs.validateReference(repoPath, candidate, undefined, cancellation))\n\t\t\t? { ref: candidate, forkPoint: undefined }\n\t\t\t: undefined;\n\t}\n\n\t/**\n\t * The base for a branch that is itself the default branch, with its tip: its own upstream, `upstream/<branch>`\n\t * when an `upstream` remote has it, else `<branch>@{u}`. Read from the cached ref and branch lists; only a\n\t * `<branch>` that isn't checked out spawns, for its `@{u}`. `undefined` when there is neither, or its ref is gone.\n\t */\n\tprivate async getSelfUpstreamTarget(\n\t\trepoPath: string,\n\t\tbranch: string,\n\t\tdependsOn: Set<string>,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<{ ref: string; sha: string } | undefined> {\n\t\tconst records = await this.provider.refs.getRefs(repoPath, cancellation);\n\n\t\tlet upstream: string | undefined;\n\t\tif ((await this.getRemoteNames(repoPath, cancellation)).includes('upstream')) {\n\t\t\tconst remoteRef = `refs/remotes/upstream/${branch}`;\n\t\t\tdependsOn.add(remoteRef);\n\t\t\tif ((await this.getRefTip(repoPath, records, remoteRef, cancellation)) != null) {\n\t\t\t\tupstream = `upstream/${branch}`;\n\t\t\t}\n\t\t}\n\n\t\tif (upstream == null) {\n\t\t\tlet tracking: string | undefined;\n\t\t\tconst current = await this.getBranch(repoPath, undefined, undefined, cancellation);\n\t\t\tif (current?.name === branch && !current.detached && !current.remote) {\n\t\t\t\ttracking = current.upstream?.name;\n\t\t\t\t// A gone upstream is still depended on, so the fetch or push that recreates it brings the base back\n\t\t\t\tif (tracking && current.upstream?.missing) {\n\t\t\t\t\taddRefDependencies(dependsOn, tracking);\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttracking = await this.provider.refs.getSymbolicReferenceName(\n\t\t\t\t\trepoPath,\n\t\t\t\t\t`${branch}@{u}`,\n\t\t\t\t\tundefined,\n\t\t\t\t\tcancellation,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!tracking || tracking.startsWith('-')) return undefined;\n\n\t\t\taddRefDependencies(dependsOn, tracking);\n\t\t\tupstream = tracking;\n\t\t}\n\n\t\tconst sha = await this.getRefTip(repoPath, records, upstream, cancellation);\n\t\treturn sha != null ? { ref: upstream, sha: sha } : undefined;\n\t}\n\n\t/**\n\t * {@link findRefTip} in `records`, the cached ref list. `getRefs` answers a failed enumeration with an empty list,\n\t * so an empty one is asked of git instead, rather than read as every ref being absent.\n\t */\n\tprivate async getRefTip(\n\t\trepoPath: string,\n\t\trecords: readonly RefRecord[],\n\t\tname: string,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<string | undefined> {\n\t\tif (records.length) return findRefTip(records, name);\n\n\t\treturn this.provider.refs.validateReference(repoPath, name, undefined, cancellation);\n\t}\n\n\t/** The merge base of HEAD and `ref`, preferring git's fork-point reading of `ref`'s reflog when it has one */\n\tprivate async getForkPoint(\n\t\trepoPath: string,\n\t\tref: string,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<string | undefined> {\n\t\tconst forkPoint = await this.provider.refs.getMergeBase(\n\t\t\trepoPath,\n\t\t\tref,\n\t\t\t'HEAD',\n\t\t\t{ forkPoint: true },\n\t\t\tcancellation,\n\t\t);\n\t\treturn forkPoint ?? this.provider.refs.getMergeBase(repoPath, 'HEAD', ref, undefined, cancellation);\n\t}\n\n\t/**\n\t * The stored merge target — the user's pick, else the one detected from its PR — skipping any whose branch git\n\t * confirms is gone so resolution falls through to the next source. A target that couldn't be checked is kept.\n\t * The stored keys are never rewritten here: the user pick is the user's, and Kepler shares the file.\n\t */\n\t@debug({ exit: true })\n\tasync getStoredMergeTargetBranchName(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: { detectedOnly?: boolean; priority?: GitCommandPriority },\n\t\tcancellation?: AbortSignal,\n\t): Promise<string | undefined> {\n\t\tconst priority = options?.priority;\n\n\t\tlet goneUserTarget: string | undefined;\n\t\tif (!options?.detectedOnly) {\n\t\t\tconst userTarget = await this.getStoredUserMergeTargetBranchName(repoPath, ref);\n\t\t\tif (userTarget) {\n\t\t\t\tconst resolved = await this.resolveStoredMergeTarget(repoPath, userTarget, priority, cancellation);\n\t\t\t\tif (resolved) return resolved;\n\n\t\t\t\tgoneUserTarget = userTarget;\n\t\t\t}\n\t\t}\n\n\t\tconst detectedTarget = await this.getStoredDetectedMergeTargetBranchName(repoPath, ref);\n\t\tif (!detectedTarget || detectedTarget === goneUserTarget) return undefined;\n\n\t\treturn this.resolveStoredMergeTarget(repoPath, detectedTarget, priority, cancellation);\n\t}\n\n\tprivate async resolveStoredMergeTarget(\n\t\trepoPath: string,\n\t\ttarget: string,\n\t\tpriority: GitCommandPriority | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<string | undefined> {\n\t\tconst { name, missing } = await this.provider.refs.getSymbolicReferenceNameOrMissing(\n\t\t\trepoPath,\n\t\t\ttarget,\n\t\t\tpriority != null ? { priority: priority } : undefined,\n\t\t\tcancellation,\n\t\t);\n\t\treturn missing ? undefined : name || target;\n\t}\n\n\t@debug({ exit: true })\n\tasync getStoredDetectedMergeTargetBranchName(repoPath: string, ref: string): Promise<string | undefined> {\n\t\tconst target =\n\t\t\t(await this.provider.config.getGkConfig(repoPath, `branch.${ref}.gk-merge-target`)) ??\n\t\t\t(await this.provider.config.getGkConfig(repoPath, `branch.${ref}.gk-target-base`)); // legacy key\n\t\treturn target?.trim() || undefined;\n\t}\n\n\t@debug()\n\tasync getStoredUserMergeTargetBranchName(repoPath: string, ref: string): Promise<string | undefined> {\n\t\tconst target = await this.provider.config.getGkConfig(repoPath, `branch.${ref}.gk-merge-target-user`);\n\t\treturn target?.trim() || undefined;\n\t}\n\n\t@trace()\n\tonCurrentBranchAccessed(repoPath: string): Promise<void> {\n\t\treturn this.recordBranchActivity(repoPath, ['gk-last-accessed']);\n\t}\n\n\t// Called on every working-tree change, and writes at most once per 5 minutes per stamp\n\t@trace()\n\tonCurrentBranchModified(repoPath: string): Promise<void> {\n\t\treturn this.recordBranchActivity(repoPath, ['gk-last-accessed', 'gk-last-modified']);\n\t}\n\n\t@trace()\n\tonCurrentBranchAgentActivity(repoPath: string): Promise<void> {\n\t\treturn this.recordBranchActivity(repoPath, ['gk-agent-last-activity']);\n\t}\n\n\tprivate getBranchActivityKey(repoPath: string, name: string): string {\n\t\treturn `${this.cache.getCommonPath(repoPath)}\\0${name}`;\n\t}\n\n\tprivate forgetBranchCreatedFrom(repoPath: string, name: string): void {\n\t\tconst key = this.getBranchActivityKey(repoPath, name);\n\t\tthis._branchCreatedFrom.delete(key);\n\t\tthis._branchCreatedFromGenerations.set(key, (this._branchCreatedFromGenerations.get(key) ?? 0) + 1);\n\t}\n\n\t/** Forgets this process's throttle marks for `name`, so its next activity re-reads the stored stamps */\n\tprivate clearBranchActivityStamps(repoPath: string, name: string): void {\n\t\tconst branchKey = this.getBranchActivityKey(repoPath, name);\n\t\tfor (const key of branchActivityKeys) {\n\t\t\tthis._branchActivityStamps.delete(`${branchKey}\\0${key}`);\n\t\t}\n\t}\n\n\t/** Never rejects — activity stamps are bookkeeping and callers fire them without a catch */\n\tprivate async recordBranchActivity(repoPath: string, keys: readonly BranchActivityKey[]): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst branch = await this.getBranch(repoPath);\n\t\t\tif (branch == null || branch.remote || branch.detached) return;\n\n\t\t\tconst branchKey = this.getBranchActivityKey(repoPath, branch.name);\n\t\t\tawait this._branchActivityCalls.run(branchKey, undefined, async () => {\n\t\t\t\tconst now = Date.now();\n\n\t\t\t\t// Kept if the write fails, so a failing write is retried after 5 minutes rather than on every call\n\t\t\t\tconst due: BranchActivityKey[] = [];\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\tconst stampKey = `${branchKey}\\0${key}`;\n\t\t\t\t\tconst last = this._branchActivityStamps.get(stampKey);\n\t\t\t\t\tif (last != null && now - last < dateMetadataStaleThresholdMs) continue;\n\n\t\t\t\t\tthis._branchActivityStamps.set(stampKey, now);\n\t\t\t\t\tdue.push(key);\n\t\t\t\t}\n\t\t\t\tif (!due.length) return;\n\n\t\t\t\t// Every due key is read before any is written: a write drops the cached gk config, so a read after it\n\t\t\t\t// would re-read the whole file\n\t\t\t\tconst stored = await Promise.allSettled(\n\t\t\t\t\tdue.map(key => this.provider.config.getGkConfig(repoPath, `branch.${branch.name}.${key}`)),\n\t\t\t\t);\n\n\t\t\t\tconst value = new Date(now).toISOString();\n\t\t\t\tfor (const [i, key] of due.entries()) {\n\t\t\t\t\t// Another process sharing the file stamped it under 5 minutes ago: hold off until that stamp goes\n\t\t\t\t\t// stale, not for 5 minutes from now\n\t\t\t\t\tconst stamp = getSettledValue(stored[i]);\n\t\t\t\t\tconst last = stamp != null ? new Date(stamp).getTime() : NaN;\n\t\t\t\t\tif (now - last < dateMetadataStaleThresholdMs) {\n\t\t\t\t\t\tthis._branchActivityStamps.set(`${branchKey}\\0${key}`, last);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tawait this.provider.config.setGkConfig(repoPath, `branch.${branch.name}.${key}`, value);\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, `Failed to record branch activity (${keys.join(', ')})`);\n\t\t}\n\t}\n\n\t@debug()\n\tasync renameBranch(repoPath: string, oldName: string, newName: string): Promise<void> {\n\t\tconst args = ['branch', '-m', oldName, newName];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t\t// The branch keeps its identity across a rename, so move its stored gk metadata with it —\n\t\t\t// otherwise the new name re-derives a base it already had, and the old name is left holding\n\t\t\t// metadata for a branch that no longer exists under it.\n\t\t\tawait this.provider.config.renameGkConfigBranchSection(repoPath, oldName, newName);\n\t\t\t// Old name's entry is now orphaned; the new name must not inherit a predecessor's base\n\t\t\tthis.cache.deleteBaseBranchName(repoPath, oldName);\n\t\t\tthis.cache.deleteBaseBranchName(repoPath, newName);\n\t\t\tthis.clearBranchActivityStamps(repoPath, oldName);\n\t\t\tthis.clearBranchActivityStamps(repoPath, newName);\n\t\t\tthis.forgetBranchCreatedFrom(repoPath, oldName);\n\t\t\tthis.forgetBranchCreatedFrom(repoPath, newName);\n\t\t} catch (ex) {\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'branch',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew BranchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\taction: 'rename',\n\t\t\t\t\t\t\tbranch: oldName,\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,\n\t\t\t\t\t),\n\t\t\t);\n\t\t} finally {\n\t\t\t// `git branch -m` can rename the ref and still fail on its config\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['config', 'heads']);\n\t\t}\n\t}\n\n\t@debug()\n\tasync setUpstreamBranch(repoPath: string, name: string, upstream: string | undefined): Promise<void> {\n\t\tconst args =\n\t\t\tupstream == null ? ['branch', '--unset-upstream', name] : ['branch', '--set-upstream-to', upstream, name];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t} catch (ex) {\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'branch',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew BranchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\taction: upstream == null ? 'unset upstream of' : `set upstream to '${upstream}' for`,\n\t\t\t\t\t\t\tbranch: name,\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,\n\t\t\t\t\t),\n\t\t\t);\n\t\t} finally {\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['config', 'heads']);\n\t\t}\n\t}\n\n\t@debug()\n\tasync storeBaseBranchName(\n\t\trepoPath: string,\n\t\tref: string,\n\t\tbase: string,\n\t\toptions?: { skipInvalidation?: readonly GkConfigInvalidationTarget[] },\n\t): Promise<void> {\n\t\tawait this.provider.config.setGkConfig(repoPath, `branch.${ref}.gk-merge-base`, base, options);\n\t}\n\n\t@debug()\n\tasync storeMergeTargetBranchName(\n\t\trepoPath: string,\n\t\tref: string,\n\t\ttarget: string,\n\t\toptions?: { skipInvalidation?: readonly GkConfigInvalidationTarget[] },\n\t): Promise<void> {\n\t\t// An unchanged value isn't rewritten: the write would churn the file Kepler shares and drop the cached gk config\n\t\tif ((await this.provider.config.getGkConfig(repoPath, `branch.${ref}.gk-merge-target`)) === target) return;\n\n\t\tawait this.provider.config.setGkConfig(repoPath, `branch.${ref}.gk-merge-target`, target, options);\n\t}\n\n\t@debug()\n\tasync storeUserMergeTargetBranchName(repoPath: string, ref: string, target: string | undefined): Promise<void> {\n\t\tawait this.provider.config.setGkConfig(repoPath, `branch.${ref}.gk-merge-target-user`, target);\n\t}\n\n\t/**\n\t * Gets all branch metadata (dates and disposition) from git config in a single batch operation.\n\t * @returns A map of branch name to metadata.\n\t */\n\tprivate getBranchMetadataMap(repoPath: string): Promise<Map<string, BranchMetadata>> {\n\t\treturn this.cache.getBranchMetadataMap(repoPath, async commonPath => {\n\t\t\tconst scope = getScopedLogger();\n\t\t\tconst metadataMap = new Map<string, BranchMetadata>();\n\n\t\t\ttry {\n\t\t\t\t// Use git config --get-regexp to load all gk-* branch metadata in one call\n\t\t\t\tconst configMap = await this.provider.config.getGkConfigRegex(\n\t\t\t\t\tcommonPath,\n\t\t\t\t\t'^branch\\\\..*\\\\.gk-(last-(accessed|modified)|disposition|agent-last-activity)$',\n\t\t\t\t);\n\t\t\t\tif (!configMap.size) return metadataMap;\n\n\t\t\t\tfor (const [key, value] of configMap) {\n\t\t\t\t\tconst parsed = parseBranchMetadataGkConfigKey(key);\n\t\t\t\t\tif (parsed == null) continue;\n\n\t\t\t\t\tlet metadata = metadataMap.get(parsed.branch);\n\t\t\t\t\tif (metadata == null) {\n\t\t\t\t\t\tmetadata = {};\n\t\t\t\t\t\tmetadataMap.set(parsed.branch, metadata);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Shared with `Cache.patchBranchMetadata`, so a patched object matches a freshly read one\n\t\t\t\t\tsetBranchMetadataValue(metadata, parsed.key, value);\n\t\t\t\t}\n\t\t\t} catch (ex) {\n\t\t\t\tdebugger;\n\t\t\t\tscope?.error(ex);\n\t\t\t}\n\n\t\t\treturn metadataMap;\n\t\t});\n\t}\n\n\tasync setBranchDisposition(\n\t\trepoPath: string,\n\t\tbranchName: string,\n\t\tdisposition: BranchDisposition | undefined,\n\t): Promise<void> {\n\t\tawait this.provider.config.setGkConfig(repoPath, `branch.${branchName}.gk-disposition`, disposition);\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['starred']);\n\t}\n}\n\n/** Each ref list {@link findRefTip} searched, by full name: one base read looks up many names in the same cached list */\nconst refRecordsByName = new WeakMap<readonly RefRecord[], Map<string, RefRecord>>();\n\n/**\n * The commit `name` resolves to among `records`, tried in git's own order for a short name (`refs/tags/` before\n * `refs/heads/` before `refs/remotes/`); annotated tags peel to their commit. `undefined` when no listed ref matches.\n */\nfunction findRefTip(records: readonly RefRecord[], name: string): string | undefined {\n\tlet byName = refRecordsByName.get(records);\n\tif (byName == null) {\n\t\tbyName = new Map();\n\t\tfor (const record of records) {\n\t\t\tif (!byName.has(record.name)) {\n\t\t\t\tbyName.set(record.name, record);\n\t\t\t}\n\t\t}\n\t\trefRecordsByName.set(records, byName);\n\t}\n\n\tfor (const candidate of [\n\t\tname,\n\t\t`refs/${name}`,\n\t\t`refs/tags/${name}`,\n\t\t`refs/heads/${name}`,\n\t\t`refs/remotes/${name}`,\n\t\t`refs/remotes/${name}/HEAD`,\n\t]) {\n\t\tconst record = byName.get(candidate);\n\t\tif (record != null) return record.peeledObjectname || record.objectname;\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Adds the full ref names a `.git/refs` watcher would report for `name`. A short name can't be told tag from local\n * from remote without a spawn, so it adds every form, including the tag git resolves it to first; a spurious one\n * only costs a recompute.\n */\nfunction addRefDependencies(dependsOn: Set<string>, name: string): void {\n\tif (name.startsWith('refs/')) {\n\t\tdependsOn.add(name);\n\t\treturn;\n\t}\n\n\tdependsOn.add(`refs/tags/${name}`);\n\tdependsOn.add(`refs/heads/${name}`);\n\tdependsOn.add(`refs/remotes/${name}`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,MAAM,+BAA+B;;;;;AAMrC,MAAM,+BAA+B;CACpC,SAAS,CAAC,MAAM,8BAA8B;CAC9C,KAAK;EACJ,qBAAqB;EACrB,aAAa;EACb,aAAa;EACb,qBAAqB;EACrB,iBAAiB;CAClB;CACA,SAAS;AACV;AAEA,MAAM,qBAAqB;CAAC;CAAoB;CAAoB;AAAwB;AAG5F,IAAa,yBAAb,MAAsE;CAoBnD;CACA;CACA;CACA;;CArBlB,mBAAoC,IAAI,OAAkD,IAAI;;;;;CAK9F,wBAAyC,IAAI,OAAuB,IAAI;;CAExE,uBAAwC,IAAI,eAAe;;;;;;CAM3D,qBAAsC,IAAI,OAAmC,IAAI;;CAEjF,gCAAiD,IAAI,OAAuB,IAAI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