@gitkraken/core-gitlens 0.16.2 → 0.16.3
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 +9 -1
- package/dist/git/watching/classifyChange.js +5 -2
- package/dist/git/watching/classifyChange.js.map +1 -1
- package/dist/git/watching/watchGroup.js +2 -1
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git-cli/providers/branches.d.ts +33 -9
- package/dist/git-cli/providers/branches.js +124 -41
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/package.json +1 -1
|
@@ -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\tAheadOfBaseTier,\n\tBranchContributionsOverview,\n\tGitBranchesSubProvider,\n\tGitBranchMergedStatus,\n\tGitPushTarget,\n\tGitPushTargetRef,\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\tsplitRemoteBranchName,\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 { joinUriPath } from '@gitlens/utils/uri.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 { readHeadState } from '../exec/headState.js';\nimport { KeyedSequencer } from '../exec/indexLock.js';\nimport type { GitMergeConflict } from '../parsers/mergeTreeParser.js';\nimport { parseMergeTreeConflict } from '../parsers/mergeTreeParser.js';\nimport { resolveBranchRemote } from './branchRemote.js';\nimport { isGitBooleanFalse } from './config.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\n/**\n * The most commits a base's reflog may reach off its new tip's history for a re-measure: every worktree's count\n * excludes each of them on its command line, and more come only from a long history force-pushed away, where a full\n * read costs less\n */\nconst maxOffHistoryCommits = 64;\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 * For a base that moved only forward, the commits its reflog reaches off the new tip's history (else `false`), by\n\t * `<ref>\\0<oldSha>\\0<newSha>`, for each cached ref list it was read against: a ref write replaces that list, along\n\t * with the reflog the answer came from. `undefined` when git couldn't say, which isn't kept. A fetch moves one base\n\t * under every worktree at once, so they share the one check, joining it while it runs\n\t */\n\tprivate readonly baseMovedForward = new WeakMap<\n\t\treadonly RefRecord[],\n\t\tMap<string, Promise<readonly string[] | false | undefined>>\n\t>();\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\t/**\n\t * The repositories (by common path) whose last config listing showed config that can differ by checkout, so a linked\n\t * checkout reads its own listing without first waiting on the main checkout's. Only a shortcut: a listing that shows\n\t * otherwise drops the repository again\n\t */\n\tprivate readonly _configDiffersByCheckout = new Set<string>();\n\n\tconstructor(\n\t\tprivate readonly context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t) {}\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\t// Without `%(upstream:remotename)` (git < 2.23) a remote whose own name contains a `/` can't be\n\t\t\t\t// told from the upstream's short name alone, so read the remote names once, only if needed\n\t\t\t\tlet remoteNames: Promise<string[]> | undefined;\n\t\t\t\tconst resolveUpstreamRemote = async (upstream: string): Promise<string | undefined> => {\n\t\t\t\t\tif (!upstream.startsWith('refs/remotes/')) return undefined;\n\n\t\t\t\t\tconst { name } = parseRefName(upstream);\n\t\t\t\t\tif (!name.includes('/', name.indexOf('/') + 1)) return undefined;\n\n\t\t\t\t\tremoteNames ??= this.provider.remotes.getRemotes(commonPath, undefined, signal).then(\n\t\t\t\t\t\tremotes => {\n\t\t\t\t\t\t\t// `getRemotes` answers a failed read as no remotes, which leaves only the first-segment split\n\t\t\t\t\t\t\tif (!remotes.length) {\n\t\t\t\t\t\t\t\tcacheable?.invalidate();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn remotes.map(r => r.name);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t(ex: unknown) => {\n\t\t\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\t\t\t\t// Fall back to the first-segment split, but don't cache a list read without the remotes\n\t\t\t\t\t\t\tcacheable?.invalidate();\n\t\t\t\t\t\t\treturn [];\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\treturn splitRemoteBranchName(name, await remoteNames)?.[0];\n\t\t\t\t};\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(\n\t\t\t\t\t\trecord.upstream,\n\t\t\t\t\t\trecord.upstreamTracking,\n\t\t\t\t\t\trecord.upstreamRemote ??\n\t\t\t\t\t\t\t(!worktreePathSupported ? await resolveUpstreamRemote(record.upstream) : undefined),\n\t\t\t\t\t\trecord.upstreamRemoteRef,\n\t\t\t\t\t);\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? {\n\t\t\t\t\t\t\t\t\t\tname: branch.upstream.name,\n\t\t\t\t\t\t\t\t\t\tmissing: branch.upstream.missing,\n\t\t\t\t\t\t\t\t\t\tremote: branch.upstream.remote,\n\t\t\t\t\t\t\t\t\t\tremoteBranch: branch.upstream.remoteBranch,\n\t\t\t\t\t\t\t\t\t\tlocal: branch.upstream.local,\n\t\t\t\t\t\t\t\t\t}\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 { remote: remoteName } = await resolveBranchRemote(\n\t\t\t\t\t\tthis.provider,\n\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\tbranch,\n\t\t\t\t\t\tcancellation,\n\t\t\t\t\t);\n\n\t\t\t\t\t// A branch with no remote upstream has no remote to find the PR's base on\n\t\t\t\t\tif (remoteName != null) {\n\t\t\t\t\t\tconst prTarget = `${remoteName}/${pr.refs.base.branch}`;\n\t\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\t// so a confirmed-gone base is skipped like a stored target.\n\t\t\t\t\t\tconst { missing } = await this.provider.refs.getSymbolicReferenceNameOrMissing(\n\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\tprTarget,\n\t\t\t\t\t\t\tpriorityOpts,\n\t\t\t\t\t\t\tcancellation,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (!missing) {\n\t\t\t\t\t\t\tmergeTarget = prTarget;\n\n\t\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\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\t// layer's branch can linger (an unpruned remote-tracking ref, or a repo that keeps merged\n\t\t\t\t\t\t\t// branches). Use it for this lookup, but don't persist it.\n\t\t\t\t\t\t\tif (pr.stack == null) {\n\t\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\t// `branchOverviews` invalidation that the write would otherwise trigger: we're\n\t\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\t// it would just force the next caller to redo the body. (gk-merge-target writes\n\t\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\t\tvoid this.storeMergeTargetBranchName(repoPath, ref, prTarget, {\n\t\t\t\t\t\t\t\t\tskipInvalidation: ['branchOverviews'],\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}\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\t// `upstream` is the full ref (`refs/heads/…` or `refs/remotes/…`) so a local upstream\n\t\t\t\t// can't be mistaken for a remote's branch of the same short name\n\t\t\t\tlet data:\n\t\t\t\t\t| { name: string; upstream?: string; remote?: string; remoteRef?: string; sha?: string }\n\t\t\t\t\t| 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'--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 = parseSymbolicFullNames(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.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 = parseSymbolicFullNames(ex.stdout);\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 = { name: result.stdout.trim() };\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\tname: symbolicRef.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};\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 = { name: defaultBranch };\n\t\t\t\t\t\t\t\tif (remote && remoteBranch) {\n\t\t\t\t\t\t\t\t\tdata.upstream =\n\t\t\t\t\t\t\t\t\t\tremote === '.'\n\t\t\t\t\t\t\t\t\t\t\t? `refs/heads/${remoteBranch}`\n\t\t\t\t\t\t\t\t\t\t\t: `refs/remotes/${remote}/${remoteBranch}`;\n\t\t\t\t\t\t\t\t\tdata.remote = remote;\n\t\t\t\t\t\t\t\t\tdata.remoteRef = merge;\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 = { name: `(HEAD detached at ${shortenRevision(sha)})`, 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 } = data;\n\n\t\t\t\tlet { remote, remoteRef } = data;\n\t\t\t\tif (data.upstream?.startsWith('refs/heads/') && remote == null) {\n\t\t\t\t\t// Git reports no remote here, but a custom fetch refspec can put a remote's branches under\n\t\t\t\t\t// `refs/heads/`, so ask the config whether this upstream is really a remote's\n\t\t\t\t\t[remote, remoteRef] = await Promise.all([\n\t\t\t\t\t\tthis.provider.config.getConfig(repoPath, `branch.${name}.remote`),\n\t\t\t\t\t\tthis.provider.config.getConfig(repoPath, `branch.${name}.merge`),\n\t\t\t\t\t]);\n\t\t\t\t}\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: data.upstream ? parseUpstream(data.upstream, '', remote, remoteRef) : undefined,\n\t\t\t\t\tsha: data.sha,\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\t// Tracking is written to the new branch's own config section, and nowhere else\n\t\t\tif (mayWriteTracking(ref, options?.noTracking)) {\n\t\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['config', 'heads'], [`refs/heads/${name}`], {\n\t\t\t\t\tconfigConfinedToRefs: true,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['heads'], [`refs/heads/${name}`]);\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\t// A delete drops the branches' own config sections, and nothing else\n\t\t\tthis.context.hooks?.repository?.onChanged?.(\n\t\t\t\trepoPath,\n\t\t\t\t['config', 'heads'],\n\t\t\t\tbranches.map(b => `refs/heads/${b}`),\n\t\t\t\t{ configConfinedToRefs: true },\n\t\t\t);\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 deleted = 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 (deleted.length) {\n\t\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\t\t// Names only the branches that went: the watcher takes a report of a named ref for the write's own,\n\t\t\t\t// so naming one that stayed would pass off an outside change to it as this delete's\n\t\t\t\tthis.context.hooks?.repository?.onChanged?.(\n\t\t\t\t\trepoPath,\n\t\t\t\t\t['config', 'heads'],\n\t\t\t\t\tdeleted.map(b => `refs/heads/${b}`),\n\t\t\t\t\t{ configConfinedToRefs: true },\n\t\t\t\t);\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 those of `names` confirmed gone; none when the probe couldn't answer, so a spurious\n\t * notification is never fired on an unrelated failure.\n\t */\n\tprivate async cleanupDeletedBranchMetadata(repoPath: string, names: string[]): Promise<string[]> {\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 [];\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\tconst deleted: string[] = [];\n\t\t\tfor (const name of names) {\n\t\t\t\tif (surviving.has(name)) continue;\n\n\t\t\t\tdeleted.push(name);\n\t\t\t\tawait this.forgetDeletedBranch(repoPath, name);\n\t\t\t}\n\n\t\t\treturn deleted;\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 [];\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@trace({ exit: true })\n\tasync getPushTarget(repoPath: string, branch?: string, cancellation?: AbortSignal): Promise<GitPushTarget> {\n\t\tconst records = await this.provider.refs.getRefs(repoPath, cancellation);\n\t\t// `getRefs` answers a failed enumeration with an empty list, which says nothing about any branch\n\t\tif (!records.length) return { known: false };\n\n\t\tif (branch == null) {\n\t\t\t// The worktree's own HEAD file names its branch with no git process, and is as current as the file. What\n\t\t\t// it can't answer (a reftable repository, a branch that is a symbolic ref to another, or a HEAD kept as a\n\t\t\t// symlink to its branch) falls back to resolving the reference\n\t\t\tconst head = await readHeadState(repoPath, this.context.fs, this.cache);\n\t\t\tif (head === 'detached') return { known: true, push: undefined, upstream: undefined };\n\n\t\t\tif (head != null) {\n\t\t\t\tbranch = head.branch;\n\t\t\t} else {\n\t\t\t\tconst current = await this.getCurrentBranchReference(repoPath, cancellation);\n\t\t\t\tif (current == null) return { known: false };\n\t\t\t\tif (current.remote || isDetachedHead(current.name)) {\n\t\t\t\t\treturn { known: true, push: undefined, upstream: undefined };\n\t\t\t\t}\n\n\t\t\t\tbranch = current.name;\n\t\t\t}\n\t\t}\n\n\t\tconst record = findRefRecord(records, branch.startsWith('refs/heads/') ? branch : `refs/heads/${branch}`);\n\t\treturn {\n\t\t\tknown: true,\n\t\t\tpush: record?.push ? toPushTargetRef(records, record.push) : undefined,\n\t\t\tupstream: record?.upstream ? toPushTargetRef(records, record.upstream) : undefined,\n\t\t};\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.getUpstreamName(repoPath, createdFrom, priorityOpts, cancellation);\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.getUpstreamName(repoPath, name, priorityOpts, cancellation);\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@trace()\n\tgetAheadOfBaseConfigKey(repoPath: string, cancellation?: AbortSignal): Promise<string | undefined> {\n\t\treturn this.getAheadOfBaseConfigListing(repoPath, cancellation);\n\t}\n\n\t@trace()\n\tasync getAheadOfBaseConfigEntries(\n\t\trepoPath: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<readonly (readonly [key: string, value: string | undefined])[] | undefined> {\n\t\tconst listing = await this.getAheadOfBaseConfigListing(repoPath, cancellation);\n\t\treturn listing != null ? parseConfigListing(listing) : undefined;\n\t}\n\n\t/**\n\t * A checkout's listing of the config inputs to {@link getAheadOfBase}. Every checkout of a repository shares the main\n\t * checkout's, unless it shows config that can differ by checkout (see `mayConfigDifferByCheckout`); then\n\t * each linked checkout reads its own, and keeps doing so until one of its own reads shows config no longer can.\n\t */\n\tprivate getAheadOfBaseConfigListing(\n\t\trepoPath: string,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<string | undefined> {\n\t\treturn this.cache.getAheadOfBaseConfigKey(\n\t\t\trepoPath,\n\t\t\tasync (checkoutPath, cacheable, signal) => {\n\t\t\t\tconst commonPath = this.cache.getCommonPath(checkoutPath);\n\t\t\t\tconst isMain = checkoutPath === commonPath;\n\t\t\t\tif (isMain || !this._configDiffersByCheckout.has(commonPath)) {\n\t\t\t\t\tconst shared = await this.cache.getAheadOfBaseConfigListing(\n\t\t\t\t\t\tcheckoutPath,\n\t\t\t\t\t\t(path, sharedCacheable, sharedSignal) =>\n\t\t\t\t\t\t\tthis.readAheadOfBaseConfigListing(path, sharedCacheable, sharedSignal),\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t);\n\t\t\t\t\t// Read in the main checkout, so it is that checkout's own\n\t\t\t\t\tif (isMain) {\n\t\t\t\t\t\tif (shared == null) {\n\t\t\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn shared;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (shared != null) {\n\t\t\t\t\t\tif (!mayConfigDifferByCheckout(shared)) return shared;\n\n\t\t\t\t\t\tthis._configDiffersByCheckout.add(commonPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst own = await this.readAheadOfBaseConfigListing(checkoutPath, cacheable, signal);\n\t\t\t\tif (own != null && !mayConfigDifferByCheckout(own)) {\n\t\t\t\t\tthis._configDiffersByCheckout.delete(commonPath);\n\t\t\t\t}\n\t\t\t\treturn own;\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate async readAheadOfBaseConfigListing(\n\t\tcwd: string,\n\t\tcacheable: CacheController,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<string | undefined> {\n\t\t// Include every branch's tracking mapping: a recorded candidate can resolve through its own upstream.\n\t\t// Preserve repeated values and order, since multiple fetch refspecs can change that resolution. Conditional\n\t\t// includes and `extensions.worktreeConfig` tell whether one checkout's listing holds for the others.\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: cwd, cancellation: cancellation, expectedExitCodes: [1] },\n\t\t\t'config',\n\t\t\t'--null',\n\t\t\t'--get-regexp',\n\t\t\t'^(branch\\\\..*\\\\.(remote|merge)|remote\\\\..*|init\\\\.defaultbranch|includeif\\\\..*|extensions\\\\.worktreeconfig)$',\n\t\t);\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tif (result.completion.status !== 'exited') {\n\t\t\tcacheable.invalidate();\n\t\t\treturn undefined;\n\t\t}\n\t\treturn result.stdout;\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@debug({ exit: true })\n\tasync getAheadOfBaseAfterBaseMove(\n\t\trepoPath: string,\n\t\tbranch: string | undefined,\n\t\tprevious: {\n\t\t\treadonly head: string;\n\t\t\treadonly base: NonNullable<AheadOfBase['base']>;\n\t\t\treadonly dependsOn: readonly string[];\n\t\t\treadonly defaultBranch?: string | null;\n\t\t},\n\t\tmoved: readonly string[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<AheadOfBase | undefined> {\n\t\tconst { head, base } = previous;\n\t\tconst oldTip = base.sha;\n\t\tif (oldTip == null || !moved.length) return undefined;\n\t\t// A preferred target comes only from an option this re-measure doesn't take. And the default branch takes an\n\t\t// upstream HEAD already contains as its own fork point, which no longer holds once the upstream moves past\n\t\t// HEAD's history; a fresh read then asks git for the fork point instead.\n\t\tif (base.tier === 'preferred' || (base.tier === 'upstream' && base.forkPoint === oldTip)) return undefined;\n\n\t\ttry {\n\t\t\tconst records = await this.provider.refs.getRefs(repoPath, cancellation);\n\t\t\tconst record = records.length ? resolveRefRecord(records, base.ref) : undefined;\n\t\t\tif (record == null || !moved.includes(record.name)) return undefined;\n\t\t\t// A name more than one listed ref answers to may now resolve to another ref than the one measured (a tag\n\t\t\t// created over a branch's name), and `--fork-point` refuses it outright, falling back to the merge base\n\t\t\tif (isAmbiguousRefName(records, base.ref)) return undefined;\n\n\t\t\tconst newTip = record.peeledObjectname || record.objectname;\n\t\t\t// Back at the old tip, a move in between may still have left the reflog `--fork-point` reads changed\n\t\t\tif (!newTip || newTip === oldTip) return undefined;\n\t\t\tif (branch != null && !isDetachedHead(branch) && findRefTip(records, `refs/heads/${branch}`) !== head) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tlet remoteHeadMoved = false;\n\t\t\tfor (const ref of moved) {\n\t\t\t\tif (ref === record.name) continue;\n\t\t\t\t// A fetch lists a remote's `HEAD` along with the branch it points at; pointing anywhere else, it was\n\t\t\t\t// retargeted, which can change the default branch. The listed tip corroborates the cached symref.\n\t\t\t\tif (\n\t\t\t\t\tfindRefTip(records, ref) !== newTip ||\n\t\t\t\t\t!(await this.isRemoteHeadOf(repoPath, ref, record.name, cancellation))\n\t\t\t\t) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tremoteHeadMoved = true;\n\t\t\t}\n\t\t\t// One retargeted onto the base (from `origin/release` to `origin/main`, say) points at it just the same, but\n\t\t\t// can make another branch the default, and one retargeted to a ref at the same commit isn't named at all, so\n\t\t\t// whenever the previous read consulted the default it is resolved again, from the cached refs and symrefs, and\n\t\t\t// must be the one that read resolved\n\t\t\tif (remoteHeadMoved && previous.defaultBranch === undefined) return undefined;\n\t\t\tif (previous.defaultBranch !== undefined) {\n\t\t\t\tconst defaultBranch = await this.getLocalDefaultBranchName(repoPath, new Set(), cancellation);\n\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\t\t\t\tif ((defaultBranch ?? null) !== previous.defaultBranch) return undefined;\n\t\t\t}\n\n\t\t\t// The `upstream` remote's copy of a base is measured against it only while their tips differ, so a ref at\n\t\t\t// the old or the new tip may now be compared where it wasn't, or the other way round\n\t\t\tif (previous.dependsOn.some(r => r.startsWith('refs/remotes/upstream/') && !r.endsWith('/HEAD'))) {\n\t\t\t\tfor (const ref of previous.dependsOn) {\n\t\t\t\t\tif (ref === record.name || ref.endsWith('/HEAD')) continue;\n\n\t\t\t\t\tconst tip = findRefTip(records, ref);\n\t\t\t\t\tif (tip === oldTip || tip === newTip) return undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// The reasoning below compares counts taken over one history. A shallow fetch cuts the history the previous\n\t\t\t// answer counted (or a deepening one extends it), so the same commits count differently, and git's fork\n\t\t\t// point can change with them; in a shallow repository it's read in full\n\t\t\tif ((await this.isShallowRepository(repoPath)) !== false) return undefined;\n\n\t\t\tconst offHistory = await this.getMovedForward(repoPath, records, record.name, oldTip, newTip);\n\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\t\t\tif (!offHistory) return undefined;\n\n\t\t\t// HEAD's commits the new tip lacks are a subset of those the old one lacked, so the previous count, taken\n\t\t\t// past the new tip, the previous fork point and the commits the reflog reaches off the new tip's history,\n\t\t\t// means the same commits, none of them reachable from that fork point or the reflog: none reached the base,\n\t\t\t// and HEAD shares no more history with the base's whole reflog than with its tip, so its merge base and its\n\t\t\t// `--fork-point` are one commit, which didn't move. The fork point is that commit too, being in the new tip's\n\t\t\t// history, where a fork point the reflog supplied (a commit of HEAD's the base once held, its entry expired\n\t\t\t// since) isn't.\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'ignore' },\n\t\t\t\t'rev-list',\n\t\t\t\t'--count',\n\t\t\t\thead,\n\t\t\t\t'--not',\n\t\t\t\tnewTip,\n\t\t\t\t...(base.forkPoint != null ? [base.forkPoint] : []),\n\t\t\t\t...offHistory,\n\t\t\t\t'--',\n\t\t\t);\n\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\t\t\tif (result.completion.status !== 'exited' || result.exitCode !== 0) return undefined;\n\t\t\tif (parseInt(result.stdout.trim(), 10) !== base.ahead) return undefined;\n\n\t\t\treturn withDefaultBranch(\n\t\t\t\t{ base: { ...base, sha: newTip }, dependsOn: [...previous.dependsOn] },\n\t\t\t\tprevious.defaultBranch,\n\t\t\t);\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/**\n\t * Whether the repository is shallow, by its common git directory's `shallow` file, which spawns nothing; `undefined`\n\t * when it can't be read\n\t */\n\tprivate async isShallowRepository(repoPath: string): Promise<boolean | undefined> {\n\t\ttry {\n\t\t\tconst gitDir = await this.provider.config.getGitDir(repoPath);\n\t\t\treturn (await this.context.fs.stat(joinUriPath(gitDir.commonUri ?? gitDir.uri, 'shallow'))) != null;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/** Whether `ref` is a `refs/remotes/<remote>/HEAD` symref pointing at `target`, from the cached local symref */\n\tprivate async isRemoteHeadOf(\n\t\trepoPath: string,\n\t\tref: string,\n\t\ttarget: string,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<boolean> {\n\t\tif (!ref.startsWith('refs/remotes/') || !ref.endsWith('/HEAD')) return false;\n\n\t\tconst remote = ref.slice('refs/remotes/'.length, -'/HEAD'.length);\n\t\tif (!remote) return false;\n\n\t\tconst symref = await this.getDefaultBranchName(repoPath, remote, { local: true }, cancellation);\n\t\treturn symref != null && `refs/remotes/${symref}` === target;\n\t}\n\n\t/**\n\t * For `ref` (a full name in `records`, the cached ref list) moving from `oldTip` to `newTip`, the commits its reflog\n\t * reaches off `newTip`'s history when it moved only forward: `oldTip` and every value its reflog took after it are in\n\t * `newTip`'s history. `--fork-point` reads every reflog entry, so one in between that shares more of HEAD's history\n\t * than `newTip` does (a branch's commit that landed and was force-pushed away) moves the fork point while the count\n\t * stands; an older one off `newTip`'s history may hold such a commit too, which each worktree's count checks for.\n\t * Without a reflog it reads only the tip. `undefined` when it didn't move only forward, or git can't say.\n\t */\n\tprivate async getMovedForward(\n\t\trepoPath: string,\n\t\trecords: readonly RefRecord[],\n\t\tref: string,\n\t\toldTip: string,\n\t\tnewTip: string,\n\t): Promise<readonly string[] | undefined> {\n\t\tlet checks = this.baseMovedForward.get(records);\n\t\tif (checks == null) {\n\t\t\tchecks = new Map();\n\t\t\tthis.baseMovedForward.set(records, checks);\n\t\t}\n\n\t\tconst key = `${ref}\\0${oldTip}\\0${newTip}`;\n\t\tlet check = checks.get(key);\n\t\tif (check == null) {\n\t\t\tcheck = this.readMovedForward(this.cache.getCommonPath(repoPath), ref, oldTip, newTip);\n\t\t\tchecks.set(key, check);\n\t\t}\n\n\t\tconst offHistory = await check;\n\t\tif (offHistory == null && checks.get(key) === check) {\n\t\t\tchecks.delete(key);\n\t\t}\n\t\treturn offHistory || undefined;\n\t}\n\n\t/**\n\t * Reads {@link getMovedForward} from git, in `commonPath`, which holds the refs, their reflogs and the objects for\n\t * every worktree. Not bound to one caller's cancellation, since every worktree the move reached rides this one\n\t * read. `false` when the ref didn't move only forward, or reaches too much history off `newTip`'s to tell;\n\t * `undefined` when git couldn't say.\n\t */\n\tprivate async readMovedForward(\n\t\tcommonPath: string,\n\t\tref: string,\n\t\toldTip: string,\n\t\tnewTip: string,\n\t): Promise<readonly string[] | false | undefined> {\n\t\tlet since = new Set([oldTip]);\n\t\tlet logged = new Set([oldTip]);\n\t\ttry {\n\t\t\t// Newest first. The previous read may have been taken at any entry at the old tip, so everything since its\n\t\t\t// oldest is checked; a ref at the same commit twice was moved back, which a fast-forward never does\n\t\t\tconst entries = await this.provider.refs.getReflogEntries(commonPath, ref);\n\t\t\tif (entries.length) {\n\t\t\t\t// A reflog that moved on since the ref list was read describes another move\n\t\t\t\tif (entries[0].sha !== newTip) return false;\n\n\t\t\t\tconst oldest = entries.findLastIndex(e => e.sha === oldTip);\n\t\t\t\tif (oldest < 0) return false;\n\n\t\t\t\tsince = new Set(entries.slice(1, oldest + 1).map(e => e.sha));\n\t\t\t\tlogged = new Set(entries.map(e => e.sha));\n\n\t\t\t\t// `--fork-point` also reads the value the ref held before its oldest entry, which no entry lists once the\n\t\t\t\t// entries before it expired. `<ref>@{<count>}` names it; git refuses it when the oldest entry created the\n\t\t\t\t// ref, and before 2.31 refuses it either way, which leaves it unknown for good\n\t\t\t\tconst before = await this.git.run(\n\t\t\t\t\t{ cwd: commonPath, errors: 'ignore' },\n\t\t\t\t\t'rev-parse',\n\t\t\t\t\t'--verify',\n\t\t\t\t\t`${ref}@{${entries.length}}`,\n\t\t\t\t);\n\t\t\t\tif (before.completion.status !== 'exited') return undefined;\n\n\t\t\t\tif (before.exitCode === 0) {\n\t\t\t\t\tconst sha = before.stdout.trim();\n\t\t\t\t\tif (!sha) return undefined;\n\n\t\t\t\t\tlogged.add(sha);\n\t\t\t\t} else if (!before.stderr?.includes(' only has ')) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t} else if (!(await this.git.supports('git:rev-parse:reflog-oldest-old-value'))) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tlogged.delete(newTip);\n\t\t\t}\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\n\t\ttry {\n\t\t\t// The commits the reflog reaches that `newTip` doesn't; the reflog can be long, so on stdin\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: commonPath, errors: 'ignore', stdin: `${[...logged, `^${newTip}`].join('\\n')}\\n` },\n\t\t\t\t'rev-list',\n\t\t\t\t`--max-count=${maxOffHistoryCommits + 1}`,\n\t\t\t\t'--stdin',\n\t\t\t);\n\t\t\tif (result.completion.status !== 'exited' || result.exitCode !== 0) return undefined;\n\n\t\t\tconst off = result.stdout.split('\\n').filter(sha => sha.length > 0);\n\t\t\tif (off.length > maxOffHistoryCommits) return false;\n\t\t\tif (off.some(sha => since.has(sha))) return false;\n\n\t\t\t// Excluding these excludes everything the reflog reaches, with no more than these on a command line\n\t\t\treturn off;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\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\tlet resolvedDefault: string | null | undefined;\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\tresolvedDefault = defaultBranch ?? null;\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 withDefaultBranch(\n\t\t\t\t\tawait this.measureAheadOfSelfUpstream(repoPath, branch, dependsOn, cancellation),\n\t\t\t\t\tresolvedDefault,\n\t\t\t\t);\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 withDefaultBranch(\n\t\t\t\t{ base: undefined, reason: unborn ? 'unborn' : 'none', dependsOn: [...dependsOn] },\n\t\t\t\tresolvedDefault,\n\t\t\t);\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 withDefaultBranch({ base: undefined, reason: 'self', dependsOn: [...dependsOn] }, resolvedDefault);\n\t\t}\n\n\t\treturn withDefaultBranch(\n\t\t\tawait this.measureAheadOfBase(repoPath, target, tier, dependsOn, cancellation),\n\t\t\tresolvedDefault,\n\t\t);\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.getUpstreamName(repoPath, candidate, undefined, cancellation);\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 * `<name>@{u}`, without asking git when the cached ref list shows `name` can't have one: a failed lookup isn't\n\t * cached, so asking it of a remote-tracking ref (`origin/main`, the usual default) re-spawns on every read.\n\t */\n\tprivate async getUpstreamName(\n\t\trepoPath: string,\n\t\tname: string,\n\t\toptions: { priority?: GitCommandPriority } | undefined,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<string | undefined> {\n\t\tconst records = await this.provider.refs.getRefs(repoPath, cancellation);\n\t\tif (!mayHaveUpstream(records, name)) return undefined;\n\n\t\treturn this.provider.refs.getSymbolicReferenceName(repoPath, `${name}@{u}`, options, cancellation);\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@trace({ 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@trace()\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, which it moves from the old name's section\n\t\t\t// to the new one's\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\t['config', 'heads'],\n\t\t\t\t[`refs/heads/${oldName}`, `refs/heads/${newName}`],\n\t\t\t\t{ configConfinedToRefs: true },\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} 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\t// The upstream is the branch's own config section; the branch is named for its tracking, not a move\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['config', 'heads'], [`refs/heads/${name}`], {\n\t\t\t\tconfigConfinedToRefs: true,\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\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/** Reads `rev-parse --symbolic-full-name @ @{u}` output: the current branch, then its upstream when it has one */\nfunction parseSymbolicFullNames(stdout: string): { name: string; upstream?: string } {\n\tconst [head, upstream] = stdout.trim().split('\\n');\n\n\treturn { name: parseRefName(head).name, upstream: upstream || undefined };\n}\n\n/** Each ref list {@link findRefTip} and {@link findRefRecord} 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\tconst record = resolveRefRecord(records, name);\n\treturn record != null ? record.peeledObjectname || record.objectname : undefined;\n}\n\n/** The listed ref `name` resolves to, in {@link findRefTip}'s order */\nfunction resolveRefRecord(records: readonly RefRecord[], name: string): RefRecord | undefined {\n\tconst byName = getRefRecordsByName(records);\n\tfor (const candidate of getRefNameCandidates(name)) {\n\t\tconst record = byName.get(candidate);\n\t\tif (record != null) return record;\n\t}\n\n\treturn undefined;\n}\n\n/** Whether more than one listed ref answers to `name`, which git calls ambiguous and resolves in {@link findRefTip}'s order */\nfunction isAmbiguousRefName(records: readonly RefRecord[], name: string): boolean {\n\tconst byName = getRefRecordsByName(records);\n\tlet found = false;\n\tfor (const candidate of getRefNameCandidates(name)) {\n\t\tif (!byName.has(candidate)) continue;\n\t\tif (found) return true;\n\n\t\tfound = true;\n\t}\n\n\treturn false;\n}\n\n/** The full ref names `name` may stand for, in git's own order for a short name */\nfunction getRefNameCandidates(name: string): string[] {\n\treturn [\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}\n\nfunction getRefRecordsByName(records: readonly RefRecord[]): Map<string, RefRecord> {\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\treturn byName;\n}\n\n/** The record for the full ref name `fullName` in `records`, the cached ref list; no short-name resolution */\nfunction findRefRecord(records: readonly RefRecord[], fullName: string): RefRecord | undefined {\n\treturn getRefRecordsByName(records).get(fullName);\n}\n\nfunction toPushTargetRef(records: readonly RefRecord[], ref: string): GitPushTargetRef {\n\tconst record = findRefRecord(records, ref);\n\treturn { ref: ref, sha: record != null ? record.peeledObjectname || record.objectname : undefined };\n}\n\n/**\n * Whether `<name>@{u}` can resolve, judged from `records`, the cached ref list. git follows `@{u}` only from the\n * upstream configured for a branch of that short name (`branch.<name>.merge`), so a remote-tracking ref, a tag or a\n * full ref name (`refs/heads/main@{u}` is \"no such branch\") has none. A name that names a local branch, or no ref at\n * all (a deleted branch's leftover config still answers), is asked. An empty list is a failed enumeration (see\n * `getRefTip`), which says nothing either way.\n */\nfunction mayHaveUpstream(records: readonly RefRecord[], name: string): boolean {\n\tif (!records.length || name === 'HEAD') return true;\n\tif (findRefTip(records, `refs/heads/${name}`) != null) return true;\n\n\treturn findRefTip(records, name) == null;\n}\n\n/** `answer` with the default branch its read resolved, when it consulted one (see `AheadOfBase.defaultBranch`) */\nfunction withDefaultBranch(answer: AheadOfBase, defaultBranch: string | null | undefined): AheadOfBase {\n\treturn defaultBranch !== undefined ? { ...answer, defaultBranch: defaultBranch } : answer;\n}\n\n/** Splits `git config --null --get-regexp` output into its entries, in order; a key set without a value has none */\nfunction parseConfigListing(listing: string): [key: string, value: string | undefined][] {\n\tconst entries: [key: string, value: string | undefined][] = [];\n\tfor (const entry of listing.split('\\0')) {\n\t\tif (!entry) continue;\n\n\t\tconst separator = entry.indexOf('\\n');\n\t\tentries.push(\n\t\t\tseparator < 0 ? [entry, undefined] : [entry.substring(0, separator), entry.substring(separator + 1)],\n\t\t);\n\t}\n\treturn entries;\n}\n\n/**\n * Whether `listing` shows config that can differ by checkout over time: `extensions.worktreeConfig` (each checkout's\n * `config.worktree`), or a conditional include that is neither `hasconfig:` nor `gitdir:`, since `onbranch:` follows\n * each checkout's HEAD and an unknown condition might follow anything. A `gitdir:` include matching only some\n * checkouts is accepted as shared: it is the common identity setup, and treating it as differing would end sharing for\n * nearly everyone. The cost is a known gap: an edit to a file only those checkouts include goes unseen there, since\n * nothing watches it, until a change the shared listing does see.\n */\nfunction mayConfigDifferByCheckout(listing: string): boolean {\n\tfor (const [key, value] of parseConfigListing(listing)) {\n\t\tif (key === 'extensions.worktreeconfig') {\n\t\t\t// A key set without a value is true\n\t\t\tif (value == null || !isGitBooleanFalse(value)) return true;\n\n\t\t\tcontinue;\n\t\t}\n\t\tif (!key.startsWith('includeif.')) continue;\n\n\t\tconst condition = key.substring('includeif.'.length, key.lastIndexOf('.'));\n\t\tif (\n\t\t\tcondition.startsWith('hasconfig:') ||\n\t\t\tcondition.startsWith('gitdir:') ||\n\t\t\tcondition.startsWith('gitdir/i:')\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\n\t\treturn true;\n\t}\n\treturn false;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEA,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;;;;;;AAQ5F,MAAM,uBAAuB;A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AmB,SAA6D;CACxF,MAAM,UAAsD,CAAC;CAC7D,KAAK,MAAM,SAAS,QAAQ,MAAM,IAAI,GAAG;EACxC,IAAI,CAAC,OAAO;EAEZ,MAAM,YAAY,MAAM,QAAQ,IAAI;EACpC,QAAQ,KACP,YAAY,IAAI,CAAC,OAAO,KAAA,CAAS,IAAI,CAAC,MAAM,UAAU,GAAG,SAAS,GAAG,MAAM,UAAU,YAAY,CAAC,CAAC,CACpG;CACD;CACA,OAAO;AACR;;;;;;;;;AAUA,SAAS,0BAA0B,SAA0B;CAC5D,KAAK,MAAM,CAAC,KAAK,UAAU,mBAAmB,OAAO,GAAG;EACvD,IAAI,QAAQ,6BAA6B;GAExC,IAAI,SAAS,QAAQ,CAAC,kBAAkB,KAAK,GAAG,OAAO;GAEvD;EACD;EACA,IAAI,CAAC,IAAI,WAAW,YAAY,GAAG;EAEnC,MAAM,YAAY,IAAI,UAAU,IAAqB,IAAI,YAAY,GAAG,CAAC;EACzE,IACC,UAAU,WAAW,YAAY,KACjC,UAAU,WAAW,SAAS,KAC9B,UAAU,WAAW,WAAW,GAEhC;EAGD,OAAO;CACR;CACA,OAAO;AACR;;;;;;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\tGitPushTarget,\n\tGitPushTargetRef,\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\tsplitRemoteBranchName,\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 { joinUriPath } from '@gitlens/utils/uri.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 { readHeadState } from '../exec/headState.js';\nimport { KeyedSequencer } from '../exec/indexLock.js';\nimport type { GitMergeConflict } from '../parsers/mergeTreeParser.js';\nimport { parseMergeTreeConflict } from '../parsers/mergeTreeParser.js';\nimport { resolveBranchRemote } from './branchRemote.js';\nimport { isGitBooleanFalse } from './config.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\n/**\n * The most commits a base's reflog may reach off its new tip's history for a re-measure: every worktree's count\n * excludes each of them on its command line, and more come only from a long history force-pushed away, where a full\n * read costs less\n */\nconst maxOffHistoryCommits = 64;\n\n/**\n * A base that moved only forward: the commits its reflog reaches off the new tip's history, and the commits\n * `--fork-point` reads from that reflog besides the new tip, the old tip among them\n */\ntype BaseMovedForward = { readonly offHistory: readonly string[]; readonly logged: ReadonlySet<string> };\n\n/** Reads a `%(ahead-behind:<base>)` field, `<ahead> <behind>`; `undefined` when it isn't one */\nfunction parseAheadBehindField(field: string | undefined): { ahead: number; behind: number } | undefined {\n\tconst [ahead, behind] = (field ?? '').split(' ').map(n => parseInt(n, 10));\n\tif (isNaN(ahead) || isNaN(behind)) return undefined;\n\n\treturn { ahead: ahead, behind: behind };\n}\n\n/** The named refs as `for-each-ref` patterns, or `undefined` when they're too many to fit one command line */\nfunction toRefPatterns(refs: ReadonlySet<string>): string[] | undefined {\n\treturn sum(refs, r => r.length + 1) < maxGitCliLength / 2 ? [...refs] : undefined;\n}\n\n/**\n * Joins the read `key` names against `records` (a cached ref list) in `memo`, or starts it with `read`. An answer is\n * kept as long as that list is: a ref write replaces the list, along with the refs and reflog the answer came from.\n * `undefined`, when git couldn't say, isn't kept\n */\nasync function shareBaseMoveRead<T>(\n\tmemo: WeakMap<readonly RefRecord[], Map<string, Promise<T | undefined>>>,\n\trecords: readonly RefRecord[],\n\tkey: string,\n\tread: () => Promise<T | undefined>,\n): Promise<T | undefined> {\n\tlet reads = memo.get(records);\n\tif (reads == null) {\n\t\treads = new Map();\n\t\tmemo.set(records, reads);\n\t}\n\n\tlet pending = reads.get(key);\n\tif (pending == null) {\n\t\tpending = read();\n\t\treads.set(key, pending);\n\t}\n\n\tconst answer = await pending;\n\tif (answer === undefined && reads.get(key) === pending) {\n\t\treads.delete(key);\n\t}\n\treturn answer;\n}\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 * For a base that moved only forward, what its reflog reaches (else `false`), by `<ref>\\0<oldSha>\\0<newSha>`, for\n\t * each cached ref list it was read against. A fetch moves one base under every worktree at once, so they share the\n\t * one check, joining it while it runs\n\t */\n\tprivate readonly baseMovedForward = new WeakMap<\n\t\treadonly RefRecord[],\n\t\tMap<string, Promise<BaseMovedForward | false | undefined>>\n\t>();\n\t/**\n\t * For a base that moved, the count of the commits its new tip lacks for each local branch a worktree has checked\n\t * out, by tip sha, keyed by that new tip alone for each cached ref list it was read against (which also fixes the\n\t * branches counted). The counts don't depend on the ref or where it moved from, so each worktree the move reached\n\t * finds its HEAD's count in the one read, even one whose previous answer was taken at another old tip. Only the\n\t * checked-out branches are counted: the shared walk runs until every counted branch meets the new tip, so an\n\t * unrelated old or orphan branch no worktree uses would make it deeper than any worktree's own count\n\t */\n\tprivate readonly aheadOfMovedBase = new WeakMap<\n\t\treadonly RefRecord[],\n\t\tMap<string, Promise<ReadonlyMap<string, number> | undefined>>\n\t>();\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\t/**\n\t * The repositories (by common path) whose last config listing showed config that can differ by checkout, so a linked\n\t * checkout reads its own listing without first waiting on the main checkout's. Only a shortcut: a listing that shows\n\t * otherwise drops the repository again\n\t */\n\tprivate readonly _configDiffersByCheckout = new Set<string>();\n\n\tconstructor(\n\t\tprivate readonly context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t) {}\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\t// Without `%(upstream:remotename)` (git < 2.23) a remote whose own name contains a `/` can't be\n\t\t\t\t// told from the upstream's short name alone, so read the remote names once, only if needed\n\t\t\t\tlet remoteNames: Promise<string[]> | undefined;\n\t\t\t\tconst resolveUpstreamRemote = async (upstream: string): Promise<string | undefined> => {\n\t\t\t\t\tif (!upstream.startsWith('refs/remotes/')) return undefined;\n\n\t\t\t\t\tconst { name } = parseRefName(upstream);\n\t\t\t\t\tif (!name.includes('/', name.indexOf('/') + 1)) return undefined;\n\n\t\t\t\t\tremoteNames ??= this.provider.remotes.getRemotes(commonPath, undefined, signal).then(\n\t\t\t\t\t\tremotes => {\n\t\t\t\t\t\t\t// `getRemotes` answers a failed read as no remotes, which leaves only the first-segment split\n\t\t\t\t\t\t\tif (!remotes.length) {\n\t\t\t\t\t\t\t\tcacheable?.invalidate();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn remotes.map(r => r.name);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t(ex: unknown) => {\n\t\t\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\t\t\t\t// Fall back to the first-segment split, but don't cache a list read without the remotes\n\t\t\t\t\t\t\tcacheable?.invalidate();\n\t\t\t\t\t\t\treturn [];\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\treturn splitRemoteBranchName(name, await remoteNames)?.[0];\n\t\t\t\t};\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(\n\t\t\t\t\t\trecord.upstream,\n\t\t\t\t\t\trecord.upstreamTracking,\n\t\t\t\t\t\trecord.upstreamRemote ??\n\t\t\t\t\t\t\t(!worktreePathSupported ? await resolveUpstreamRemote(record.upstream) : undefined),\n\t\t\t\t\t\trecord.upstreamRemoteRef,\n\t\t\t\t\t);\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? {\n\t\t\t\t\t\t\t\t\t\tname: branch.upstream.name,\n\t\t\t\t\t\t\t\t\t\tmissing: branch.upstream.missing,\n\t\t\t\t\t\t\t\t\t\tremote: branch.upstream.remote,\n\t\t\t\t\t\t\t\t\t\tremoteBranch: branch.upstream.remoteBranch,\n\t\t\t\t\t\t\t\t\t\tlocal: branch.upstream.local,\n\t\t\t\t\t\t\t\t\t}\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 { remote: remoteName } = await resolveBranchRemote(\n\t\t\t\t\t\tthis.provider,\n\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\tbranch,\n\t\t\t\t\t\tcancellation,\n\t\t\t\t\t);\n\n\t\t\t\t\t// A branch with no remote upstream has no remote to find the PR's base on\n\t\t\t\t\tif (remoteName != null) {\n\t\t\t\t\t\tconst prTarget = `${remoteName}/${pr.refs.base.branch}`;\n\t\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\t// so a confirmed-gone base is skipped like a stored target.\n\t\t\t\t\t\tconst { missing } = await this.provider.refs.getSymbolicReferenceNameOrMissing(\n\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\tprTarget,\n\t\t\t\t\t\t\tpriorityOpts,\n\t\t\t\t\t\t\tcancellation,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (!missing) {\n\t\t\t\t\t\t\tmergeTarget = prTarget;\n\n\t\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\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\t// layer's branch can linger (an unpruned remote-tracking ref, or a repo that keeps merged\n\t\t\t\t\t\t\t// branches). Use it for this lookup, but don't persist it.\n\t\t\t\t\t\t\tif (pr.stack == null) {\n\t\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\t// `branchOverviews` invalidation that the write would otherwise trigger: we're\n\t\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\t// it would just force the next caller to redo the body. (gk-merge-target writes\n\t\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\t\tvoid this.storeMergeTargetBranchName(repoPath, ref, prTarget, {\n\t\t\t\t\t\t\t\t\tskipInvalidation: ['branchOverviews'],\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}\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\t// `upstream` is the full ref (`refs/heads/…` or `refs/remotes/…`) so a local upstream\n\t\t\t\t// can't be mistaken for a remote's branch of the same short name\n\t\t\t\tlet data:\n\t\t\t\t\t| { name: string; upstream?: string; remote?: string; remoteRef?: string; sha?: string }\n\t\t\t\t\t| 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'--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 = parseSymbolicFullNames(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.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 = parseSymbolicFullNames(ex.stdout);\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 = { name: result.stdout.trim() };\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\tname: symbolicRef.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};\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 = { name: defaultBranch };\n\t\t\t\t\t\t\t\tif (remote && remoteBranch) {\n\t\t\t\t\t\t\t\t\tdata.upstream =\n\t\t\t\t\t\t\t\t\t\tremote === '.'\n\t\t\t\t\t\t\t\t\t\t\t? `refs/heads/${remoteBranch}`\n\t\t\t\t\t\t\t\t\t\t\t: `refs/remotes/${remote}/${remoteBranch}`;\n\t\t\t\t\t\t\t\t\tdata.remote = remote;\n\t\t\t\t\t\t\t\t\tdata.remoteRef = merge;\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 = { name: `(HEAD detached at ${shortenRevision(sha)})`, 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 } = data;\n\n\t\t\t\tlet { remote, remoteRef } = data;\n\t\t\t\tif (data.upstream?.startsWith('refs/heads/') && remote == null) {\n\t\t\t\t\t// Git reports no remote here, but a custom fetch refspec can put a remote's branches under\n\t\t\t\t\t// `refs/heads/`, so ask the config whether this upstream is really a remote's\n\t\t\t\t\t[remote, remoteRef] = await Promise.all([\n\t\t\t\t\t\tthis.provider.config.getConfig(repoPath, `branch.${name}.remote`),\n\t\t\t\t\t\tthis.provider.config.getConfig(repoPath, `branch.${name}.merge`),\n\t\t\t\t\t]);\n\t\t\t\t}\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: data.upstream ? parseUpstream(data.upstream, '', remote, remoteRef) : undefined,\n\t\t\t\t\tsha: data.sha,\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\t// Tracking is written to the new branch's own config section, and nowhere else\n\t\t\tif (mayWriteTracking(ref, options?.noTracking)) {\n\t\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['config', 'heads'], [`refs/heads/${name}`], {\n\t\t\t\t\tconfigConfinedToRefs: true,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['heads'], [`refs/heads/${name}`]);\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\t// A delete drops the branches' own config sections, and nothing else\n\t\t\tthis.context.hooks?.repository?.onChanged?.(\n\t\t\t\trepoPath,\n\t\t\t\t['config', 'heads'],\n\t\t\t\tbranches.map(b => `refs/heads/${b}`),\n\t\t\t\t{ configConfinedToRefs: true },\n\t\t\t);\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 deleted = 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 (deleted.length) {\n\t\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\t\t// Names only the branches that went: the watcher takes a report of a named ref for the write's own,\n\t\t\t\t// so naming one that stayed would pass off an outside change to it as this delete's\n\t\t\t\tthis.context.hooks?.repository?.onChanged?.(\n\t\t\t\t\trepoPath,\n\t\t\t\t\t['config', 'heads'],\n\t\t\t\t\tdeleted.map(b => `refs/heads/${b}`),\n\t\t\t\t\t{ configConfinedToRefs: true },\n\t\t\t\t);\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 those of `names` confirmed gone; none when the probe couldn't answer, so a spurious\n\t * notification is never fired on an unrelated failure.\n\t */\n\tprivate async cleanupDeletedBranchMetadata(repoPath: string, names: string[]): Promise<string[]> {\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 [];\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\tconst deleted: string[] = [];\n\t\t\tfor (const name of names) {\n\t\t\t\tif (surviving.has(name)) continue;\n\n\t\t\t\tdeleted.push(name);\n\t\t\t\tawait this.forgetDeletedBranch(repoPath, name);\n\t\t\t}\n\n\t\t\treturn deleted;\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 [];\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@trace({ exit: true })\n\tasync getPushTarget(repoPath: string, branch?: string, cancellation?: AbortSignal): Promise<GitPushTarget> {\n\t\tconst records = await this.provider.refs.getRefs(repoPath, cancellation);\n\t\t// `getRefs` answers a failed enumeration with an empty list, which says nothing about any branch\n\t\tif (!records.length) return { known: false };\n\n\t\tif (branch == null) {\n\t\t\t// The worktree's own HEAD file names its branch with no git process, and is as current as the file. What\n\t\t\t// it can't answer (a reftable repository, a branch that is a symbolic ref to another, or a HEAD kept as a\n\t\t\t// symlink to its branch) falls back to resolving the reference\n\t\t\tconst head = await readHeadState(repoPath, this.context.fs, this.cache);\n\t\t\tif (head === 'detached') return { known: true, push: undefined, upstream: undefined };\n\n\t\t\tif (head != null) {\n\t\t\t\tbranch = head.branch;\n\t\t\t} else {\n\t\t\t\tconst current = await this.getCurrentBranchReference(repoPath, cancellation);\n\t\t\t\tif (current == null) return { known: false };\n\t\t\t\tif (current.remote || isDetachedHead(current.name)) {\n\t\t\t\t\treturn { known: true, push: undefined, upstream: undefined };\n\t\t\t\t}\n\n\t\t\t\tbranch = current.name;\n\t\t\t}\n\t\t}\n\n\t\tconst record = findRefRecord(records, branch.startsWith('refs/heads/') ? branch : `refs/heads/${branch}`);\n\t\treturn {\n\t\t\tknown: true,\n\t\t\tpush: record?.push ? toPushTargetRef(records, record.push) : undefined,\n\t\t\tupstream: record?.upstream ? toPushTargetRef(records, record.upstream) : undefined,\n\t\t};\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.getUpstreamName(repoPath, createdFrom, priorityOpts, cancellation);\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.getUpstreamName(repoPath, name, priorityOpts, cancellation);\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@trace()\n\tgetAheadOfBaseConfigKey(repoPath: string, cancellation?: AbortSignal): Promise<string | undefined> {\n\t\treturn this.getAheadOfBaseConfigListing(repoPath, cancellation);\n\t}\n\n\t@trace()\n\tasync getAheadOfBaseConfigEntries(\n\t\trepoPath: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<readonly (readonly [key: string, value: string | undefined])[] | undefined> {\n\t\tconst listing = await this.getAheadOfBaseConfigListing(repoPath, cancellation);\n\t\treturn listing != null ? parseConfigListing(listing) : undefined;\n\t}\n\n\t/**\n\t * A checkout's listing of the config inputs to {@link getAheadOfBase}. Every checkout of a repository shares the main\n\t * checkout's, unless it shows config that can differ by checkout (see `mayConfigDifferByCheckout`); then\n\t * each linked checkout reads its own, and keeps doing so until one of its own reads shows config no longer can.\n\t */\n\tprivate getAheadOfBaseConfigListing(\n\t\trepoPath: string,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<string | undefined> {\n\t\treturn this.cache.getAheadOfBaseConfigKey(\n\t\t\trepoPath,\n\t\t\tasync (checkoutPath, cacheable, signal) => {\n\t\t\t\tconst commonPath = this.cache.getCommonPath(checkoutPath);\n\t\t\t\tconst isMain = checkoutPath === commonPath;\n\t\t\t\tif (isMain || !this._configDiffersByCheckout.has(commonPath)) {\n\t\t\t\t\tconst shared = await this.cache.getAheadOfBaseConfigListing(\n\t\t\t\t\t\tcheckoutPath,\n\t\t\t\t\t\t(path, sharedCacheable, sharedSignal) =>\n\t\t\t\t\t\t\tthis.readAheadOfBaseConfigListing(path, sharedCacheable, sharedSignal),\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t);\n\t\t\t\t\t// Read in the main checkout, so it is that checkout's own\n\t\t\t\t\tif (isMain) {\n\t\t\t\t\t\tif (shared == null) {\n\t\t\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn shared;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (shared != null) {\n\t\t\t\t\t\tif (!mayConfigDifferByCheckout(shared)) return shared;\n\n\t\t\t\t\t\tthis._configDiffersByCheckout.add(commonPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst own = await this.readAheadOfBaseConfigListing(checkoutPath, cacheable, signal);\n\t\t\t\tif (own != null && !mayConfigDifferByCheckout(own)) {\n\t\t\t\t\tthis._configDiffersByCheckout.delete(commonPath);\n\t\t\t\t}\n\t\t\t\treturn own;\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate async readAheadOfBaseConfigListing(\n\t\tcwd: string,\n\t\tcacheable: CacheController,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<string | undefined> {\n\t\t// Include every branch's tracking mapping: a recorded candidate can resolve through its own upstream.\n\t\t// Preserve repeated values and order, since multiple fetch refspecs can change that resolution. Conditional\n\t\t// includes and `extensions.worktreeConfig` tell whether one checkout's listing holds for the others.\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: cwd, cancellation: cancellation, expectedExitCodes: [1] },\n\t\t\t'config',\n\t\t\t'--null',\n\t\t\t'--get-regexp',\n\t\t\t'^(branch\\\\..*\\\\.(remote|merge)|remote\\\\..*|init\\\\.defaultbranch|includeif\\\\..*|extensions\\\\.worktreeconfig)$',\n\t\t);\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tif (result.completion.status !== 'exited') {\n\t\t\tcacheable.invalidate();\n\t\t\treturn undefined;\n\t\t}\n\t\treturn result.stdout;\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@debug({ exit: true })\n\tasync getAheadOfBaseAfterBaseMove(\n\t\trepoPath: string,\n\t\tbranch: string | undefined,\n\t\tprevious: {\n\t\t\treadonly head: string;\n\t\t\treadonly base: NonNullable<AheadOfBase['base']>;\n\t\t\treadonly dependsOn: readonly string[];\n\t\t\treadonly defaultBranch?: string | null;\n\t\t},\n\t\tmoved: readonly string[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<AheadOfBase | undefined> {\n\t\tconst { head, base } = previous;\n\t\tconst oldTip = base.sha;\n\t\tif (oldTip == null || !moved.length) return undefined;\n\t\t// A preferred target comes only from an option this re-measure doesn't take. And the default branch takes an\n\t\t// upstream HEAD already contains as its own fork point, which no longer holds once the upstream moves past\n\t\t// HEAD's history; a fresh read then asks git for the fork point instead.\n\t\tif (base.tier === 'preferred' || (base.tier === 'upstream' && base.forkPoint === oldTip)) return undefined;\n\n\t\ttry {\n\t\t\tconst records = await this.provider.refs.getRefs(repoPath, cancellation);\n\t\t\tconst record = records.length ? resolveRefRecord(records, base.ref) : undefined;\n\t\t\tif (record == null || !moved.includes(record.name)) return undefined;\n\t\t\t// A name more than one listed ref answers to may now resolve to another ref than the one measured (a tag\n\t\t\t// created over a branch's name), and `--fork-point` refuses it outright, falling back to the merge base\n\t\t\tif (isAmbiguousRefName(records, base.ref)) return undefined;\n\n\t\t\tconst newTip = record.peeledObjectname || record.objectname;\n\t\t\t// Back at the old tip, a move in between may still have left the reflog `--fork-point` reads changed\n\t\t\tif (!newTip || newTip === oldTip) return undefined;\n\t\t\tif (branch != null && !isDetachedHead(branch) && findRefTip(records, `refs/heads/${branch}`) !== head) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tlet remoteHeadMoved = false;\n\t\t\tfor (const ref of moved) {\n\t\t\t\tif (ref === record.name) continue;\n\t\t\t\t// A fetch lists a remote's `HEAD` along with the branch it points at; pointing anywhere else, it was\n\t\t\t\t// retargeted, which can change the default branch. The listed tip corroborates the cached symref.\n\t\t\t\tif (\n\t\t\t\t\tfindRefTip(records, ref) !== newTip ||\n\t\t\t\t\t!(await this.isRemoteHeadOf(repoPath, ref, record.name, cancellation))\n\t\t\t\t) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tremoteHeadMoved = true;\n\t\t\t}\n\t\t\t// One retargeted onto the base (from `origin/release` to `origin/main`, say) points at it just the same, but\n\t\t\t// can make another branch the default, and one retargeted to a ref at the same commit isn't named at all, so\n\t\t\t// whenever the previous read consulted the default it is resolved again, from the cached refs and symrefs, and\n\t\t\t// must be the one that read resolved\n\t\t\tif (remoteHeadMoved && previous.defaultBranch === undefined) return undefined;\n\t\t\tif (previous.defaultBranch !== undefined) {\n\t\t\t\tconst defaultBranch = await this.getLocalDefaultBranchName(repoPath, new Set(), cancellation);\n\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\t\t\t\tif ((defaultBranch ?? null) !== previous.defaultBranch) return undefined;\n\t\t\t}\n\n\t\t\t// The `upstream` remote's copy of a base is measured against it only while their tips differ, so a ref at\n\t\t\t// the old or the new tip may now be compared where it wasn't, or the other way round\n\t\t\tif (previous.dependsOn.some(r => r.startsWith('refs/remotes/upstream/') && !r.endsWith('/HEAD'))) {\n\t\t\t\tfor (const ref of previous.dependsOn) {\n\t\t\t\t\tif (ref === record.name || ref.endsWith('/HEAD')) continue;\n\n\t\t\t\t\tconst tip = findRefTip(records, ref);\n\t\t\t\t\tif (tip === oldTip || tip === newTip) return undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// The reasoning below compares counts taken over one history. A shallow fetch cuts the history the previous\n\t\t\t// answer counted (or a deepening one extends it), so the same commits count differently, and git's fork\n\t\t\t// point can change with them; in a shallow repository it's read in full\n\t\t\tif ((await this.isShallowRepository(repoPath)) !== false) return undefined;\n\n\t\t\tconst movedForward = await this.getMovedForward(repoPath, records, record.name, oldTip, newTip);\n\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\t\t\tif (!movedForward) return undefined;\n\n\t\t\tconst { offHistory, logged } = movedForward;\n\n\t\t\t// HEAD's commits the new tip lacks are a subset of those the old one lacked, so the previous count, taken\n\t\t\t// past the new tip, the previous fork point and the commits the reflog reaches off the new tip's history,\n\t\t\t// means the same commits, none of them reachable from that fork point or the reflog: none reached the base,\n\t\t\t// and HEAD shares no more history with the base's whole reflog than with its tip, so its merge base and its\n\t\t\t// `--fork-point` are one commit, which didn't move. The fork point is that commit too, being in the new tip's\n\t\t\t// history, where a fork point the reflog supplied (a commit of HEAD's the base once held, its entry expired\n\t\t\t// since) isn't.\n\t\t\t//\n\t\t\t// Every worktree the move reached shares one count of each local branch's commits past the new tip alone, for\n\t\t\t// the branches worktrees have checked out: one old or orphan branch no worktree uses would make the shared\n\t\t\t// walk reach deeper than any worktree's own count. The old tip is in the new tip's history, so for HEAD that\n\t\t\t// count is at most the previous one and at least the count above, which leaves out more: one that differs\n\t\t\t// from the previous count means the count above does too. An equal one is the count above when leaving out\n\t\t\t// more takes nothing more: with nothing off the new tip's history, everything the reflog holds is in it, so a\n\t\t\t// fork point the reflog supplied is too, as are the old and new tips. With any other fork point (a merge base,\n\t\t\t// or a commit whose reflog entry expired since), commits off the new tip's history, or a HEAD no checked-out\n\t\t\t// branch points at (a detached one included), this worktree counts its own.\n\t\t\tconst aheadOfNewTip = (await this.getAheadOfMovedBase(repoPath, records, newTip))?.get(head);\n\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\t\t\tif (aheadOfNewTip != null && aheadOfNewTip !== base.ahead) return undefined;\n\n\t\t\tconst forkPoint = base.forkPoint;\n\t\t\tif (\n\t\t\t\taheadOfNewTip == null ||\n\t\t\t\toffHistory.length !== 0 ||\n\t\t\t\t(forkPoint != null && forkPoint !== oldTip && forkPoint !== newTip && !logged.has(forkPoint))\n\t\t\t) {\n\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'ignore' },\n\t\t\t\t\t'rev-list',\n\t\t\t\t\t'--count',\n\t\t\t\t\thead,\n\t\t\t\t\t'--not',\n\t\t\t\t\tnewTip,\n\t\t\t\t\t...(forkPoint != null ? [forkPoint] : []),\n\t\t\t\t\t...offHistory,\n\t\t\t\t\t'--',\n\t\t\t\t);\n\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\t\t\t\tif (result.completion.status !== 'exited' || result.exitCode !== 0) return undefined;\n\t\t\t\tif (parseInt(result.stdout.trim(), 10) !== base.ahead) return undefined;\n\t\t\t}\n\n\t\t\treturn withDefaultBranch(\n\t\t\t\t{ base: { ...base, sha: newTip }, dependsOn: [...previous.dependsOn] },\n\t\t\t\tprevious.defaultBranch,\n\t\t\t);\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/**\n\t * Whether the repository is shallow, by its common git directory's `shallow` file, which spawns nothing; `undefined`\n\t * when it can't be read\n\t */\n\tprivate async isShallowRepository(repoPath: string): Promise<boolean | undefined> {\n\t\ttry {\n\t\t\tconst gitDir = await this.provider.config.getGitDir(repoPath);\n\t\t\treturn (await this.context.fs.stat(joinUriPath(gitDir.commonUri ?? gitDir.uri, 'shallow'))) != null;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/** Whether `ref` is a `refs/remotes/<remote>/HEAD` symref pointing at `target`, from the cached local symref */\n\tprivate async isRemoteHeadOf(\n\t\trepoPath: string,\n\t\tref: string,\n\t\ttarget: string,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<boolean> {\n\t\tif (!ref.startsWith('refs/remotes/') || !ref.endsWith('/HEAD')) return false;\n\n\t\tconst remote = ref.slice('refs/remotes/'.length, -'/HEAD'.length);\n\t\tif (!remote) return false;\n\n\t\tconst symref = await this.getDefaultBranchName(repoPath, remote, { local: true }, cancellation);\n\t\treturn symref != null && `refs/remotes/${symref}` === target;\n\t}\n\n\t/**\n\t * For `ref` (a full name in `records`, the cached ref list) moving from `oldTip` to `newTip`, the commits its reflog\n\t * holds and those it reaches off `newTip`'s history, when it moved only forward: `oldTip` and every value its reflog\n\t * took after it are in `newTip`'s history. `--fork-point` reads every reflog entry, so one in between that shares\n\t * more of HEAD's history than `newTip` does (a branch's commit that landed and was force-pushed away) moves the fork\n\t * point while the count stands; an older one off `newTip`'s history may hold such a commit too, which each\n\t * worktree's count checks for. Without a reflog it reads only the tip. `undefined` when it didn't move only forward,\n\t * or git can't say.\n\t */\n\tprivate async getMovedForward(\n\t\trepoPath: string,\n\t\trecords: readonly RefRecord[],\n\t\tref: string,\n\t\toldTip: string,\n\t\tnewTip: string,\n\t): Promise<BaseMovedForward | undefined> {\n\t\tconst movedForward = await shareBaseMoveRead(\n\t\t\tthis.baseMovedForward,\n\t\t\trecords,\n\t\t\t`${ref}\\0${oldTip}\\0${newTip}`,\n\t\t\t() => this.readMovedForward(this.cache.getCommonPath(repoPath), ref, oldTip, newTip),\n\t\t);\n\t\treturn movedForward || undefined;\n\t}\n\n\t/**\n\t * Reads {@link getMovedForward} from git, in `commonPath`, which holds the refs, their reflogs and the objects for\n\t * every worktree. Not bound to one caller's cancellation, since every worktree the move reached rides this one\n\t * read. `false` when the ref didn't move only forward, or reaches too much history off `newTip`'s to tell;\n\t * `undefined` when git couldn't say.\n\t */\n\tprivate async readMovedForward(\n\t\tcommonPath: string,\n\t\tref: string,\n\t\toldTip: string,\n\t\tnewTip: string,\n\t): Promise<BaseMovedForward | false | undefined> {\n\t\tlet since = new Set([oldTip]);\n\t\tlet logged = new Set([oldTip]);\n\t\ttry {\n\t\t\t// Newest first. The previous read may have been taken at any entry at the old tip, so everything since its\n\t\t\t// oldest is checked; a ref at the same commit twice was moved back, which a fast-forward never does\n\t\t\tconst entries = await this.provider.refs.getReflogEntries(commonPath, ref);\n\t\t\tif (entries.length) {\n\t\t\t\t// A reflog that moved on since the ref list was read describes another move\n\t\t\t\tif (entries[0].sha !== newTip) return false;\n\n\t\t\t\tconst oldest = entries.findLastIndex(e => e.sha === oldTip);\n\t\t\t\tif (oldest < 0) return false;\n\n\t\t\t\tsince = new Set(entries.slice(1, oldest + 1).map(e => e.sha));\n\t\t\t\tlogged = new Set(entries.map(e => e.sha));\n\n\t\t\t\t// `--fork-point` also reads the value the ref held before its oldest entry, which no entry lists once the\n\t\t\t\t// entries before it expired. `<ref>@{<count>}` names it; git refuses it when the oldest entry created the\n\t\t\t\t// ref, and before 2.31 refuses it either way, which leaves it unknown for good\n\t\t\t\tconst before = await this.git.run(\n\t\t\t\t\t{ cwd: commonPath, errors: 'ignore' },\n\t\t\t\t\t'rev-parse',\n\t\t\t\t\t'--verify',\n\t\t\t\t\t`${ref}@{${entries.length}}`,\n\t\t\t\t);\n\t\t\t\tif (before.completion.status !== 'exited') return undefined;\n\n\t\t\t\tif (before.exitCode === 0) {\n\t\t\t\t\tconst sha = before.stdout.trim();\n\t\t\t\t\tif (!sha) return undefined;\n\n\t\t\t\t\tlogged.add(sha);\n\t\t\t\t} else if (!before.stderr?.includes(' only has ')) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t} else if (!(await this.git.supports('git:rev-parse:reflog-oldest-old-value'))) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tlogged.delete(newTip);\n\t\t\t}\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\n\t\ttry {\n\t\t\t// The commits the reflog reaches that `newTip` doesn't; the reflog can be long, so on stdin\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: commonPath, errors: 'ignore', stdin: `${[...logged, `^${newTip}`].join('\\n')}\\n` },\n\t\t\t\t'rev-list',\n\t\t\t\t`--max-count=${maxOffHistoryCommits + 1}`,\n\t\t\t\t'--stdin',\n\t\t\t);\n\t\t\tif (result.completion.status !== 'exited' || result.exitCode !== 0) return undefined;\n\n\t\t\tconst off = result.stdout.split('\\n').filter(sha => sha.length > 0);\n\t\t\tif (off.length > maxOffHistoryCommits) return false;\n\t\t\tif (off.some(sha => since.has(sha))) return false;\n\n\t\t\t// Excluding these excludes everything the reflog reaches, with no more than these on a command line\n\t\t\treturn { offHistory: off, logged: logged };\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/**\n\t * For a base moved to `newTip`, read against `records` (the cached ref list), the count of the commits `newTip`\n\t * lacks for each local branch a worktree has checked out, by tip sha, so a detached HEAD at one of those tips finds\n\t * its count too. Only those branches are counted: the one walk runs until every counted branch meets `newTip`, so an\n\t * unrelated old or orphan branch would make it deeper than any worktree's own count, and a HEAD at a commit no\n\t * checked-out branch points at isn't in the answer. The branches derive from `records`, which the read is kept\n\t * per, so `newTip` alone keys it. `undefined` when git can't count them in one pass (before 2.41), there is no\n\t * checked-out branch or `records` can't tell which are, or git couldn't say.\n\t */\n\tprivate getAheadOfMovedBase(\n\t\trepoPath: string,\n\t\trecords: readonly RefRecord[],\n\t\tnewTip: string,\n\t): Promise<ReadonlyMap<string, number> | undefined> {\n\t\treturn shareBaseMoveRead(this.aheadOfMovedBase, records, newTip, () =>\n\t\t\tthis.readAheadOfMovedBase(this.cache.getCommonPath(repoPath), records, newTip),\n\t\t);\n\t}\n\n\t/**\n\t * Reads {@link getAheadOfMovedBase} from git, in `commonPath`, which holds every worktree's branches. Not bound to\n\t * one caller's cancellation, since every worktree the move reached rides this one read.\n\t */\n\tprivate async readAheadOfMovedBase(\n\t\tcommonPath: string,\n\t\trecords: readonly RefRecord[],\n\t\tnewTip: string,\n\t): Promise<ReadonlyMap<string, number> | undefined> {\n\t\ttry {\n\t\t\tif (!(await this.git.supports('git:for-each-ref:ahead-behind'))) return undefined;\n\n\t\t\tconst checkedOut = new Set<string>();\n\t\t\tfor (const record of records) {\n\t\t\t\tif (!record.name.startsWith('refs/heads/')) continue;\n\n\t\t\t\t// Without git's `%(worktreepath)` (before 2.23) the list can't say which branches are checked out, and\n\t\t\t\t// counting all of them is the walk this avoids, so each worktree counts its own\n\t\t\t\tif (record.worktreePath == null) return undefined;\n\n\t\t\t\tif (record.worktreePath) {\n\t\t\t\t\tcheckedOut.add(record.name);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!checkedOut.size) return undefined;\n\n\t\t\t// A list too long for the command line is read whole and filtered\n\t\t\tconst patterns = toRefPatterns(checkedOut) ?? ['refs/heads'];\n\n\t\t\t// `newTip` is a full sha, so no `)` can end the format atom early. for-each-ref also matches below a\n\t\t\t// pattern (`refs/heads/a` matches `refs/heads/a/b`), so only the exact names are kept.\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: commonPath, errors: 'ignore' },\n\t\t\t\t'for-each-ref',\n\t\t\t\t`--format=%(refname)%09%(objectname)%09%(ahead-behind:${newTip})`,\n\t\t\t\t...patterns,\n\t\t\t);\n\t\t\t// One walk counts every checked-out branch, which a commit-graph speeds up most\n\t\t\tvoid this.provider.maintenance?.request(commonPath, 'commit-graph');\n\t\t\tif (result.completion.status !== 'exited' || result.exitCode !== 0) return undefined;\n\n\t\t\tconst aheadByTip = new Map<string, number>();\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, sha, field] = line.split('\\t');\n\t\t\t\tif (!ref || !sha) return undefined;\n\t\t\t\tif (!checkedOut.has(ref)) continue;\n\n\t\t\t\t// git leaves the field empty for a ref that isn't at a commit, which no HEAD can be at, so it's skipped\n\t\t\t\t// rather than costing every worktree the shared read\n\t\t\t\tconst counted = parseAheadBehindField(field);\n\t\t\t\tif (counted == null) continue;\n\n\t\t\t\taheadByTip.set(sha, counted.ahead);\n\t\t\t}\n\t\t\treturn aheadByTip;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\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\tlet resolvedDefault: string | null | undefined;\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\tresolvedDefault = defaultBranch ?? null;\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 withDefaultBranch(\n\t\t\t\t\tawait this.measureAheadOfSelfUpstream(repoPath, branch, dependsOn, cancellation),\n\t\t\t\t\tresolvedDefault,\n\t\t\t\t);\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 withDefaultBranch(\n\t\t\t\t{ base: undefined, reason: unborn ? 'unborn' : 'none', dependsOn: [...dependsOn] },\n\t\t\t\tresolvedDefault,\n\t\t\t);\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 withDefaultBranch({ base: undefined, reason: 'self', dependsOn: [...dependsOn] }, resolvedDefault);\n\t\t}\n\n\t\treturn withDefaultBranch(\n\t\t\tawait this.measureAheadOfBase(repoPath, target, tier, dependsOn, cancellation),\n\t\t\tresolvedDefault,\n\t\t);\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 {\n\t\t\tpatterns = toRefPatterns(refs) ?? ['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 aheadBehind = parseAheadBehindField(counted);\n\t\t\t\tif (aheadBehind == null) {\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, aheadBehind);\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.getUpstreamName(repoPath, candidate, undefined, cancellation);\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 * `<name>@{u}`, without asking git when the cached ref list shows `name` can't have one: a failed lookup isn't\n\t * cached, so asking it of a remote-tracking ref (`origin/main`, the usual default) re-spawns on every read.\n\t */\n\tprivate async getUpstreamName(\n\t\trepoPath: string,\n\t\tname: string,\n\t\toptions: { priority?: GitCommandPriority } | undefined,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<string | undefined> {\n\t\tconst records = await this.provider.refs.getRefs(repoPath, cancellation);\n\t\tif (!mayHaveUpstream(records, name)) return undefined;\n\n\t\treturn this.provider.refs.getSymbolicReferenceName(repoPath, `${name}@{u}`, options, cancellation);\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@trace({ 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@trace()\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, which it moves from the old name's section\n\t\t\t// to the new one's\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\t['config', 'heads'],\n\t\t\t\t[`refs/heads/${oldName}`, `refs/heads/${newName}`],\n\t\t\t\t{ configConfinedToRefs: true },\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} 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\t// The upstream is the branch's own config section; the branch is named for its tracking, not a move\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['config', 'heads'], [`refs/heads/${name}`], {\n\t\t\t\tconfigConfinedToRefs: true,\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\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/** Reads `rev-parse --symbolic-full-name @ @{u}` output: the current branch, then its upstream when it has one */\nfunction parseSymbolicFullNames(stdout: string): { name: string; upstream?: string } {\n\tconst [head, upstream] = stdout.trim().split('\\n');\n\n\treturn { name: parseRefName(head).name, upstream: upstream || undefined };\n}\n\n/** Each ref list {@link findRefTip} and {@link findRefRecord} 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\tconst record = resolveRefRecord(records, name);\n\treturn record != null ? record.peeledObjectname || record.objectname : undefined;\n}\n\n/** The listed ref `name` resolves to, in {@link findRefTip}'s order */\nfunction resolveRefRecord(records: readonly RefRecord[], name: string): RefRecord | undefined {\n\tconst byName = getRefRecordsByName(records);\n\tfor (const candidate of getRefNameCandidates(name)) {\n\t\tconst record = byName.get(candidate);\n\t\tif (record != null) return record;\n\t}\n\n\treturn undefined;\n}\n\n/** Whether more than one listed ref answers to `name`, which git calls ambiguous and resolves in {@link findRefTip}'s order */\nfunction isAmbiguousRefName(records: readonly RefRecord[], name: string): boolean {\n\tconst byName = getRefRecordsByName(records);\n\tlet found = false;\n\tfor (const candidate of getRefNameCandidates(name)) {\n\t\tif (!byName.has(candidate)) continue;\n\t\tif (found) return true;\n\n\t\tfound = true;\n\t}\n\n\treturn false;\n}\n\n/** The full ref names `name` may stand for, in git's own order for a short name */\nfunction getRefNameCandidates(name: string): string[] {\n\treturn [\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}\n\nfunction getRefRecordsByName(records: readonly RefRecord[]): Map<string, RefRecord> {\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\treturn byName;\n}\n\n/** The record for the full ref name `fullName` in `records`, the cached ref list; no short-name resolution */\nfunction findRefRecord(records: readonly RefRecord[], fullName: string): RefRecord | undefined {\n\treturn getRefRecordsByName(records).get(fullName);\n}\n\nfunction toPushTargetRef(records: readonly RefRecord[], ref: string): GitPushTargetRef {\n\tconst record = findRefRecord(records, ref);\n\treturn { ref: ref, sha: record != null ? record.peeledObjectname || record.objectname : undefined };\n}\n\n/**\n * Whether `<name>@{u}` can resolve, judged from `records`, the cached ref list. git follows `@{u}` only from the\n * upstream configured for a branch of that short name (`branch.<name>.merge`), so a remote-tracking ref, a tag or a\n * full ref name (`refs/heads/main@{u}` is \"no such branch\") has none. A name that names a local branch, or no ref at\n * all (a deleted branch's leftover config still answers), is asked. An empty list is a failed enumeration (see\n * `getRefTip`), which says nothing either way.\n */\nfunction mayHaveUpstream(records: readonly RefRecord[], name: string): boolean {\n\tif (!records.length || name === 'HEAD') return true;\n\tif (findRefTip(records, `refs/heads/${name}`) != null) return true;\n\n\treturn findRefTip(records, name) == null;\n}\n\n/** `answer` with the default branch its read resolved, when it consulted one (see `AheadOfBase.defaultBranch`) */\nfunction withDefaultBranch(answer: AheadOfBase, defaultBranch: string | null | undefined): AheadOfBase {\n\treturn defaultBranch !== undefined ? { ...answer, defaultBranch: defaultBranch } : answer;\n}\n\n/** Splits `git config --null --get-regexp` output into its entries, in order; a key set without a value has none */\nfunction parseConfigListing(listing: string): [key: string, value: string | undefined][] {\n\tconst entries: [key: string, value: string | undefined][] = [];\n\tfor (const entry of listing.split('\\0')) {\n\t\tif (!entry) continue;\n\n\t\tconst separator = entry.indexOf('\\n');\n\t\tentries.push(\n\t\t\tseparator < 0 ? [entry, undefined] : [entry.substring(0, separator), entry.substring(separator + 1)],\n\t\t);\n\t}\n\treturn entries;\n}\n\n/**\n * Whether `listing` shows config that can differ by checkout over time: `extensions.worktreeConfig` (each checkout's\n * `config.worktree`), or a conditional include that is neither `hasconfig:` nor `gitdir:`, since `onbranch:` follows\n * each checkout's HEAD and an unknown condition might follow anything. A `gitdir:` include matching only some\n * checkouts is accepted as shared: it is the common identity setup, and treating it as differing would end sharing for\n * nearly everyone. The cost is a known gap: an edit to a file only those checkouts include goes unseen there, since\n * nothing watches it, until a change the shared listing does see.\n */\nfunction mayConfigDifferByCheckout(listing: string): boolean {\n\tfor (const [key, value] of parseConfigListing(listing)) {\n\t\tif (key === 'extensions.worktreeconfig') {\n\t\t\t// A key set without a value is true\n\t\t\tif (value == null || !isGitBooleanFalse(value)) return true;\n\n\t\t\tcontinue;\n\t\t}\n\t\tif (!key.startsWith('includeif.')) continue;\n\n\t\tconst condition = key.substring('includeif.'.length, key.lastIndexOf('.'));\n\t\tif (\n\t\t\tcondition.startsWith('hasconfig:') ||\n\t\t\tcondition.startsWith('gitdir:') ||\n\t\t\tcondition.startsWith('gitdir/i:')\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\n\t\treturn true;\n\t}\n\treturn false;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEA,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;;;;;;AAQ5F,MAAM,uBAAuB;;AAS7B,SAAS,sBAAsB,OAA0E;CACxG,MAAM,CAAC,OAAO,WAAW,SAAS,GAAA,CAAI,MAAM,GAAG,CAAC,CAAC,KAAI,MAAK,SAAS,GAAG,EAAE,CAAC;CACzE,IAAI,MAAM,KAAK,KAAK,MAAM,MAAM,GAAG,OAAO,KAAA;CAE1C,OAAO;EAAS;EAAe;CAAO;AACvC;;AAGA,SAAS,cAAc,MAAiD;CACvE,OAAO,IAAI,OAAM,MAAK,EAAE,SAAS,C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