@gitkraken/core-gitlens 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -1
- package/dist/git/cache.d.ts +11 -0
- package/dist/git/cache.js +26 -3
- package/dist/git/cache.js.map +1 -1
- package/dist/git/context.d.ts +3 -2
- package/dist/git/context.js.map +1 -1
- package/dist/git/features.d.ts +1 -1
- package/dist/git/features.js +1 -0
- package/dist/git/features.js.map +1 -1
- package/dist/git/models/reflog.d.ts +6 -0
- package/dist/git/models/reflog.js.map +1 -1
- package/dist/git/models/revision.d.ts +0 -1
- package/dist/git/models/revision.js +1 -2
- package/dist/git/models/revision.js.map +1 -1
- package/dist/git/providers/commits.d.ts +20 -1
- package/dist/git/providers/operations.d.ts +13 -0
- package/dist/git/providers/provider.d.ts +14 -4
- package/dist/git/providers/refs.d.ts +10 -0
- package/dist/git/providers/revision.d.ts +2 -0
- package/dist/git/providers/staging.d.ts +2 -1
- package/dist/git/providers/stash.d.ts +3 -2
- package/dist/git/providers/status.d.ts +4 -0
- package/dist/git/run.types.d.ts +16 -0
- package/dist/git-cli/cliGitProvider.d.ts +24 -3
- package/dist/git-cli/cliGitProvider.js +79 -17
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/exec/commandClassifier.d.ts +31 -0
- package/dist/git-cli/exec/commandClassifier.js +391 -0
- package/dist/git-cli/exec/commandClassifier.js.map +1 -0
- package/dist/git-cli/exec/git.d.ts +24 -3
- package/dist/git-cli/exec/git.js +116 -12
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/parsers/reflogParser.d.ts +7 -0
- package/dist/git-cli/parsers/reflogParser.js +11 -1
- package/dist/git-cli/parsers/reflogParser.js.map +1 -1
- package/dist/git-cli/providers/branches.js +16 -14
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/commits.d.ts +4 -2
- package/dist/git-cli/providers/commits.js +55 -4
- package/dist/git-cli/providers/commits.js.map +1 -1
- package/dist/git-cli/providers/diff.js +4 -4
- package/dist/git-cli/providers/diff.js.map +1 -1
- package/dist/git-cli/providers/operations.d.ts +12 -0
- package/dist/git-cli/providers/operations.js +26 -3
- package/dist/git-cli/providers/operations.js.map +1 -1
- package/dist/git-cli/providers/patch.js +2 -5
- package/dist/git-cli/providers/patch.js.map +1 -1
- package/dist/git-cli/providers/refs.d.ts +5 -0
- package/dist/git-cli/providers/refs.js +26 -1
- package/dist/git-cli/providers/refs.js.map +1 -1
- package/dist/git-cli/providers/remotes.js +3 -2
- package/dist/git-cli/providers/remotes.js.map +1 -1
- package/dist/git-cli/providers/revision.d.ts +2 -0
- package/dist/git-cli/providers/revision.js +11 -0
- package/dist/git-cli/providers/revision.js.map +1 -1
- package/dist/git-cli/providers/staging.d.ts +2 -1
- package/dist/git-cli/providers/staging.js +12 -7
- package/dist/git-cli/providers/staging.js.map +1 -1
- package/dist/git-cli/providers/stash.d.ts +3 -2
- package/dist/git-cli/providers/stash.js +34 -22
- package/dist/git-cli/providers/stash.js.map +1 -1
- package/dist/git-cli/providers/status.d.ts +2 -0
- package/dist/git-cli/providers/status.js +27 -9
- package/dist/git-cli/providers/status.js.map +1 -1
- package/dist/plus/git-github/providers/github/commits.d.ts +4 -2
- package/dist/plus/git-github/providers/github/commits.js +3 -1
- package/dist/plus/git-github/providers/github/commits.js.map +1 -1
- package/dist/plus/git-github/providers/github/revision.d.ts +1 -0
- package/dist/plus/git-github/providers/github/revision.js +5 -0
- package/dist/plus/git-github/providers/github/revision.js.map +1 -1
- package/docs/kepler-git-write-api-parity.md +140 -14
- 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 } from '@gitlens/git/models/reference.js';\nimport type {\n\tBranchContributionsOverview,\n\tGitBranchesSubProvider,\n\tGitBranchMergedStatus,\n} from '@gitlens/git/providers/branches.js';\nimport type { GitCommandPriority } from '@gitlens/git/run.types.js';\nimport {\n\tformatDetachedHeadName,\n\tgetLocalBranchByUpstream,\n\tisDetachedHead,\n\tisRemoteHEAD,\n\tparseRefName,\n\tparseUpstream,\n} from '@gitlens/git/utils/branch.utils.js';\nimport { createConflictDetectionError } from '@gitlens/git/utils/mergeConflicts.utils.js';\nimport { createReference } from '@gitlens/git/utils/reference.utils.js';\nimport { createRevisionRange, shortenRevision } from '@gitlens/git/utils/revision.utils.js';\nimport type { BranchSortOptions } from '@gitlens/git/utils/sorting.js';\nimport { sortBranches, sortContributors } from '@gitlens/git/utils/sorting.js';\nimport { ensureArray, filterMap } from '@gitlens/utils/array.js';\nimport { CancellationError, isCancellationError } from '@gitlens/utils/cancellation.js';\nimport { debounce } from '@gitlens/utils/decorators/debounce.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { getBranchId } from '@gitlens/utils/gitRefs.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport type { PagedResult, PagingOptions } from '@gitlens/utils/paging.js';\nimport { emptyPagedResult, PageableResult } from '@gitlens/utils/paging.js';\nimport { normalizePath } from '@gitlens/utils/path.js';\nimport { getSettledValue } from '@gitlens/utils/promise.js';\nimport type { CacheController } from '@gitlens/utils/promiseCache.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport type { GitResult } from '../exec/exec.types.js';\nimport type { Git } from '../exec/git.js';\nimport { getGitCommandError, gitConfigsBranch, gitConfigsLog, GitError, GitErrors, GitWarnings } from '../exec/git.js';\nimport type { GitMergeConflict } from '../parsers/mergeTreeParser.js';\nimport { parseMergeTreeConflict } from '../parsers/mergeTreeParser.js';\n\n/** Minimum time between writes to the config for last accessed/modified dates */\nconst dateMetadataStaleThresholdMs = 5 * 60 * 1000; // 5 minutes\n\nexport class BranchesGitSubProvider implements GitBranchesSubProvider {\n\tconstructor(\n\t\tprivate readonly context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t) {}\n\n\t@debug()\n\tasync getBranch(\n\t\trepoPath: string,\n\t\tname?: string,\n\t\toptions?: { force?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranch | undefined> {\n\t\tif (options?.force) {\n\t\t\tthis.cache.evictCaches(repoPath, 'branches');\n\t\t}\n\n\t\tif (name != null) {\n\t\t\tconst {\n\t\t\t\tvalues: [branch],\n\t\t\t} = await this.getBranches(repoPath, { filter: b => b.name === name }, cancellation);\n\t\t\treturn branch;\n\t\t}\n\n\t\tconst branchPromise = this.cache.branch.getOrCreate(\n\t\t\trepoPath,\n\t\t\tasync (_cacheable, signal) => {\n\t\t\t\tconst {\n\t\t\t\t\tvalues: [branch],\n\t\t\t\t} = await this.getBranches(repoPath, { filter: b => b.current }, signal);\n\t\t\t\treturn branch ?? this.getCurrentBranch(repoPath, undefined, undefined, signal);\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\n\t\tif (branchPromise == null) {\n\t\t\tconst {\n\t\t\t\tvalues: [branch],\n\t\t\t} = await this.getBranches(repoPath, { filter: b => b.current }, cancellation);\n\t\t\treturn branch ?? this.getCurrentBranch(repoPath, undefined, undefined, cancellation);\n\t\t}\n\n\t\treturn branchPromise;\n\t}\n\n\tprivate async getCurrentBranch(\n\t\trepoPath: string,\n\t\tmetadataMap: Map<string, BranchMetadata> | undefined,\n\t\tordering: string | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranch | undefined> {\n\t\tconst ref = await this.getCurrentBranchReferenceCore(repoPath, ordering, cancellation);\n\t\tif (ref == null) return undefined;\n\n\t\tconst [pausedOpStatusResult, committerDateResult, defaultWorktreePathResult, metadataMapResult] =\n\t\t\tawait Promise.allSettled([\n\t\t\t\tisDetachedHead(ref.name)\n\t\t\t\t\t? this.provider.pausedOps?.getPausedOperationStatus(repoPath, undefined, cancellation)\n\t\t\t\t\t: undefined,\n\t\t\t\tthis.git\n\t\t\t\t\t.run(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcwd: repoPath,\n\t\t\t\t\t\t\tcancellation: cancellation,\n\t\t\t\t\t\t\tconfigs: gitConfigsLog,\n\t\t\t\t\t\t\terrors: 'ignore',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'log',\n\t\t\t\t\t\t'-n1',\n\t\t\t\t\t\t'--format=%ct',\n\t\t\t\t\t\tordering ? `--${ordering}-order` : undefined,\n\t\t\t\t\t\t'--',\n\t\t\t\t\t)\n\t\t\t\t\t.then(result => (result.stdout ? result.stdout.trim() : undefined)),\n\t\t\t\tthis.provider.config.getDefaultWorktreePath?.(repoPath),\n\t\t\t\tmetadataMap != null ? Promise.resolve(metadataMap) : this.getBranchMetadataMap(repoPath),\n\t\t\t]);\n\n\t\tconst committerDate = getSettledValue(committerDateResult);\n\t\tconst pausedOpStatus = getSettledValue(pausedOpStatusResult);\n\t\tconst rebaseStatus = pausedOpStatus?.type === 'rebase' ? pausedOpStatus : undefined;\n\t\tconst defaultWorktreePath = getSettledValue(defaultWorktreePathResult);\n\t\tmetadataMap ??= getSettledValue(metadataMapResult);\n\t\tconst metadata = metadataMap?.get(ref.name);\n\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst branchRefName = rebaseStatus?.incoming.name ?? `refs/heads/${ref.name}`;\n\n\t\tconst branch = new GitBranch(\n\t\t\trepoPath, // Use worktree-specific path for consistent IDs within each worktree\n\t\t\tbranchRefName,\n\t\t\ttrue,\n\t\t\tcommitterDate != null ? new Date(Number(committerDate) * 1000) : undefined,\n\t\t\tmetadata,\n\t\t\tref.sha,\n\t\t\tref.upstream ? { ...ref.upstream, state: { ahead: 0, behind: 0 } } : undefined,\n\t\t\t{ path: repoPath, isDefault: repoPath === defaultWorktreePath },\n\t\t\tundefined,\n\t\t\trebaseStatus != null,\n\t\t);\n\n\t\treturn branch;\n\t}\n\n\t@debug({ args: repoPath => ({ repoPath: repoPath }) })\n\tasync getBranches(\n\t\trepoPath: string,\n\t\toptions?: {\n\t\t\tfilter?: (b: GitBranch) => boolean;\n\t\t\tordering?: 'date' | 'author-date' | 'topo' | null;\n\t\t\tpaging?: PagingOptions;\n\t\t\tsort?: boolean | BranchSortOptions;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<PagedResult<GitBranch>> {\n\t\tif (repoPath == null) return emptyPagedResult;\n\n\t\tconst scope = getScopedLogger();\n\n\t\tconst getCore = async (\n\t\t\tcommonPath: string,\n\t\t\tcacheable?: CacheController,\n\t\t\tsignal?: AbortSignal,\n\t\t): Promise<PagedResult<GitBranch>> => {\n\t\t\t// Prefer the aggregate signal from the cache when present; fall back to the caller's\n\t\t\t// own cancellation when bypassing the cache (e.g. paging-cursor path).\n\t\t\tsignal ??= cancellation;\n\t\t\ttry {\n\t\t\t\tconst [recordsResult, supportedResult, defaultWorktreePathResult, metadataMapResult] =\n\t\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\t\tthis.provider.refs.getRefs(commonPath, signal),\n\t\t\t\t\t\tthis.git.supported('git:for-each-ref'),\n\t\t\t\t\t\tthis.provider.config.getDefaultWorktreePath?.(commonPath),\n\t\t\t\t\t\tthis.getBranchMetadataMap(commonPath),\n\t\t\t\t\t]);\n\n\t\t\t\tconst records = getSettledValue(recordsResult) ?? [];\n\t\t\t\tconst supported = getSettledValue(supportedResult) ?? [];\n\t\t\t\tconst metadataMap = getSettledValue(metadataMapResult) ?? new Map<string, BranchMetadata>();\n\t\t\t\tconst defaultWorktreePath = getSettledValue(defaultWorktreePathResult);\n\t\t\t\tconst worktreePathSupported = supported.includes('git:for-each-ref:worktreePath');\n\n\t\t\t\t// If we don't get any data, assume the repo doesn't have any commits yet so check if we have a current branch\n\t\t\t\tif (!records.length) {\n\t\t\t\t\t// Never CACHE that conclusion. `getRefs` reports a failed enumeration the same way as a\n\t\t\t\t\t// genuinely ref-less repo — an empty array (it invalidates its own entry but doesn't\n\t\t\t\t\t// throw) — so a transient `for-each-ref` failure would otherwise pin this degraded\n\t\t\t\t\t// current-branch-only list in a map with no TTL, and every branch consumer would see a\n\t\t\t\t\t// one-branch repo for the session. A truly empty repo re-reads cheaply, so refusing the\n\t\t\t\t\t// entry costs nothing in the case this is actually meant to serve.\n\t\t\t\t\tcacheable?.invalidate();\n\n\t\t\t\t\tconst current = await this.getCurrentBranch(\n\t\t\t\t\t\tcommonPath,\n\t\t\t\t\t\tmetadataMap,\n\t\t\t\t\t\toptions?.ordering ?? this.context.config?.commits.ordering ?? undefined,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t);\n\t\t\t\t\treturn current != null ? { values: [current] } : emptyPagedResult;\n\t\t\t\t}\n\n\t\t\t\tusing sw = maybeStopWatch(scope, { log: { onlyExit: true, level: 'debug' } });\n\n\t\t\t\tconst branches: GitBranch[] = [];\n\n\t\t\t\tfor (const record of records) {\n\t\t\t\t\tconst fullName = record.name;\n\t\t\t\t\t// Filter to branches and remote-tracking branches; skip tags from the unified records.\n\t\t\t\t\tif (!fullName.startsWith('refs/heads/') && !fullName.startsWith('refs/remotes/')) continue;\n\t\t\t\t\t// Skip HEAD refs in remote branches\n\t\t\t\t\tif (isRemoteHEAD(fullName)) continue;\n\n\t\t\t\t\tconst upstream = parseUpstream(record.upstream, record.upstreamTracking);\n\n\t\t\t\t\tconst metadata = metadataMap.get(parseRefName(fullName).name);\n\t\t\t\t\tconst worktreePath = record.worktreePath ? normalizePath(record.worktreePath) : undefined;\n\n\t\t\t\t\tbranches.push(\n\t\t\t\t\t\tnew GitBranch(\n\t\t\t\t\t\t\tcommonPath,\n\t\t\t\t\t\t\tfullName,\n\t\t\t\t\t\t\tfalse, // Don't trust %(HEAD) for current as it's per-worktree -- we will set it later\n\t\t\t\t\t\t\trecord.committerDate ? new Date(record.committerDate) : undefined,\n\t\t\t\t\t\t\tmetadata,\n\t\t\t\t\t\t\trecord.objectname,\n\t\t\t\t\t\t\tupstream,\n\t\t\t\t\t\t\tworktreePathSupported\n\t\t\t\t\t\t\t\t? worktreePath\n\t\t\t\t\t\t\t\t\t? { path: worktreePath, isDefault: worktreePath === defaultWorktreePath }\n\t\t\t\t\t\t\t\t\t: false\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tsw?.stop({ suffix: ` parsed ${branches.length} branches` });\n\n\t\t\t\t// Pre-populate current branch cache for worktrees based on worktreePath info\n\t\t\t\t// This eliminates the need for rev-parse calls during branch reconstruction\n\t\t\t\tfor (const branch of branches) {\n\t\t\t\t\t// oxlint-disable-next-line typescript/prefer-optional-chain\n\t\t\t\t\tif (branch.worktree && branch.worktree.path) {\n\t\t\t\t\t\tconst { name } = parseRefName(branch.refName);\n\t\t\t\t\t\tconst reference = createReference(name, branch.worktree.path, {\n\t\t\t\t\t\t\trefType: 'branch',\n\t\t\t\t\t\t\tname: name,\n\t\t\t\t\t\t\tid: getBranchId(branch.worktree.path, false, name),\n\t\t\t\t\t\t\tremote: false,\n\t\t\t\t\t\t\tupstream: branch.upstream?.name\n\t\t\t\t\t\t\t\t? { name: branch.upstream.name, missing: branch.upstream.missing }\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\tsha: branch.sha,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.cache.setCurrentBranchReferenceIfAbsent(branch.worktree.path, reference);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn branches.length ? { values: branches } : emptyPagedResult;\n\t\t\t} catch (ex) {\n\t\t\t\t// Signal cache invalidation so the shared cache entry is cleaned up\n\t\t\t\tcacheable?.invalidate();\n\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\treturn emptyPagedResult;\n\t\t\t}\n\t\t};\n\n\t\t// Mapper function that adjusts branches for a specific worktree\n\t\tconst mapBranches = async (\n\t\t\tshared: PagedResult<GitBranch>,\n\t\t\ttargetRepoPath: string,\n\t\t\tcommonPath: string,\n\t\t\tmapperSignal?: AbortSignal,\n\t\t): Promise<PagedResult<GitBranch>> => {\n\t\t\tif (!shared.values.length) return shared;\n\n\t\t\t// Prefer the mapper's per-entry aggregate signal when present; fall back to the\n\t\t\t// caller's own cancellation when bypassing the cache (paging-cursor path).\n\t\t\tmapperSignal ??= cancellation;\n\n\t\t\t// Get current branch info and default worktree path for the target worktree\n\t\t\tconst [currentRefResult, defaultWorktreePathResult] = await Promise.allSettled([\n\t\t\t\tthis.getCurrentBranchReferenceCore(targetRepoPath, undefined, mapperSignal),\n\t\t\t\tthis.provider.config.getDefaultWorktreePath?.(commonPath),\n\t\t\t]);\n\t\t\tconst currentRef = getSettledValue(currentRefResult);\n\t\t\tconst defaultWorktreePath = getSettledValue(defaultWorktreePathResult);\n\t\t\tconst isDetached = currentRef != null && isDetachedHead(currentRef.name);\n\n\t\t\t// Clone branches with correct repoPath and current flag\n\t\t\tconst branches: GitBranch[] = shared.values.map(b => {\n\t\t\t\t// Check if this branch is current in the target worktree\n\t\t\t\tconst isCurrent = !b.remote && b.name === currentRef?.name && !isDetached;\n\n\t\t\t\t// Only create new object if something changed\n\t\t\t\tif (!isCurrent && targetRepoPath === commonPath) return b;\n\n\t\t\t\treturn new GitBranch(\n\t\t\t\t\ttargetRepoPath, // Use target worktree path\n\t\t\t\t\tb.refName,\n\t\t\t\t\tisCurrent,\n\t\t\t\t\tb.date,\n\t\t\t\t\tb.metadata,\n\t\t\t\t\tb.sha,\n\t\t\t\t\tb.upstream,\n\t\t\t\t\t// For current branch, ensure worktree is set (fallback when git doesn't support worktreePath)\n\t\t\t\t\tisCurrent\n\t\t\t\t\t\t? (b.worktree ?? { path: targetRepoPath, isDefault: targetRepoPath === defaultWorktreePath })\n\t\t\t\t\t\t: b.worktree,\n\t\t\t\t\tfalse, // detached - only true for detached HEAD branch itself\n\t\t\t\t\tfalse, // rebasing - only true for detached HEAD branch in rebase\n\t\t\t\t);\n\t\t\t});\n\n\t\t\t// Handle detached HEAD - need to create a special branch for it\n\t\t\tif (isDetached || (currentRef != null && !branches.some(b => b.current))) {\n\t\t\t\tconst metadataMap = await this.getBranchMetadataMap(commonPath);\n\t\t\t\tconst current = await this.getCurrentBranch(\n\t\t\t\t\ttargetRepoPath,\n\t\t\t\t\tmetadataMap,\n\t\t\t\t\toptions?.ordering ?? this.context.config?.commits.ordering ?? undefined,\n\t\t\t\t\tmapperSignal,\n\t\t\t\t);\n\t\t\t\tif (current != null) {\n\t\t\t\t\t// Replace if exists (by id), otherwise prepend\n\t\t\t\t\tconst index = branches.findIndex(b => b.id === current.id);\n\t\t\t\t\tif (index !== -1) {\n\t\t\t\t\t\tbranches[index] = current;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbranches.unshift(current);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { ...shared, values: branches };\n\t\t};\n\n\t\tlet result: PagedResult<GitBranch>;\n\n\t\t// Use paging cursor to bypass cache if paginating\n\t\tif (options?.paging?.cursor != null) {\n\t\t\tconst commonPath = this.cache.getCommonPath(repoPath);\n\t\t\tconst shared = await getCore(commonPath);\n\t\t\t// Still apply the mapper to ensure correct repoPath and current flag for the requesting worktree\n\t\t\tresult = await mapBranches(shared, repoPath, commonPath);\n\t\t} else {\n\t\t\tresult = await this.cache.getBranches(repoPath, getCore, mapBranches, cancellation);\n\t\t}\n\n\t\tif (options?.filter != null) {\n\t\t\tresult = {\n\t\t\t\t...result,\n\t\t\t\tvalues: result.values.filter(options.filter),\n\t\t\t};\n\t\t}\n\n\t\tif (options?.sort) {\n\t\t\tsortBranches(result.values, typeof options.sort === 'boolean' ? undefined : options.sort);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t@debug()\n\tasync getBranchContributionsOverview(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: {\n\t\t\tassociatedPullRequest?: Promise<\n\t\t\t\t{ refs?: { base?: { branch: string } }; stack?: { position: number } } | undefined\n\t\t\t>;\n\t\t\tpriority?: GitCommandPriority;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<BranchContributionsOverview | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst priority = options?.priority;\n\t\tconst priorityOpts = priority != null ? { priority: priority } : undefined;\n\n\t\t// Expensive body — runs only on cache miss. Closes over `mergeTarget` so the cache key\n\t\t// (`${ref}|${mergeTarget}`) fully captures every input that affects the result.\n\t\tconst fetchBody = async (\n\t\t\tmergeTarget: string,\n\t\t\tsignal: AbortSignal | undefined,\n\t\t): Promise<BranchContributionsOverview | undefined> => {\n\t\t\tconst mergeBase = await this.provider.refs.getMergeBase(repoPath, ref, mergeTarget, priorityOpts, signal);\n\t\t\tif (mergeBase == null) return undefined;\n\n\t\t\t// Fetch the merge-base commit's dates in parallel with contributors so consumers\n\t\t\t// (e.g. the graph minimap scope window) don't pay a separate round-trip for them.\n\t\t\t// `allSettled` so a transient failure in one side doesn't drop the overview entirely.\n\t\t\tconst [contributorsSettled, mergeBaseDatesSettled] = await Promise.allSettled([\n\t\t\t\tthis.provider.contributors.getContributors(\n\t\t\t\t\trepoPath,\n\t\t\t\t\tcreateRevisionRange(mergeBase, ref, '..'),\n\t\t\t\t\t{ stats: true },\n\t\t\t\t\tsignal,\n\t\t\t\t),\n\t\t\t\tthis.provider.commits.getCommitDates(repoPath, mergeBase, signal),\n\t\t\t]);\n\n\t\t\tif (signal?.aborted) throw new CancellationError();\n\n\t\t\tconst result = getSettledValue(contributorsSettled) ?? { contributors: [] };\n\t\t\tconst mergeBaseDates = getSettledValue(mergeBaseDatesSettled);\n\n\t\t\tsortContributors(result.contributors, { orderBy: 'score:desc' });\n\n\t\t\tlet totalCommits = 0;\n\t\t\tlet totalFiles = 0;\n\t\t\tlet totalAdditions = 0;\n\t\t\tlet totalDeletions = 0;\n\t\t\tlet firstCommitTimestamp;\n\t\t\tlet latestCommitTimestamp;\n\n\t\t\tfor (const c of result.contributors) {\n\t\t\t\ttotalCommits += c.contributionCount;\n\t\t\t\ttotalFiles += c.stats?.files ?? 0;\n\t\t\t\ttotalAdditions += c.stats?.additions ?? 0;\n\t\t\t\ttotalDeletions += c.stats?.deletions ?? 0;\n\n\t\t\t\tconst firstTimestamp = c.firstCommitDate?.getTime();\n\t\t\t\tconst latestTimestamp = c.latestCommitDate?.getTime();\n\n\t\t\t\tif (firstTimestamp != null || latestTimestamp != null) {\n\t\t\t\t\tfirstCommitTimestamp =\n\t\t\t\t\t\tfirstCommitTimestamp != null\n\t\t\t\t\t\t\t? Math.min(firstCommitTimestamp, firstTimestamp ?? Infinity, latestTimestamp ?? Infinity)\n\t\t\t\t\t\t\t: (firstTimestamp ?? latestTimestamp);\n\n\t\t\t\t\tlatestCommitTimestamp =\n\t\t\t\t\t\tlatestCommitTimestamp != null\n\t\t\t\t\t\t\t? Math.max(latestCommitTimestamp, firstTimestamp ?? -Infinity, latestTimestamp ?? -Infinity)\n\t\t\t\t\t\t\t: (latestTimestamp ?? firstTimestamp);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\trepoPath: repoPath,\n\t\t\t\tbranch: ref,\n\t\t\t\tmergeTarget: mergeTarget,\n\t\t\t\tmergeBase: mergeBase,\n\t\t\t\tmergeBaseDate: mergeBaseDates?.committerDate,\n\n\t\t\t\tcommits: totalCommits,\n\t\t\t\tfiles: totalFiles,\n\t\t\t\tadditions: totalAdditions,\n\t\t\t\tdeletions: totalDeletions,\n\n\t\t\t\tlatestCommitDate: latestCommitTimestamp != null ? new Date(latestCommitTimestamp) : undefined,\n\t\t\t\tfirstCommitDate: firstCommitTimestamp != null ? new Date(firstCommitTimestamp) : undefined,\n\n\t\t\t\tcontributors: result.contributors,\n\t\t\t};\n\t\t};\n\n\t\ttry {\n\t\t\t// Resolve `mergeTarget` through Tier 1 → Tier 2 → Tier 3. The pieces of each tier are\n\t\t\t// already individually cached (`getStoredMergeTargetBranchName`, `getBaseBranchName`,\n\t\t\t// `getDefaultBranchName`), so this resolution path is cheap on warm caches. Only the\n\t\t\t// expensive body below (`getMergeBase` + `getContributors` w/ stats + `getCommitDates`)\n\t\t\t// is wrapped by `cache.getBranchOverview`, keyed on the resolved `mergeTarget` so any\n\t\t\t// caller that resolves to the same target shares; differing targets get independent\n\t\t\t// slots, which is the correctness constraint that previously forced the Tier 2/3 paths\n\t\t\t// to bypass the cache entirely.\n\t\t\tlet mergeTarget: string | undefined;\n\n\t\t\t// Tier 1: Stored merge target (user-set or previously detected from PR).\n\t\t\tconst storedTarget = await this.getStoredMergeTargetBranchName(repoPath, ref);\n\t\t\tif (storedTarget) {\n\t\t\t\tconst validated = await this.provider.refs.getSymbolicReferenceName(\n\t\t\t\t\trepoPath,\n\t\t\t\t\tstoredTarget,\n\t\t\t\t\tpriorityOpts,\n\t\t\t\t\tcancellation,\n\t\t\t\t);\n\t\t\t\tmergeTarget = validated || storedTarget;\n\t\t\t}\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\tmergeTarget = `${branch.remoteName}/${pr.refs.base.branch}`;\n\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// Storing it would leave a stored target naming a branch that no longer exists — and\n\t\t\t\t\t// a stored target beats every other tier, so it would keep winning until cleared by\n\t\t\t\t\t// hand. Use it for this lookup, but don't persist it.\n\t\t\t\t\tif (pr.stack == null) {\n\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// `branchOverviews` invalidation that the write would otherwise trigger: we're\n\t\t\t\t\t\t// about to populate `${ref}|${mergeTarget}` with this exact target, so evicting\n\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// do not affect `baseBranchName`, so no need to skip that target.)\n\t\t\t\t\t\tvoid this.storeMergeTargetBranchName(repoPath, ref, mergeTarget, {\n\t\t\t\t\t\t\tskipInvalidation: ['branchOverviews'],\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Tier 3: Base branch, then default branch.\n\t\t\tmergeTarget ??= await this.getBaseBranchName(repoPath, ref, priorityOpts, cancellation);\n\t\t\tmergeTarget ??= await this.getDefaultBranchName(repoPath, undefined, priorityOpts, cancellation);\n\n\t\t\tif (mergeTarget == null) return undefined;\n\n\t\t\tconst resolvedTarget = mergeTarget;\n\t\t\treturn await this.cache.getBranchOverview(\n\t\t\t\trepoPath,\n\t\t\t\t`${ref}|${resolvedTarget}`,\n\t\t\t\t(_commonPath, _cacheable, signal) => fetchBody(resolvedTarget, signal ?? cancellation),\n\t\t\t\t{ cancellation: cancellation },\n\t\t\t);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@debug()\n\tasync getBranchesWithCommits(\n\t\trepoPath: string,\n\t\tcommits: string[],\n\t\tbranch?: string,\n\t\toptions?:\n\t\t\t| { all?: boolean; commitDate?: Date; mode?: 'contains' | 'pointsAt' }\n\t\t\t| { commitDate?: Date; mode?: 'contains' | 'pointsAt'; remotes?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<string[]> {\n\t\tif (branch != null) {\n\t\t\tconst result = await this.branchesContainingCore(\n\t\t\t\trepoPath,\n\t\t\t\tcommits,\n\t\t\t\t{ mode: 'contains', name: branch },\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst data = result.stdout.trim();\n\t\t\treturn data ? [data] : [];\n\t\t}\n\n\t\tconst result = await this.branchesContainingCore(repoPath, commits, options, cancellation);\n\t\tif (!result.stdout) return [];\n\n\t\treturn filterMap(result.stdout.split('\\n'), b => b.trim() || undefined);\n\t}\n\n\tprivate async branchesContainingCore(\n\t\trepoPath: string,\n\t\trefs: string[],\n\t\toptions?: {\n\t\t\tall?: boolean;\n\t\t\tmode?: 'contains' | 'pointsAt';\n\t\t\tname?: string;\n\t\t\tremotes?: boolean;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitResult> {\n\t\tconst params: string[] = ['branch'];\n\t\tif (options?.all) {\n\t\t\tparams.push('-a');\n\t\t} else if (options?.remotes) {\n\t\t\tparams.push('-r');\n\t\t}\n\n\t\tparams.push('--format=%(refname:short)');\n\n\t\tfor (const ref of refs) {\n\t\t\tparams.push(options?.mode === 'pointsAt' ? `--points-at=${ref}` : `--contains=${ref}`);\n\t\t}\n\n\t\tif (options?.name != null) {\n\t\t\tparams.push(options.name);\n\t\t}\n\n\t\treturn this.git.run(\n\t\t\t{\n\t\t\t\tcwd: repoPath,\n\t\t\t\tcancellation: cancellation,\n\t\t\t\tconfigs: gitConfigsBranch,\n\t\t\t\terrors: 'ignore',\n\t\t\t},\n\t\t\t...params,\n\t\t);\n\t}\n\n\t@debug()\n\tasync getCurrentBranchReference(\n\t\trepoPath: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranchReference | undefined> {\n\t\tlet ref = await this.getCurrentBranchReferenceCore(repoPath, undefined, cancellation);\n\t\tif (ref != null && isDetachedHead(ref.name)) {\n\t\t\tref = createReference(ref.sha!, repoPath, {\n\t\t\t\trefType: 'branch',\n\t\t\t\tname: formatDetachedHeadName(ref.sha!),\n\t\t\t\tid: getBranchId(repoPath, ref.remote, ref.sha!),\n\t\t\t\tremote: ref.remote,\n\t\t\t\tupstream: ref.upstream,\n\t\t\t\tsha: ref.sha,\n\t\t\t});\n\t\t}\n\t\treturn ref;\n\t}\n\n\tprivate getCurrentBranchReferenceCore(\n\t\trepoPath: string,\n\t\tordering?: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranchReference | undefined> {\n\t\treturn this.cache.currentBranchReference.getOrCreate(\n\t\t\trepoPath,\n\t\t\tasync (_cacheable, signal) => {\n\t\t\t\tconst commitOrdering = ordering;\n\n\t\t\t\tlet data: [string, string | undefined] | undefined;\n\t\t\t\tlet result;\n\t\t\t\ttry {\n\t\t\t\t\tresult = await this.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, cancellation: signal, errors: 'throw' },\n\t\t\t\t\t\t'rev-parse',\n\t\t\t\t\t\t'--abbrev-ref',\n\t\t\t\t\t\t'--symbolic-full-name',\n\t\t\t\t\t\t'@',\n\t\t\t\t\t\t'@{u}',\n\t\t\t\t\t\t'--',\n\t\t\t\t\t);\n\t\t\t\t\tdata = [result.stdout, undefined];\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\t\tconst msg: string = ex?.toString() ?? '';\n\t\t\t\t\tif (GitErrors.badRevision.test(msg) || GitWarnings.noUpstream.test(msg)) {\n\t\t\t\t\t\tif (ex.stdout != null && ex.stdout.length !== 0) {\n\t\t\t\t\t\t\tdata = [ex.stdout, undefined];\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tresult = await this.git.run(\n\t\t\t\t\t\t\t\t\t{ cwd: repoPath, cancellation: signal },\n\t\t\t\t\t\t\t\t\t'symbolic-ref',\n\t\t\t\t\t\t\t\t\t'--short',\n\t\t\t\t\t\t\t\t\t'HEAD',\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (result.stdout) {\n\t\t\t\t\t\t\t\t\tdata = [result.stdout.trim(), undefined];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (data == null) {\n\t\t\t\t\t\t\t\tconst symbolicRef = await this.getDefaultBranchName(\n\t\t\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\t\t\t'origin',\n\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (symbolicRef != null) {\n\t\t\t\t\t\t\t\t\tdata = [\n\t\t\t\t\t\t\t\t\t\tsymbolicRef.startsWith('origin/')\n\t\t\t\t\t\t\t\t\t\t\t? symbolicRef.substring('origin/'.length)\n\t\t\t\t\t\t\t\t\t\t\t: symbolicRef,\n\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (data == null) {\n\t\t\t\t\t\t\t\tconst defaultBranch =\n\t\t\t\t\t\t\t\t\t(await this.provider.config.getConfig(repoPath, 'init.defaultBranch')) ?? 'main';\n\t\t\t\t\t\t\t\tconst configMap = await this.provider.config.getConfigRegex(\n\t\t\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\t\t\t`branch\\\\.${defaultBranch}\\\\.+`,\n\t\t\t\t\t\t\t\t\t{ runGitLocally: true },\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tconst remote = configMap.get(`branch.${defaultBranch}.remote`);\n\t\t\t\t\t\t\t\tconst merge = configMap.get(`branch.${defaultBranch}.merge`);\n\t\t\t\t\t\t\t\tconst remoteBranch = merge?.startsWith('refs/heads/')\n\t\t\t\t\t\t\t\t\t? merge.substring('refs/heads/'.length)\n\t\t\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\t\t\t\tdata = [\n\t\t\t\t\t\t\t\t\t`${defaultBranch}${remote && remoteBranch ? `\\n${remote}/${remoteBranch}` : ''}`,\n\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (GitWarnings.headNotABranch.test(msg)) {\n\t\t\t\t\t\tresult = await this.git.run(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcwd: repoPath,\n\t\t\t\t\t\t\t\tcancellation: signal,\n\t\t\t\t\t\t\t\tconfigs: gitConfigsLog,\n\t\t\t\t\t\t\t\terrors: 'ignore',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'log',\n\t\t\t\t\t\t\t'-n1',\n\t\t\t\t\t\t\t'--format=%H',\n\t\t\t\t\t\t\tcommitOrdering ? `--${commitOrdering}-order` : undefined,\n\t\t\t\t\t\t\t'--',\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif (result.completion.status === 'cancelled' || signal?.aborted) {\n\t\t\t\t\t\t\tthrow new CancellationError();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst sha = result.stdout.trim();\n\t\t\t\t\t\tif (sha) {\n\t\t\t\t\t\t\tdata = [`(HEAD detached at ${shortenRevision(sha)})`, sha];\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tLogger.warn(`[${repoPath}] Unable to get current branch: ${ex}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (data == null) return undefined;\n\n\t\t\t\tconst [name, upstream] = data[0].split('\\n');\n\n\t\t\t\treturn createReference(name, repoPath, {\n\t\t\t\t\trefType: 'branch',\n\t\t\t\t\tname: name,\n\t\t\t\t\tid: getBranchId(repoPath, false, name),\n\t\t\t\t\tremote: false,\n\t\t\t\t\tupstream: upstream ? { name: upstream, missing: false } : undefined,\n\t\t\t\t\tsha: data[1],\n\t\t\t\t});\n\t\t\t},\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\t@debug({ exit: true })\n\tasync getDefaultBranchName(\n\t\trepoPath: string | undefined,\n\t\tremote?: string,\n\t\toptions?: { priority?: GitCommandPriority; local?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<string | undefined> {\n\t\tif (repoPath == null) return undefined;\n\n\t\tremote ??= 'origin';\n\t\tconst priority = options?.priority;\n\t\tconst priorityOpts = priority != null ? { priority: priority } : undefined;\n\n\t\t// Local-only: read just the existing local symref, never contacting the remote. Cached under a\n\t\t// `${remote}:local` key — a colon can't appear in a refname component, so it can never collide\n\t\t// with a real remote name used by the networked variant below. Invalidated by the same\n\t\t// remotes/branches cache cascades as the networked lookup.\n\t\tif (options?.local) {\n\t\t\treturn this.cache.getDefaultBranchName(\n\t\t\t\trepoPath,\n\t\t\t\t`${remote}:local`,\n\t\t\t\tasync (commonPath, cacheable, signal) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Bind to the aggregate `signal` (fires only when ALL current callers abort), not\n\t\t\t\t\t\t// this-caller's `cancellation` — otherwise a superseded caller's abort would kill the\n\t\t\t\t\t\t// shared command and reject concurrent riders that never cancelled.\n\t\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t\t{ cwd: commonPath, cancellation: signal ?? cancellation, ...priorityOpts },\n\t\t\t\t\t\t\t'symbolic-ref',\n\t\t\t\t\t\t\t'--short',\n\t\t\t\t\t\t\t`refs/remotes/${remote}/HEAD`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn result.stdout.trim() || undefined;\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\t\t\t// `symbolic-ref` on an absent `refs/remotes/<remote>/HEAD` exits fatal rather than\n\t\t\t\t\t\t// empty, and that message matches no `GitWarnings` entry, so it arrives here as a\n\t\t\t\t\t\t// throw. It is still an ANSWER — the ref genuinely isn't set — and the overwhelmingly\n\t\t\t\t\t\t// common one, so cache it. Invalidating instead means every caller re-probes and the\n\t\t\t\t\t\t// whole point of caching this lookup is lost.\n\t\t\t\t\t\tconst stderr = (ex as { stderr?: string }).stderr ?? '';\n\t\t\t\t\t\tif (stderr.includes('is not a symbolic ref')) return undefined;\n\n\t\t\t\t\t\t// Anything else never produced an answer (spawn failure, queue rejection). This entry\n\t\t\t\t\t\t// has no TTL, so caching that would pin \"no default branch\" for the session.\n\t\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t}\n\n\t\treturn this.cache.getDefaultBranchName(\n\t\t\trepoPath,\n\t\t\tremote,\n\t\t\tasync (commonPath, cacheable, signal) => {\n\t\t\t\tlet retried = false;\n\t\t\t\twhile (true) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t\t{ cwd: commonPath, cancellation: signal ?? cancellation, ...priorityOpts },\n\t\t\t\t\t\t\t'symbolic-ref',\n\t\t\t\t\t\t\t'--short',\n\t\t\t\t\t\t\t`refs/remotes/${remote}/HEAD`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn result.stdout.trim() || undefined;\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\t// Only \"no HEAD ref configured\" is an ANSWER here; every other throw means the lookup\n\t\t\t\t\t\t// never happened. This entry has no TTL, so caching a failure — an offline `ls-remote`\n\t\t\t\t\t\t// being the likely one — would pin \"no default branch\" for the session.\n\t\t\t\t\t\tlet answered = false;\n\t\t\t\t\t\tif (/is not a symbolic ref/.test(ex.stderr)) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tif (!retried) {\n\t\t\t\t\t\t\t\t\tretried = true;\n\t\t\t\t\t\t\t\t\tawait this.git.run(\n\t\t\t\t\t\t\t\t\t\t{ cwd: commonPath, cancellation: signal ?? cancellation, ...priorityOpts },\n\t\t\t\t\t\t\t\t\t\t'remote',\n\t\t\t\t\t\t\t\t\t\t'set-head',\n\t\t\t\t\t\t\t\t\t\t'-a',\n\t\t\t\t\t\t\t\t\t\tremote,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t// This just created `refs/remotes/<remote>/HEAD`, which the `local` variant\n\t\t\t\t\t\t\t\t\t// may already have cached a miss for. The watcher would also catch the new\n\t\t\t\t\t\t\t\t\t// ref, but evict directly so consumers of this package that don't wire up a\n\t\t\t\t\t\t\t\t\t// watcher aren't stuck with that miss.\n\t\t\t\t\t\t\t\t\tthis.cache.deleteDefaultBranchName(commonPath, `${remote}:local`);\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t\t\t\t{ cwd: commonPath, cancellation: signal ?? cancellation, ...priorityOpts },\n\t\t\t\t\t\t\t\t\t'ls-remote',\n\t\t\t\t\t\t\t\t\t'--symref',\n\t\t\t\t\t\t\t\t\tremote,\n\t\t\t\t\t\t\t\t\t'HEAD',\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (result.stdout) {\n\t\t\t\t\t\t\t\t\tconst match = /ref:\\s(\\S+)\\s+HEAD/m.exec(result.stdout);\n\t\t\t\t\t\t\t\t\tif (match != null) {\n\t\t\t\t\t\t\t\t\t\tconst [, branch] = match;\n\t\t\t\t\t\t\t\t\t\treturn `${remote}/${branch.substring('refs/heads/'.length).trim()}`;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// `ls-remote` ran and the remote advertised no HEAD — a real \"none\".\n\t\t\t\t\t\t\t\tanswered = true;\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!answered) {\n\t\t\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\t@debug()\n\tasync createBranch(repoPath: string, name: string, ref: string, options?: { noTracking?: boolean }): Promise<void> {\n\t\tconst args = ['branch', name, ref];\n\t\tif (options?.noTracking) {\n\t\t\targs.push('--no-track');\n\t\t}\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t\t// Evict the cached base so the new branch re-derives its own. The PERSISTED `branch.<ref>.gk-*`\n\t\t\t// keys are left alone: they're dropped when GitLens deletes a branch, never when one is created.\n\t\t\t// Removing them here would mean treating a reused name as proof of a different branch, which\n\t\t\t// nothing can establish — so the trade is that a branch reusing a name deleted outside GitLens\n\t\t\t// inherits the orphaned section.\n\t\t\tthis.cache.deleteBaseBranchName(repoPath, name);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['heads']);\n\t\t} catch (ex) {\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'branch',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew BranchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\taction: 'create',\n\t\t\t\t\t\t\tbranch: name,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t@debug()\n\tasync deleteLocalBranch(repoPath: string, names: string | string[], options?: { force?: boolean }): Promise<void> {\n\t\tconst branches = ensureArray(names);\n\t\tconst args = ['branch', options?.force ? '-D' : '-d', ...branches];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t\tfor (const branch of branches) {\n\t\t\t\tawait this.forgetDeletedBranch(repoPath, branch);\n\t\t\t}\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['heads']);\n\t\t} catch (ex) {\n\t\t\t// A multi-name delete partially succeeds: `git branch -d a bad c` removes `a` and `c`, refuses\n\t\t\t// `bad`, and still exits non-zero — so the loop above never ran for the branches that did go.\n\t\t\t// Clean those up here rather than leave persisted gk metadata behind for a name a later branch\n\t\t\t// can reuse.\n\t\t\tconst anyDeleted = await this.cleanupDeletedBranchMetadata(repoPath, branches);\n\n\t\t\t// The success path's notifications never ran, but some branches DID go — without these the\n\t\t\t// branch caches stay stale and consumers wait on the filesystem watcher (which never fires\n\t\t\t// for a packed ref).\n\t\t\tif (anyDeleted) {\n\t\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['heads']);\n\t\t\t}\n\n\t\t\tif (ex instanceof BranchError) {\n\t\t\t\tthrow ex.update({\n\t\t\t\t\taction: options?.force ? 'force delete' : 'delete',\n\t\t\t\t\tbranch: branches.join(', '),\n\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Classify the failure (e.g. not fully merged) so consumers like the delete wizard can offer a\n\t\t\t// force retry — without this the reason would be undefined and every failure reads as 'other'.\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'branch',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew BranchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\taction: options?.force ? 'force delete' : 'delete',\n\t\t\t\t\t\t\tbranch: branches.join(', '),\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Drops what GitLens keeps for a local branch beyond its ref, for both ways one is deleted\n\t * (`deleteLocalBranch` and `refs.deleteReference`). The persisted gk metadata goes too, not just the\n\t * cached resolution: `getBaseBranchName` reads `branch.<ref>.gk-merge-base` before falling back to the\n\t * reflog, so leaving it behind would hand a later branch reusing this name its predecessor's base.\n\t */\n\tasync forgetDeletedBranch(repoPath: string, name: string): Promise<void> {\n\t\tthis.cache.deleteBaseBranchName(repoPath, name);\n\t\tawait this.provider.config.removeGkConfigBranchSection(repoPath, name);\n\t}\n\n\t/**\n\t * Drops the cached and persisted per-branch metadata for whichever of `names` no longer exists. Only\n\t * for the partial-failure path — one extra `for-each-ref` is cheap while already handling an error,\n\t * and keeps the success path free of it.\n\t *\n\t * Returns whether any of `names` is confirmed gone; `false` when the probe couldn't answer, so a\n\t * spurious notification is never fired on an unrelated failure.\n\t */\n\tprivate async cleanupDeletedBranchMetadata(repoPath: string, names: string[]): Promise<boolean> {\n\t\ttry {\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, errors: 'ignore' },\n\t\t\t\t'for-each-ref',\n\t\t\t\t// Full refname, stripped here rather than by git. NOT `%(refname:short)`: that yields the\n\t\t\t\t// shortest UNAMBIGUOUS name, so a branch with a same-named tag comes back as `heads/<name>`,\n\t\t\t\t// never matches the requested name, and would read as deleted — wiping a live branch's\n\t\t\t\t// metadata. `%(refname:strip=2)` also solves that, but `%(refname)` is the oldest, plainest\n\t\t\t\t// field and needs no assumption about which git version gained `strip`.\n\t\t\t\t'--format=%(refname)',\n\t\t\t\t...names.map(n => `refs/heads/${n}`),\n\t\t\t);\n\t\t\t// `errors: 'ignore'` means a failed probe RESOLVES empty, which is indistinguishable from \"none\n\t\t\t// of them survived\" — and would delete every name's metadata, including user-owned keys like\n\t\t\t// `gk-disposition` and `gk-associated-issues`. Only act on a genuine answer.\n\t\t\t//\n\t\t\t// BOTH conditions: `exitCode !== 0` catches a probe git ran and rejected, `status !== 'exited'`\n\t\t\t// catches one that never produced an answer — a spawn failure or queue rejection (no exit code at\n\t\t\t// all), or a swallowed warning (which carries git's real code, so the exit-code test alone can\n\t\t\t// still read it as \"none survived\").\n\t\t\tif (result.completion.status !== 'exited' || result.exitCode !== 0) return false;\n\n\t\t\tconst prefix = 'refs/heads/';\n\t\t\tconst surviving = new Set(\n\t\t\t\tresult.stdout\n\t\t\t\t\t.split('\\n')\n\t\t\t\t\t.map(l => l.trim())\n\t\t\t\t\t.filter(l => l.startsWith(prefix))\n\t\t\t\t\t.map(l => l.substring(prefix.length)),\n\t\t\t);\n\n\t\t\tlet anyDeleted = false;\n\t\t\tfor (const name of names) {\n\t\t\t\tif (surviving.has(name)) continue;\n\n\t\t\t\tanyDeleted = true;\n\t\t\t\tawait this.forgetDeletedBranch(repoPath, name);\n\t\t\t}\n\n\t\t\treturn anyDeleted;\n\t\t} catch {\n\t\t\t// Best-effort bookkeeping while already unwinding a failure — never mask the original error.\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t@debug()\n\tasync deleteRemoteBranch(repoPath: string, names: string | string[], remote: string): Promise<void> {\n\t\tconst branches = ensureArray(names);\n\t\tconst args = ['push', '-d', remote, ...branches];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['remotes']);\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof BranchError) {\n\t\t\t\tthrow ex.update({\n\t\t\t\t\taction: 'delete',\n\t\t\t\t\tbranch: branches.join(', '),\n\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Classify against the underlying `git push -d` failure modes; map the \"remote ref does not\n\t\t\t// exist\" case onto BranchError's noRemoteReference so consumers get an actionable reason.\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'push',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew BranchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason === 'rejectedRefDoesNotExist' ? 'noRemoteReference' : 'other',\n\t\t\t\t\t\t\taction: 'delete',\n\t\t\t\t\t\t\tbranch: branches.join(', '),\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t@debug()\n\tasync getBranchMergedStatus(\n\t\trepoPath: string,\n\t\tbranch: GitBranchReference,\n\t\tinto: GitBranchReference,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranchMergedStatus> {\n\t\tif (branch.name === into.name || branch.upstream?.name === into.name) {\n\t\t\treturn { merged: false };\n\t\t}\n\n\t\t// Hoisted so it can feed the cache key below (its tip is a 3rd key input) and the mapper\n\t\t// below reuses it instead of resolving it a second time.\n\t\tconst localInto = into.remote\n\t\t\t? await this.getLocalBranchByUpstream(repoPath, into.name, cancellation)\n\t\t\t: undefined;\n\n\t\t// Cache key omits repoPath so worktrees of the same common repo share the cached answer.\n\t\t// Content-keyed on the involved tip shas (the result is a pure function of them), so tip\n\t\t// movement mints a new key instead of relying on eviction; falls back to the name-only\n\t\t// identity when a sha is missing (defensive — the sole caller always supplies both tips).\n\t\tconst cacheKey =\n\t\t\tbranch.sha != null && into.sha != null\n\t\t\t\t? `${branch.remote ? 'r' : 'l'}:${branch.name}@${branch.sha}|${into.remote ? 'r' : 'l'}:${into.name}@${into.sha}${\n\t\t\t\t\t\tlocalInto?.sha != null ? `|L:${localInto.name}@${localInto.sha}` : ''\n\t\t\t\t\t}`\n\t\t\t\t: `${branch.remote ? 'r' : 'l'}:${branch.name}|${into.remote ? 'r' : 'l'}:${into.name}`;\n\n\t\treturn this.cache.getBranchMergedStatus(\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tasync (commonPath, _cacheable, signal) => {\n\t\t\t\tconst result = await this.getBranchMergedStatusCore(commonPath, branch, into, signal);\n\t\t\t\tif (result.merged) return result;\n\n\t\t\t\t// If there is a local branch and it is not the branch we are checking, check if it has been merged into it\n\t\t\t\tif (localInto != null && localInto.name !== branch.name) {\n\t\t\t\t\t// Skip the second full merge-check cycle when the local branch points at the same commit as the remote —\n\t\t\t\t\t// the merge-base/cherry/diff/apply pipeline would produce the same answer we already got for `into` above\n\t\t\t\t\tif (localInto.sha != null && localInto.sha === into.sha) {\n\t\t\t\t\t\treturn { merged: false };\n\t\t\t\t\t}\n\n\t\t\t\t\tconst result = await this.getBranchMergedStatusCore(commonPath, branch, localInto, signal);\n\t\t\t\t\tif (result.merged) {\n\t\t\t\t\t\t// `localBranchOnly` is built against `commonPath` here; the cache mapper rewrites\n\t\t\t\t\t\t// `repoPath`/`id` to the requesting worktree on retrieval.\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\tlocalBranchOnly: createReference(localInto.ref, commonPath, {\n\t\t\t\t\t\t\t\tid: getBranchId(commonPath, localInto.remote, localInto.name),\n\t\t\t\t\t\t\t\trefType: 'branch',\n\t\t\t\t\t\t\t\tname: localInto.name,\n\t\t\t\t\t\t\t\tremote: localInto.remote,\n\t\t\t\t\t\t\t\tupstream: localInto.upstream,\n\t\t\t\t\t\t\t\tsha: localInto.sha,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn { merged: false };\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate async getBranchMergedStatusCore(\n\t\trepoPath: string,\n\t\tbranch: GitBranchReference,\n\t\tinto: GitBranchReference,\n\t\tcancellation?: AbortSignal,\n\t): Promise<Exclude<GitBranchMergedStatus, 'localBranchOnly'>> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\t// Check if branch is direct ancestor (handles FF merges)\n\t\t\ttry {\n\t\t\t\tawait this.git.run(\n\t\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t\t'merge-base',\n\t\t\t\t\t'--is-ancestor',\n\t\t\t\t\tbranch.name,\n\t\t\t\t\tinto.name,\n\t\t\t\t);\n\t\t\t\treturn { merged: true, confidence: 'highest' };\n\t\t\t} catch (ex) {\n\t\t\t\tif (isCancellationError(ex)) throw ex;\n\t\t\t}\n\n\t\t\t// Cherry-pick detection (handles cherry-picks, rebases, etc)\n\t\t\tlet result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation },\n\t\t\t\t'cherry',\n\t\t\t\t'--abbrev',\n\t\t\t\t'-v',\n\t\t\t\tinto.name,\n\t\t\t\tbranch.name,\n\t\t\t);\n\t\t\t// Check if there are no lines or all lines startwith a `-` (i.e. likely merged)\n\t\t\tif (\n\t\t\t\t!result.stdout ||\n\t\t\t\tresult.stdout\n\t\t\t\t\t.trim()\n\t\t\t\t\t.split('\\n')\n\t\t\t\t\t.every(l => l.startsWith('-'))\n\t\t\t) {\n\t\t\t\treturn { merged: true, confidence: 'high' };\n\t\t\t}\n\n\t\t\t// Attempt to detect squash merges by checking if the diff of the branch can be cleanly removed from the target\n\t\t\tconst mergeBase = await this.provider.refs.getMergeBase(\n\t\t\t\trepoPath,\n\t\t\t\tinto.name,\n\t\t\t\tbranch.name,\n\t\t\t\tundefined,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tresult = await this.git.run({ cwd: repoPath, cancellation: cancellation }, 'diff', mergeBase, branch.name);\n\t\t\tif (result.stdout) {\n\t\t\t\t// Create a temporary index file\n\t\t\t\tawait using disposableIndex = await this.provider.staging.createTemporaryIndex(\n\t\t\t\t\trepoPath,\n\t\t\t\t\t'ref',\n\t\t\t\t\tinto.name,\n\t\t\t\t);\n\t\t\t\tconst { env } = disposableIndex;\n\n\t\t\t\tresult = await this.git.run(\n\t\t\t\t\t{\n\t\t\t\t\t\tcwd: repoPath,\n\t\t\t\t\t\tcancellation: cancellation,\n\t\t\t\t\t\tenv: env,\n\t\t\t\t\t\terrors: 'ignore',\n\t\t\t\t\t\tstdin: result.stdout,\n\t\t\t\t\t},\n\t\t\t\t\t'apply',\n\t\t\t\t\t'--cached',\n\t\t\t\t\t'--reverse',\n\t\t\t\t\t'--check',\n\t\t\t\t\t'-',\n\t\t\t\t);\n\n\t\t\t\tif (result.exitCode === 0 && !result.stdout.trim() && !result.stderr?.trim()) {\n\t\t\t\t\treturn { merged: true, confidence: 'medium' };\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { merged: false };\n\t\t} catch (ex) {\n\t\t\tif (Logger.enabled('trace')) {\n\t\t\t\tscope?.error(ex);\n\t\t\t}\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn { merged: false };\n\t\t}\n\t}\n\n\t@debug()\n\tasync getLocalBranchByUpstream(\n\t\trepoPath: string,\n\t\tremoteBranchName: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranch | undefined> {\n\t\tconst branches = new PageableResult<GitBranch>(p =>\n\t\t\tthis.getBranches(repoPath, p != null ? { paging: p } : undefined, cancellation),\n\t\t);\n\t\treturn getLocalBranchByUpstream(remoteBranchName, branches);\n\t}\n\n\t/** Detects potential conflicts when applying commits onto a target branch (git rebase and cherry-pick) */\n\t@debug()\n\tasync getPotentialApplyConflicts(\n\t\trepoPath: string,\n\t\ttargetBranch: string,\n\t\tshas: string[],\n\t\toptions?: { stopOnFirstConflict?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<ConflictDetectionResult> {\n\t\tif (!shas.length) return { status: 'clean' };\n\n\t\tconst cacheKey: ConflictDetectionCacheKey = `apply:${targetBranch}:${shas.join(',')}:${options?.stopOnFirstConflict ?? false}`;\n\t\treturn this.cache.conflictDetection.getOrCreate(\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tasync (_cacheable, signal) => {\n\t\t\t\t// Resolve all parent refs in a single call - fails if any commit is a root commit (no parent)\n\t\t\t\tconst parentRefs = shas.map(c => `${c}^`);\n\t\t\t\tlet parentShas: string[];\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, cancellation: signal, errors: 'throw' },\n\t\t\t\t\t\t'rev-parse',\n\t\t\t\t\t\t...parentRefs,\n\t\t\t\t\t);\n\t\t\t\t\tparentShas = result.stdout.trim().split('\\n');\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\t\t\t\t\t// If any commit doesn't have a parent (root commit), we can't do conflict detection\n\t\t\t\t\treturn createConflictDetectionError('noParent');\n\t\t\t\t}\n\n\t\t\t\tif (parentShas.length !== shas.length) {\n\t\t\t\t\treturn createConflictDetectionError('refNotFound');\n\t\t\t\t}\n\n\t\t\t\tconst commitsWithParents = shas.map((c, i) => ({ sha: c, parent: parentShas[i] }));\n\t\t\t\treturn this.checkForPotentialConflicts(repoPath, commitsWithParents, targetBranch, signal, options);\n\t\t\t},\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\t/** Detects potential conflict when merge a branch into a target branch (git merge) */\n\t@debug()\n\tasync getPotentialMergeConflicts(\n\t\trepoPath: string,\n\t\tbranch: string,\n\t\ttargetBranch: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<ConflictDetectionResult> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst cacheKey: ConflictDetectionCacheKey = `merge:${branch}:${targetBranch}`;\n\t\treturn this.cache.conflictDetection.getOrCreate(\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tasync (_cacheable, signal) => {\n\t\t\t\tif (!(await this.git.supports('git:merge-tree:write-tree'))) {\n\t\t\t\t\treturn createConflictDetectionError('unsupported');\n\t\t\t\t}\n\n\t\t\t\tlet data;\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, cancellation: signal, errors: 'throw' },\n\t\t\t\t\t\t'merge-tree',\n\t\t\t\t\t\t'-z',\n\t\t\t\t\t\t'--name-only',\n\t\t\t\t\t\t'--no-messages',\n\t\t\t\t\t\tbranch,\n\t\t\t\t\t\ttargetBranch,\n\t\t\t\t\t);\n\t\t\t\t\tdata = result.stdout;\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\t\tconst msg: string = ex?.toString() ?? '';\n\t\t\t\t\tif (GitErrors.notAValidObjectName.test(msg)) {\n\t\t\t\t\t\tscope?.error(\n\t\t\t\t\t\t\tex,\n\t\t\t\t\t\t\t`'${targetBranch}' or '${branch}' not found - ensure the branches exist and are fully qualified (e.g. 'refs/heads/main')`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn createConflictDetectionError('refNotFound');\n\t\t\t\t\t} else if (GitErrors.badRevision.test(msg)) {\n\t\t\t\t\t\tscope?.error(ex, `Invalid branch name: ${msg.slice(msg.indexOf(\"'\"))}`);\n\t\t\t\t\t\treturn createConflictDetectionError('refNotFound');\n\t\t\t\t\t} else if (GitErrors.noMergeBase.test(msg)) {\n\t\t\t\t\t\tscope?.error(\n\t\t\t\t\t\t\tex,\n\t\t\t\t\t\t\t`Unable to merge '${branch}' and '${targetBranch}' as they have no common ancestor`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn createConflictDetectionError('noMergeBase');\n\t\t\t\t\t} else if (ex instanceof GitError) {\n\t\t\t\t\t\tdata = ex.stdout;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tscope?.error(ex);\n\t\t\t\t\t\treturn createConflictDetectionError('other');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!data) return { status: 'clean' };\n\n\t\t\t\tconst mergeConflict = parseMergeTreeConflict(data);\n\t\t\t\tif (!mergeConflict.conflicts.length) return { status: 'clean', treeOid: mergeConflict.treeOid };\n\n\t\t\t\treturn {\n\t\t\t\t\tstatus: 'conflicts',\n\t\t\t\t\tconflict: {\n\t\t\t\t\t\trepoPath: repoPath,\n\t\t\t\t\t\tbranch: branch,\n\t\t\t\t\t\ttarget: targetBranch,\n\t\t\t\t\t\tfiles: mergeConflict.conflicts,\n\t\t\t\t\t\tshas: undefined, // Merge conflicts don't have a specific commit SHA\n\t\t\t\t\t},\n\t\t\t\t\ttreeOid: mergeConflict.treeOid,\n\t\t\t\t};\n\t\t\t},\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\t/** Detects conflicts when an autostash is reapplied onto the tree an integration produced */\n\t@debug()\n\tasync getPotentialStashReapplyConflicts(\n\t\trepoPath: string,\n\t\tontoTreeOid: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<ConflictDetectionResult> {\n\t\t// Requires Git v2.38+ for --write-tree with 3-arg form\n\t\t// `runMergeTreeStep` relies on `--merge-base`\n\t\tif (!(await this.git.supports('git:merge-tree:merge-base'))) {\n\t\t\treturn createConflictDetectionError('unsupported');\n\t\t}\n\n\t\t// git stash create writes commit objects but touches neither the working tree nor the stash ref, and\n\t\t// captures tracked changes only — which is exactly what autostash does\n\t\tlet stashSha: string;\n\t\ttry {\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t'stash',\n\t\t\t\t'create',\n\t\t\t);\n\t\t\tstashSha = result.stdout.trim();\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn createConflictDetectionError('other');\n\t\t}\n\n\t\tif (!stashSha) return { status: 'clean' };\n\n\t\t// Key on what the simulation actually consumes — the stash's tree and its first parent (the HEAD it was\n\t\t// taken against, and so the merge base). The stash SHA itself embeds a commit timestamp, so two runs over\n\t\t// an identical tree produce different SHAs and a SHA-keyed entry could never be hit.\n\t\tlet stashTree: string;\n\t\tlet stashParent: string;\n\t\ttry {\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t'rev-parse',\n\t\t\t\t`${stashSha}^{tree}`,\n\t\t\t\t`${stashSha}^`,\n\t\t\t);\n\t\t\t[stashTree, stashParent] = result.stdout.trim().split('\\n');\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn createConflictDetectionError('other');\n\t\t}\n\n\t\tconst cacheKey: ConflictDetectionCacheKey = `reapply:${ontoTreeOid}:${stashTree}.${stashParent}`;\n\t\treturn this.cache.conflictDetection.getOrCreate(\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tasync (_cacheable, signal) => {\n\t\t\t\t// The stash commit's first parent is the HEAD it was taken against, which is the correct merge\n\t\t\t\t// base for a reapply — ours is the post-integration tree, theirs is the stash\n\t\t\t\tconst step = await this.runMergeTreeStep(repoPath, `${stashSha}^`, ontoTreeOid, stashSha, signal);\n\t\t\t\tif (!step.ok) return createConflictDetectionError(step.reason);\n\n\t\t\t\tif (!step.result.conflicts.length) return { status: 'clean', treeOid: step.result.treeOid };\n\n\t\t\t\treturn {\n\t\t\t\t\tstatus: 'conflicts',\n\t\t\t\t\tconflict: {\n\t\t\t\t\t\trepoPath: repoPath,\n\t\t\t\t\t\tbranch: stashSha,\n\t\t\t\t\t\ttarget: ontoTreeOid,\n\t\t\t\t\t\tfiles: step.result.conflicts,\n\t\t\t\t\t\tshas: undefined,\n\t\t\t\t\t},\n\t\t\t\t\ttreeOid: step.result.treeOid,\n\t\t\t\t};\n\t\t\t},\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\tprivate async runMergeTreeStep(\n\t\trepoPath: string,\n\t\tbase: string,\n\t\tours: string,\n\t\ttheirs: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<{ ok: true; result: GitMergeConflict } | { ok: false; reason: ConflictDetectionErrorReason }> {\n\t\tconst scope = getScopedLogger();\n\n\t\tlet data;\n\t\ttry {\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t'merge-tree',\n\t\t\t\t'--write-tree',\n\t\t\t\t'-z',\n\t\t\t\t'--name-only',\n\t\t\t\t'--no-messages',\n\t\t\t\t`--merge-base=${base}`,\n\t\t\t\tours,\n\t\t\t\ttheirs,\n\t\t\t);\n\t\t\tdata = result.stdout;\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\tconst msg: string = ex?.toString() ?? '';\n\t\t\tif (GitErrors.notAValidObjectName.test(msg)) {\n\t\t\t\tscope?.error(ex, `'${ours}' or '${theirs}' not found - ensure the branches/commits exist`);\n\t\t\t\treturn { ok: false, reason: 'refNotFound' };\n\t\t\t} else if (GitErrors.badRevision.test(msg)) {\n\t\t\t\tscope?.error(ex, `Invalid revision: ${msg.slice(msg.indexOf(\"'\"))}`);\n\t\t\t\treturn { ok: false, reason: 'refNotFound' };\n\t\t\t} else if (GitErrors.noMergeBase.test(msg)) {\n\t\t\t\tscope?.error(ex, `Unable to merge '${ours}' and '${theirs}' as they have no common ancestor`);\n\t\t\t\treturn { ok: false, reason: 'noMergeBase' };\n\t\t\t} else if (ex instanceof GitError) {\n\t\t\t\tdata = ex.stdout;\n\t\t\t} else {\n\t\t\t\tscope?.error(ex, 'Failed to execute merge-tree for conflict check');\n\t\t\t\treturn { ok: false, reason: 'other' };\n\t\t\t}\n\t\t}\n\n\t\treturn { ok: true, result: parseMergeTreeConflict(data ?? '') };\n\t}\n\n\tprivate async checkForPotentialConflicts(\n\t\trepoPath: string,\n\t\tcommits: Iterable<{ sha: string; parent: string }>,\n\t\ttargetBranch: string,\n\t\tcancellation?: AbortSignal,\n\t\toptions?: { stopOnFirstConflict?: boolean },\n\t): Promise<ConflictDetectionResult> {\n\t\tconst scope = getScopedLogger();\n\n\t\t// Requires Git v2.38+ for --write-tree with 3-arg form\n\t\t// `runMergeTreeStep` relies on `--merge-base`\n\t\tif (!(await this.git.supports('git:merge-tree:merge-base'))) {\n\t\t\treturn createConflictDetectionError('unsupported');\n\t\t}\n\n\t\tlet currentTreeOid: string;\n\t\ttry {\n\t\t\t// Get the initial target branch tree OID\n\t\t\tconst treeResult = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t'rev-parse',\n\t\t\t\t`${targetBranch}^{tree}`,\n\t\t\t);\n\t\t\tcurrentTreeOid = treeResult.stdout.trim();\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\tscope?.error(ex, `Failed to resolve target branch '${targetBranch}'`);\n\t\t\treturn createConflictDetectionError('refNotFound');\n\t\t}\n\n\t\tconst conflictingShas: string[] = [];\n\t\tconst conflictingFilePaths = new Set<string>();\n\n\t\tfor (const commit of commits) {\n\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t// Use merge-tree --write-tree with --merge-base to simulate cherry-pick:\n\t\t\t// merge-tree --write-tree --merge-base=<commit-parent> <current-tree> <commit>\n\t\t\t// This performs a 3-way merge where:\n\t\t\t// - base = commit.parent (where the commit started)\n\t\t\t// - ours = currentTreeOid (current state of the target)\n\t\t\t// - theirs = commit.sha (what we're cherry-picking)\n\t\t\tconst step = await this.runMergeTreeStep(repoPath, commit.parent, currentTreeOid, commit.sha, cancellation);\n\t\t\tif (!step.ok) return createConflictDetectionError(step.reason);\n\n\t\t\tconst mergeConflict = step.result;\n\n\t\t\tif (mergeConflict.conflicts.length) {\n\t\t\t\tconflictingShas.push(commit.sha);\n\t\t\t\tfor (const file of mergeConflict.conflicts) {\n\t\t\t\t\tconflictingFilePaths.add(file.path);\n\t\t\t\t}\n\n\t\t\t\tif (options?.stopOnFirstConflict) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstatus: 'conflicts',\n\t\t\t\t\t\tconflict: {\n\t\t\t\t\t\t\trepoPath: repoPath,\n\t\t\t\t\t\t\tbranch: commit.sha,\n\t\t\t\t\t\t\ttarget: targetBranch,\n\t\t\t\t\t\t\tfiles: mergeConflict.conflicts,\n\t\t\t\t\t\t\tshas: [commit.sha],\n\t\t\t\t\t\t},\n\t\t\t\t\t\tstoppedOnFirstConflict: true,\n\t\t\t\t\t\ttreeOid: mergeConflict.treeOid || undefined,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Update currentTreeOid to the result tree OID for the next iteration\n\t\t\t// This works even when there are conflicts - the tree contains conflict markers\n\t\t\tif (mergeConflict.treeOid) {\n\t\t\t\tcurrentTreeOid = mergeConflict.treeOid;\n\t\t\t}\n\t\t}\n\n\t\tif (conflictingShas.length) {\n\t\t\treturn {\n\t\t\t\tstatus: 'conflicts',\n\t\t\t\tconflict: {\n\t\t\t\t\trepoPath: repoPath,\n\t\t\t\t\tbranch: conflictingShas[0],\n\t\t\t\t\ttarget: targetBranch,\n\t\t\t\t\tfiles: Array.from(conflictingFilePaths, path => ({ path: path })),\n\t\t\t\t\tshas: conflictingShas,\n\t\t\t\t},\n\t\t\t\tstoppedOnFirstConflict: false,\n\t\t\t\ttreeOid: currentTreeOid,\n\t\t\t};\n\t\t}\n\n\t\treturn { status: 'clean', treeOid: currentTreeOid };\n\t}\n\n\t@debug({ exit: true })\n\tgetBaseBranchName(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: { priority?: GitCommandPriority },\n\t\tcancellation?: AbortSignal,\n\t): Promise<string | undefined> {\n\t\tconst priority = options?.priority;\n\t\tconst priorityOpts = priority != null ? { priority: priority } : undefined;\n\n\t\treturn this.cache.getBaseBranchName(\n\t\t\trepoPath,\n\t\t\tref,\n\t\t\tasync (commonPath, cacheable, signal) => {\n\t\t\t\ttry {\n\t\t\t\t\t// getGkConfig has built-in fallback to regular config for backward compatibility\n\t\t\t\t\tlet mergeBase = await this.provider.config.getGkConfig(commonPath, `branch.${ref}.gk-merge-base`);\n\t\t\t\t\tlet update = false;\n\n\t\t\t\t\t// Also check vscode-merge-base in regular config (VS Code compatibility)\n\t\t\t\t\tif (mergeBase == null) {\n\t\t\t\t\t\tmergeBase = await this.provider.config.getConfig(commonPath, `branch.${ref}.vscode-merge-base`);\n\t\t\t\t\t\tupdate = mergeBase != null;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (mergeBase != null) {\n\t\t\t\t\t\tconst branch = await this.provider.refs.getSymbolicReferenceName(\n\t\t\t\t\t\t\tcommonPath,\n\t\t\t\t\t\t\tmergeBase,\n\t\t\t\t\t\t\tpriorityOpts,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (branch != null) {\n\t\t\t\t\t\t\tif (update) {\n\t\t\t\t\t\t\t\t// Self-write: the value we're storing is exactly what this factory is\n\t\t\t\t\t\t\t\t// returning, so any in-flight `branchOverviews` or `baseBranchName` entry\n\t\t\t\t\t\t\t\t// being populated against this resolution should NOT be evicted.\n\t\t\t\t\t\t\t\tvoid this.storeBaseBranchName(commonPath, ref, branch, {\n\t\t\t\t\t\t\t\t\tskipInvalidation: ['branchOverviews', 'baseBranchName'],\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn branch;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch {}\n\n\t\t\t\tconst reflog = await this.getBaseBranchFromReflog(\n\t\t\t\t\tcommonPath,\n\t\t\t\t\tref,\n\t\t\t\t\t{ upstream: true, priority: priority },\n\t\t\t\t\tsignal,\n\t\t\t\t);\n\t\t\t\tif (reflog.branch != null) {\n\t\t\t\t\t// Self-write: see comment on the migration path above.\n\t\t\t\t\tvoid this.storeBaseBranchName(commonPath, ref, reflog.branch, {\n\t\t\t\t\t\tskipInvalidation: ['branchOverviews', 'baseBranchName'],\n\t\t\t\t\t});\n\t\t\t\t\treturn reflog.branch;\n\t\t\t\t}\n\n\t\t\t\t// This entry has no TTL and the `'branches'` cascade no longer clears it (a tip move can't\n\t\t\t\t// change a base), so a failed read cached as `undefined` would read as \"no base branch\" for\n\t\t\t\t// the rest of the session. Only a reflog that actually RAN and found nothing is an answer.\n\t\t\t\tif (reflog.failed) {\n\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\t/**\n\t * `failed` separates \"the reflog ran and had no answer\" from \"the read never happened\" — the caller\n\t * caches the former forever and must not cache the latter.\n\t */\n\tprivate async getBaseBranchFromReflog(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: { upstream: true; priority?: GitCommandPriority },\n\t\tcancellation?: AbortSignal,\n\t): Promise<{ branch: string | undefined; failed: boolean }> {\n\t\tconst priority = options?.priority;\n\t\tconst priorityOpts = priority != null ? { priority: priority } : undefined;\n\n\t\ttry {\n\t\t\tlet result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, ...priorityOpts },\n\t\t\t\t'reflog',\n\t\t\t\tref,\n\t\t\t\t'--grep-reflog=branch: Created from *.',\n\t\t\t);\n\n\t\t\tlet entries = result.stdout.split('\\n').filter(entry => Boolean(entry));\n\t\t\tif (entries.length !== 1) return { branch: undefined, failed: false };\n\n\t\t\t// Check if branch created from an explicit branch\n\t\t\tlet match = entries[0].match(/branch: Created from (.*)$/);\n\t\t\tif (match?.length === 2) {\n\t\t\t\tlet name: string | undefined = match[1];\n\t\t\t\tif (name !== 'HEAD') {\n\t\t\t\t\tif (options?.upstream) {\n\t\t\t\t\t\tconst upstream = await this.provider.refs.getSymbolicReferenceName(\n\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\t`${name}@{u}`,\n\t\t\t\t\t\t\tpriorityOpts,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (upstream) return { branch: upstream, failed: false };\n\t\t\t\t\t}\n\n\t\t\t\t\tname = await this.provider.refs.getSymbolicReferenceName(repoPath, name, priorityOpts);\n\t\t\t\t\tif (name) return { branch: name, failed: false };\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Check if branch was created from HEAD\n\t\t\tresult = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, ...priorityOpts },\n\t\t\t\t'reflog',\n\t\t\t\t'HEAD',\n\t\t\t\t`--grep-reflog=checkout: moving from .* to ${ref.replace('refs/heads/', '')}`,\n\t\t\t);\n\n\t\t\tentries = result.stdout.split('\\n').filter(entry => Boolean(entry));\n\t\t\tif (!entries.length) return { branch: undefined, failed: false };\n\n\t\t\tmatch = entries.at(-1)!.match(/checkout: moving from ([^\\s]+)\\s/);\n\t\t\tif (match?.length === 2) {\n\t\t\t\tlet name: string | undefined = match[1];\n\t\t\t\tif (options?.upstream) {\n\t\t\t\t\tconst upstream = await this.provider.refs.getSymbolicReferenceName(\n\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t`${name}@{u}`,\n\t\t\t\t\t\tpriorityOpts,\n\t\t\t\t\t);\n\t\t\t\t\tif (upstream) return { branch: upstream, failed: false };\n\t\t\t\t}\n\n\t\t\t\tname = await this.provider.refs.getSymbolicReferenceName(repoPath, name, priorityOpts);\n\t\t\t\tif (name) return { branch: name, failed: false };\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t// The reads use default error handling, so a spawn failure, queue rejection or swallowed\n\t\t\t// `GitWarnings` match lands here rather than producing an empty answer.\n\t\t\treturn { branch: undefined, failed: true };\n\t\t}\n\n\t\treturn { branch: undefined, failed: false };\n\t}\n\n\t@debug({ exit: true })\n\tasync getStoredMergeTargetBranchName(repoPath: string, ref: string): Promise<string | undefined> {\n\t\tconst target =\n\t\t\t(await this.getStoredUserMergeTargetBranchName?.(repoPath, ref)) ??\n\t\t\t(await this.getStoredDetectedMergeTargetBranchName?.(repoPath, ref));\n\t\treturn target?.trim() || undefined;\n\t}\n\n\t@debug({ exit: true })\n\tasync getStoredDetectedMergeTargetBranchName(repoPath: string, ref: string): Promise<string | undefined> {\n\t\tconst target =\n\t\t\t(await this.provider.config.getGkConfig(repoPath, `branch.${ref}.gk-merge-target`)) ??\n\t\t\t(await this.provider.config.getGkConfig(repoPath, `branch.${ref}.gk-target-base`)); // legacy key\n\t\treturn target?.trim() || undefined;\n\t}\n\n\t@debug()\n\tasync getStoredUserMergeTargetBranchName(repoPath: string, ref: string): Promise<string | undefined> {\n\t\tconst target = await this.provider.config.getGkConfig(repoPath, `branch.${ref}.gk-merge-target-user`);\n\t\treturn target?.trim() || undefined;\n\t}\n\n\t/** Updates the last accessed timestamp for the current branch */\n\t@debounce(2.5 * 60 * 1000)\n\t@debug()\n\tasync onCurrentBranchAccessed(repoPath: string): Promise<void> {\n\t\tconst branch = await this.getBranch(repoPath);\n\t\tif (branch == null || branch.remote || branch.detached) return;\n\n\t\tawait this.storeBranchMetadata(repoPath, 'gk-last-accessed', branch.name, new Date());\n\t}\n\n\t/** Updates the last accessed and modified timestamp for the current branch */\n\t@debounce(2.5 * 60 * 1000)\n\t@debug()\n\tasync onCurrentBranchModified(repoPath: string): Promise<void> {\n\t\tconst branch = await this.getBranch(repoPath);\n\t\tif (branch == null || branch.remote || branch.detached) return;\n\n\t\tconst now = new Date();\n\t\tawait this.storeBranchMetadata(repoPath, 'gk-last-accessed', branch.name, now);\n\t\tawait this.storeBranchMetadata(repoPath, 'gk-last-modified', branch.name, now);\n\t}\n\n\t/** Updates the agent last activity timestamp for the current branch */\n\t@debounce(2.5 * 60 * 1000)\n\t@debug()\n\tasync onCurrentBranchAgentActivity(repoPath: string): Promise<void> {\n\t\tconst branch = await this.getBranch(repoPath);\n\t\tif (branch == null || branch.remote || branch.detached) return;\n\n\t\tawait this.storeBranchMetadata(repoPath, 'gk-agent-last-activity', branch.name, new Date());\n\t}\n\n\t@debug()\n\tasync renameBranch(repoPath: string, oldName: string, newName: string): Promise<void> {\n\t\tconst args = ['branch', '-m', oldName, newName];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t\t// The branch keeps its identity across a rename, so move its stored gk metadata with it —\n\t\t\t// otherwise the new name re-derives a base it already had, and the old name is left holding\n\t\t\t// metadata for a branch that no longer exists under it.\n\t\t\tawait this.provider.config.renameGkConfigBranchSection(repoPath, oldName, newName);\n\t\t\t// Old name's entry is now orphaned; the new name must not inherit a predecessor's base\n\t\t\tthis.cache.deleteBaseBranchName(repoPath, oldName);\n\t\t\tthis.cache.deleteBaseBranchName(repoPath, newName);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['heads']);\n\t\t} catch (ex) {\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'branch',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew BranchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\taction: 'rename',\n\t\t\t\t\t\t\tbranch: oldName,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t@debug()\n\tasync setUpstreamBranch(repoPath: string, name: string, upstream: string | undefined): Promise<void> {\n\t\tconst args =\n\t\t\tupstream == null ? ['branch', '--unset-upstream', name] : ['branch', '--set-upstream-to', upstream, name];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['heads']);\n\t\t} catch (ex) {\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'branch',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew BranchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\taction: upstream == null ? 'unset upstream of' : `set upstream to '${upstream}' for`,\n\t\t\t\t\t\t\tbranch: name,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t@debug()\n\tasync storeBaseBranchName(\n\t\trepoPath: string,\n\t\tref: string,\n\t\tbase: string,\n\t\toptions?: { skipInvalidation?: readonly GkConfigInvalidationTarget[] },\n\t): Promise<void> {\n\t\tawait this.provider.config.setGkConfig(repoPath, `branch.${ref}.gk-merge-base`, base, options);\n\t}\n\n\t@debug()\n\tasync storeMergeTargetBranchName(\n\t\trepoPath: string,\n\t\tref: string,\n\t\ttarget: string,\n\t\toptions?: { skipInvalidation?: readonly GkConfigInvalidationTarget[] },\n\t): Promise<void> {\n\t\tawait this.provider.config.setGkConfig(repoPath, `branch.${ref}.gk-merge-target`, target, options);\n\t}\n\n\t@debug()\n\tasync storeUserMergeTargetBranchName(repoPath: string, ref: string, target: string | undefined): Promise<void> {\n\t\tawait this.provider.config.setGkConfig(repoPath, `branch.${ref}.gk-merge-target-user`, target);\n\t}\n\n\t/**\n\t * Gets all branch metadata (dates and disposition) from git config in a single batch operation.\n\t * @returns A map of branch name to metadata.\n\t */\n\tprivate getBranchMetadataMap(repoPath: string): Promise<Map<string, BranchMetadata>> {\n\t\treturn this.cache.getBranchMetadataMap(repoPath, async commonPath => {\n\t\t\tconst scope = getScopedLogger();\n\t\t\tconst metadataMap = new Map<string, BranchMetadata>();\n\n\t\t\ttry {\n\t\t\t\t// Use git config --get-regexp to load all gk-* branch metadata in one call\n\t\t\t\tconst configMap = await this.provider.config.getGkConfigRegex(\n\t\t\t\t\tcommonPath,\n\t\t\t\t\t'^branch\\\\..*\\\\.gk-(last-(accessed|modified)|disposition|agent-last-activity)$',\n\t\t\t\t);\n\t\t\t\tif (!configMap.size) return metadataMap;\n\n\t\t\t\tfor (const [key, value] of configMap) {\n\t\t\t\t\t// Extract branch name and metadata key from \"branch.{name}.gk-{key}\"\n\t\t\t\t\tif (!key.startsWith('branch.')) continue;\n\n\t\t\t\t\tconst keyParts = key.split('.');\n\t\t\t\t\tif (keyParts.length < 3) continue;\n\n\t\t\t\t\t// Branch name is everything between \"branch.\" and the last \".gk-*\"\n\t\t\t\t\tconst metaKey = keyParts.at(-1);\n\t\t\t\t\tconst branchName = keyParts.slice(1, -1).join('.');\n\n\t\t\t\t\tlet metadata = metadataMap.get(branchName);\n\t\t\t\t\tif (metadata == null) {\n\t\t\t\t\t\tmetadata = {};\n\t\t\t\t\t\tmetadataMap.set(branchName, metadata);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (metaKey === 'gk-last-accessed') {\n\t\t\t\t\t\tmetadata.lastAccessedAt = value;\n\t\t\t\t\t} else if (metaKey === 'gk-last-modified') {\n\t\t\t\t\t\tmetadata.lastModifiedAt = value;\n\t\t\t\t\t} else if (metaKey === 'gk-agent-last-activity') {\n\t\t\t\t\t\tmetadata.agentLastActivityAt = value;\n\t\t\t\t\t} else if (metaKey === 'gk-disposition') {\n\t\t\t\t\t\tif (value === 'starred' || value === 'archived') {\n\t\t\t\t\t\t\tmetadata.disposition = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (ex) {\n\t\t\t\tdebugger;\n\t\t\t\tscope?.error(ex);\n\t\t\t}\n\n\t\t\treturn metadataMap;\n\t\t});\n\t}\n\n\tprivate async storeBranchMetadata(\n\t\trepoPath: string,\n\t\tkey: 'gk-last-accessed' | 'gk-last-modified' | 'gk-agent-last-activity',\n\t\tref: string,\n\t\tdate: Date,\n\t): Promise<void> {\n\t\tconst value = await this.provider.config.getGkConfig(repoPath, `branch.${ref}.${key}`);\n\t\t// Skip if incoming date is not at least 5 minutes newer than stored date\n\t\tif (value != null && date.getTime() - new Date(value).getTime() < dateMetadataStaleThresholdMs) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn this.provider.config.setGkConfig(repoPath, `branch.${ref}.${key}`, date.toISOString());\n\t}\n\n\tasync setBranchDisposition(\n\t\trepoPath: string,\n\t\tbranchName: string,\n\t\tdisposition: BranchDisposition | undefined,\n\t): Promise<void> {\n\t\tawait this.provider.config.setGkConfig(repoPath, `branch.${branchName}.gk-disposition`, disposition);\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['starred']);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAM,+BAA+B;AAErC,IAAa,yBAAb,MAAsE;CAEnD;CACA;CACA;CACA;CAJlB,YACC,SACA,KACA,OACA,UACC;EAJgB,KAAA,UAAA;EACA,KAAA,MAAA;EACA,KAAA,QAAA;EACA,KAAA,WAAA;CACf;CAEH,MACM,UACL,UACA,MACA,SACA,cACiC;EACjC,IAAI,SAAS,OACZ,KAAK,MAAM,YAAY,UAAU,UAAU;EAG5C,IAAI,QAAQ,MAAM;GACjB,MAAM,EACL,QAAQ,CAAC,YACN,MAAM,KAAK,YAAY,UAAU,EAAE,SAAQ,MAAK,EAAE,SAAS,KAAK,GAAG,YAAY;GACnF,OAAO;EACR;EAEA,MAAM,gBAAgB,KAAK,MAAM,OAAO,YACvC,UACA,OAAO,YAAY,WAAW;GAC7B,MAAM,EACL,QAAQ,CAAC,YACN,MAAM,KAAK,YAAY,UAAU,EAAE,SAAQ,MAAK,EAAE,QAAQ,GAAG,MAAM;GACvE,OAAO,UAAU,KAAK,iBAAiB,UAAU,KAAA,GAAW,KAAA,GAAW,MAAM;EAC9E,GACA,YACD;EAEA,IAAI,iBAAiB,MAAM;GAC1B,MAAM,EACL,QAAQ,CAAC,YACN,MAAM,KAAK,YAAY,UAAU,EAAE,SAAQ,MAAK,EAAE,QAAQ,GAAG,YAAY;GAC7E,OAAO,UAAU,KAAK,iBAAiB,UAAU,KAAA,GAAW,KAAA,GAAW,YAAY;EACpF;EAEA,OAAO;CACR;CAEA,MAAc,iBACb,UACA,aACA,UACA,cACiC;EACjC,MAAM,MAAM,MAAM,KAAK,8BAA8B,UAAU,UAAU,YAAY;EACrF,IAAI,OAAO,MAAM,OAAO,KAAA;E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CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,gBAAA,IAAA;AAgCN,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,qBAAA,IAAA;AA0BN,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,uBAAA,IAAA;AAUN,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,8BAAA,IAAA;AAUN,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,kCAAA,IAAA"}
|
|
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 } from '@gitlens/git/models/reference.js';\nimport type {\n\tBranchContributionsOverview,\n\tGitBranchesSubProvider,\n\tGitBranchMergedStatus,\n} from '@gitlens/git/providers/branches.js';\nimport type { GitCommandPriority } from '@gitlens/git/run.types.js';\nimport {\n\tformatDetachedHeadName,\n\tgetLocalBranchByUpstream,\n\tisDetachedHead,\n\tisRemoteHEAD,\n\tparseRefName,\n\tparseUpstream,\n} from '@gitlens/git/utils/branch.utils.js';\nimport { createConflictDetectionError } from '@gitlens/git/utils/mergeConflicts.utils.js';\nimport { createReference } from '@gitlens/git/utils/reference.utils.js';\nimport { createRevisionRange, shortenRevision } from '@gitlens/git/utils/revision.utils.js';\nimport type { BranchSortOptions } from '@gitlens/git/utils/sorting.js';\nimport { sortBranches, sortContributors } from '@gitlens/git/utils/sorting.js';\nimport { ensureArray, filterMap } from '@gitlens/utils/array.js';\nimport { CancellationError, isCancellationError } from '@gitlens/utils/cancellation.js';\nimport { debounce } from '@gitlens/utils/decorators/debounce.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { getBranchId } from '@gitlens/utils/gitRefs.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport type { PagedResult, PagingOptions } from '@gitlens/utils/paging.js';\nimport { emptyPagedResult, PageableResult } from '@gitlens/utils/paging.js';\nimport { normalizePath } from '@gitlens/utils/path.js';\nimport { getSettledValue } from '@gitlens/utils/promise.js';\nimport type { CacheController } from '@gitlens/utils/promiseCache.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport type { GitResult } from '../exec/exec.types.js';\nimport type { Git } from '../exec/git.js';\nimport { getGitCommandError, gitConfigsBranch, gitConfigsLog, GitError, GitErrors, GitWarnings } from '../exec/git.js';\nimport type { GitMergeConflict } from '../parsers/mergeTreeParser.js';\nimport { parseMergeTreeConflict } from '../parsers/mergeTreeParser.js';\n\n/** Minimum time between writes to the config for last accessed/modified dates */\nconst dateMetadataStaleThresholdMs = 5 * 60 * 1000; // 5 minutes\n\nexport class BranchesGitSubProvider implements GitBranchesSubProvider {\n\tconstructor(\n\t\tprivate readonly context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t) {}\n\n\t@debug()\n\tasync getBranch(\n\t\trepoPath: string,\n\t\tname?: string,\n\t\toptions?: { force?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranch | undefined> {\n\t\tif (options?.force) {\n\t\t\tthis.cache.evictCaches(repoPath, 'branches');\n\t\t}\n\n\t\tif (name != null) {\n\t\t\tconst {\n\t\t\t\tvalues: [branch],\n\t\t\t} = await this.getBranches(repoPath, { filter: b => b.name === name }, cancellation);\n\t\t\treturn branch;\n\t\t}\n\n\t\tconst branchPromise = this.cache.branch.getOrCreate(\n\t\t\trepoPath,\n\t\t\tasync (_cacheable, signal) => {\n\t\t\t\tconst {\n\t\t\t\t\tvalues: [branch],\n\t\t\t\t} = await this.getBranches(repoPath, { filter: b => b.current }, signal);\n\t\t\t\treturn branch ?? this.getCurrentBranch(repoPath, undefined, undefined, signal);\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\n\t\tif (branchPromise == null) {\n\t\t\tconst {\n\t\t\t\tvalues: [branch],\n\t\t\t} = await this.getBranches(repoPath, { filter: b => b.current }, cancellation);\n\t\t\treturn branch ?? this.getCurrentBranch(repoPath, undefined, undefined, cancellation);\n\t\t}\n\n\t\treturn branchPromise;\n\t}\n\n\tprivate async getCurrentBranch(\n\t\trepoPath: string,\n\t\tmetadataMap: Map<string, BranchMetadata> | undefined,\n\t\tordering: string | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranch | undefined> {\n\t\tconst ref = await this.getCurrentBranchReferenceCore(repoPath, ordering, cancellation);\n\t\tif (ref == null) return undefined;\n\n\t\tconst [pausedOpStatusResult, committerDateResult, defaultWorktreePathResult, metadataMapResult] =\n\t\t\tawait Promise.allSettled([\n\t\t\t\tisDetachedHead(ref.name)\n\t\t\t\t\t? this.provider.pausedOps?.getPausedOperationStatus(repoPath, undefined, cancellation)\n\t\t\t\t\t: undefined,\n\t\t\t\tthis.git\n\t\t\t\t\t.run(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcwd: repoPath,\n\t\t\t\t\t\t\tcancellation: cancellation,\n\t\t\t\t\t\t\tconfigs: gitConfigsLog,\n\t\t\t\t\t\t\terrors: 'ignore',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'log',\n\t\t\t\t\t\t'-n1',\n\t\t\t\t\t\t'--format=%ct',\n\t\t\t\t\t\tordering ? `--${ordering}-order` : undefined,\n\t\t\t\t\t\t'--',\n\t\t\t\t\t)\n\t\t\t\t\t.then(result => (result.stdout ? result.stdout.trim() : undefined)),\n\t\t\t\tthis.provider.config.getDefaultWorktreePath?.(repoPath),\n\t\t\t\tmetadataMap != null ? Promise.resolve(metadataMap) : this.getBranchMetadataMap(repoPath),\n\t\t\t]);\n\n\t\tconst committerDate = getSettledValue(committerDateResult);\n\t\tconst pausedOpStatus = getSettledValue(pausedOpStatusResult);\n\t\tconst rebaseStatus = pausedOpStatus?.type === 'rebase' ? pausedOpStatus : undefined;\n\t\tconst defaultWorktreePath = getSettledValue(defaultWorktreePathResult);\n\t\tmetadataMap ??= getSettledValue(metadataMapResult);\n\t\tconst metadata = metadataMap?.get(ref.name);\n\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst branchRefName = rebaseStatus?.incoming.name ?? `refs/heads/${ref.name}`;\n\n\t\tconst branch = new GitBranch(\n\t\t\trepoPath, // Use worktree-specific path for consistent IDs within each worktree\n\t\t\tbranchRefName,\n\t\t\ttrue,\n\t\t\tcommitterDate != null ? new Date(Number(committerDate) * 1000) : undefined,\n\t\t\tmetadata,\n\t\t\tref.sha,\n\t\t\tref.upstream ? { ...ref.upstream, state: { ahead: 0, behind: 0 } } : undefined,\n\t\t\t{ path: repoPath, isDefault: repoPath === defaultWorktreePath },\n\t\t\tundefined,\n\t\t\trebaseStatus != null,\n\t\t);\n\n\t\treturn branch;\n\t}\n\n\t@debug({ args: repoPath => ({ repoPath: repoPath }) })\n\tasync getBranches(\n\t\trepoPath: string,\n\t\toptions?: {\n\t\t\tfilter?: (b: GitBranch) => boolean;\n\t\t\tordering?: 'date' | 'author-date' | 'topo' | null;\n\t\t\tpaging?: PagingOptions;\n\t\t\tsort?: boolean | BranchSortOptions;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<PagedResult<GitBranch>> {\n\t\tif (repoPath == null) return emptyPagedResult;\n\n\t\tconst scope = getScopedLogger();\n\n\t\tconst getCore = async (\n\t\t\tcommonPath: string,\n\t\t\tcacheable?: CacheController,\n\t\t\tsignal?: AbortSignal,\n\t\t): Promise<PagedResult<GitBranch>> => {\n\t\t\t// Prefer the aggregate signal from the cache when present; fall back to the caller's\n\t\t\t// own cancellation when bypassing the cache (e.g. paging-cursor path).\n\t\t\tsignal ??= cancellation;\n\t\t\ttry {\n\t\t\t\tconst [recordsResult, supportedResult, defaultWorktreePathResult, metadataMapResult] =\n\t\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\t\tthis.provider.refs.getRefs(commonPath, signal),\n\t\t\t\t\t\tthis.git.supported('git:for-each-ref'),\n\t\t\t\t\t\tthis.provider.config.getDefaultWorktreePath?.(commonPath),\n\t\t\t\t\t\tthis.getBranchMetadataMap(commonPath),\n\t\t\t\t\t]);\n\n\t\t\t\tconst records = getSettledValue(recordsResult) ?? [];\n\t\t\t\tconst supported = getSettledValue(supportedResult) ?? [];\n\t\t\t\tconst metadataMap = getSettledValue(metadataMapResult) ?? new Map<string, BranchMetadata>();\n\t\t\t\tconst defaultWorktreePath = getSettledValue(defaultWorktreePathResult);\n\t\t\t\tconst worktreePathSupported = supported.includes('git:for-each-ref:worktreePath');\n\n\t\t\t\t// If we don't get any data, assume the repo doesn't have any commits yet so check if we have a current branch\n\t\t\t\tif (!records.length) {\n\t\t\t\t\t// Never CACHE that conclusion. `getRefs` reports a failed enumeration the same way as a\n\t\t\t\t\t// genuinely ref-less repo — an empty array (it invalidates its own entry but doesn't\n\t\t\t\t\t// throw) — so a transient `for-each-ref` failure would otherwise pin this degraded\n\t\t\t\t\t// current-branch-only list in a map with no TTL, and every branch consumer would see a\n\t\t\t\t\t// one-branch repo for the session. A truly empty repo re-reads cheaply, so refusing the\n\t\t\t\t\t// entry costs nothing in the case this is actually meant to serve.\n\t\t\t\t\tcacheable?.invalidate();\n\n\t\t\t\t\tconst current = await this.getCurrentBranch(\n\t\t\t\t\t\tcommonPath,\n\t\t\t\t\t\tmetadataMap,\n\t\t\t\t\t\toptions?.ordering ?? this.context.config?.commits.ordering ?? undefined,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t);\n\t\t\t\t\treturn current != null ? { values: [current] } : emptyPagedResult;\n\t\t\t\t}\n\n\t\t\t\tusing sw = maybeStopWatch(scope, { log: { onlyExit: true, level: 'debug' } });\n\n\t\t\t\tconst branches: GitBranch[] = [];\n\n\t\t\t\tfor (const record of records) {\n\t\t\t\t\tconst fullName = record.name;\n\t\t\t\t\t// Filter to branches and remote-tracking branches; skip tags from the unified records.\n\t\t\t\t\tif (!fullName.startsWith('refs/heads/') && !fullName.startsWith('refs/remotes/')) continue;\n\t\t\t\t\t// Skip HEAD refs in remote branches\n\t\t\t\t\tif (isRemoteHEAD(fullName)) continue;\n\n\t\t\t\t\tconst upstream = parseUpstream(record.upstream, record.upstreamTracking);\n\n\t\t\t\t\tconst metadata = metadataMap.get(parseRefName(fullName).name);\n\t\t\t\t\tconst worktreePath = record.worktreePath ? normalizePath(record.worktreePath) : undefined;\n\n\t\t\t\t\tbranches.push(\n\t\t\t\t\t\tnew GitBranch(\n\t\t\t\t\t\t\tcommonPath,\n\t\t\t\t\t\t\tfullName,\n\t\t\t\t\t\t\tfalse, // Don't trust %(HEAD) for current as it's per-worktree -- we will set it later\n\t\t\t\t\t\t\trecord.committerDate ? new Date(record.committerDate) : undefined,\n\t\t\t\t\t\t\tmetadata,\n\t\t\t\t\t\t\trecord.objectname,\n\t\t\t\t\t\t\tupstream,\n\t\t\t\t\t\t\tworktreePathSupported\n\t\t\t\t\t\t\t\t? worktreePath\n\t\t\t\t\t\t\t\t\t? { path: worktreePath, isDefault: worktreePath === defaultWorktreePath }\n\t\t\t\t\t\t\t\t\t: false\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tsw?.stop({ suffix: ` parsed ${branches.length} branches` });\n\n\t\t\t\t// Pre-populate current branch cache for worktrees based on worktreePath info\n\t\t\t\t// This eliminates the need for rev-parse calls during branch reconstruction\n\t\t\t\tfor (const branch of branches) {\n\t\t\t\t\t// oxlint-disable-next-line typescript/prefer-optional-chain\n\t\t\t\t\tif (branch.worktree && branch.worktree.path) {\n\t\t\t\t\t\tconst { name } = parseRefName(branch.refName);\n\t\t\t\t\t\tconst reference = createReference(name, branch.worktree.path, {\n\t\t\t\t\t\t\trefType: 'branch',\n\t\t\t\t\t\t\tname: name,\n\t\t\t\t\t\t\tid: getBranchId(branch.worktree.path, false, name),\n\t\t\t\t\t\t\tremote: false,\n\t\t\t\t\t\t\tupstream: branch.upstream?.name\n\t\t\t\t\t\t\t\t? { name: branch.upstream.name, missing: branch.upstream.missing }\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\tsha: branch.sha,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.cache.setCurrentBranchReferenceIfAbsent(branch.worktree.path, reference);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn branches.length ? { values: branches } : emptyPagedResult;\n\t\t\t} catch (ex) {\n\t\t\t\t// Signal cache invalidation so the shared cache entry is cleaned up\n\t\t\t\tcacheable?.invalidate();\n\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\treturn emptyPagedResult;\n\t\t\t}\n\t\t};\n\n\t\t// Mapper function that adjusts branches for a specific worktree\n\t\tconst mapBranches = async (\n\t\t\tshared: PagedResult<GitBranch>,\n\t\t\ttargetRepoPath: string,\n\t\t\tcommonPath: string,\n\t\t\tmapperSignal?: AbortSignal,\n\t\t): Promise<PagedResult<GitBranch>> => {\n\t\t\tif (!shared.values.length) return shared;\n\n\t\t\t// Prefer the mapper's per-entry aggregate signal when present; fall back to the\n\t\t\t// caller's own cancellation when bypassing the cache (paging-cursor path).\n\t\t\tmapperSignal ??= cancellation;\n\n\t\t\t// Get current branch info and default worktree path for the target worktree\n\t\t\tconst [currentRefResult, defaultWorktreePathResult] = await Promise.allSettled([\n\t\t\t\tthis.getCurrentBranchReferenceCore(targetRepoPath, undefined, mapperSignal),\n\t\t\t\tthis.provider.config.getDefaultWorktreePath?.(commonPath),\n\t\t\t]);\n\t\t\tconst currentRef = getSettledValue(currentRefResult);\n\t\t\tconst defaultWorktreePath = getSettledValue(defaultWorktreePathResult);\n\t\t\tconst isDetached = currentRef != null && isDetachedHead(currentRef.name);\n\n\t\t\t// Clone branches with correct repoPath and current flag\n\t\t\tconst branches: GitBranch[] = shared.values.map(b => {\n\t\t\t\t// Check if this branch is current in the target worktree\n\t\t\t\tconst isCurrent = !b.remote && b.name === currentRef?.name && !isDetached;\n\n\t\t\t\t// Only create new object if something changed\n\t\t\t\tif (!isCurrent && targetRepoPath === commonPath) return b;\n\n\t\t\t\treturn new GitBranch(\n\t\t\t\t\ttargetRepoPath, // Use target worktree path\n\t\t\t\t\tb.refName,\n\t\t\t\t\tisCurrent,\n\t\t\t\t\tb.date,\n\t\t\t\t\tb.metadata,\n\t\t\t\t\tb.sha,\n\t\t\t\t\tb.upstream,\n\t\t\t\t\t// For current branch, ensure worktree is set (fallback when git doesn't support worktreePath)\n\t\t\t\t\tisCurrent\n\t\t\t\t\t\t? (b.worktree ?? { path: targetRepoPath, isDefault: targetRepoPath === defaultWorktreePath })\n\t\t\t\t\t\t: b.worktree,\n\t\t\t\t\tfalse, // detached - only true for detached HEAD branch itself\n\t\t\t\t\tfalse, // rebasing - only true for detached HEAD branch in rebase\n\t\t\t\t);\n\t\t\t});\n\n\t\t\t// Handle detached HEAD - need to create a special branch for it\n\t\t\tif (isDetached || (currentRef != null && !branches.some(b => b.current))) {\n\t\t\t\tconst metadataMap = await this.getBranchMetadataMap(commonPath);\n\t\t\t\tconst current = await this.getCurrentBranch(\n\t\t\t\t\ttargetRepoPath,\n\t\t\t\t\tmetadataMap,\n\t\t\t\t\toptions?.ordering ?? this.context.config?.commits.ordering ?? undefined,\n\t\t\t\t\tmapperSignal,\n\t\t\t\t);\n\t\t\t\tif (current != null) {\n\t\t\t\t\t// Replace if exists (by id), otherwise prepend\n\t\t\t\t\tconst index = branches.findIndex(b => b.id === current.id);\n\t\t\t\t\tif (index !== -1) {\n\t\t\t\t\t\tbranches[index] = current;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbranches.unshift(current);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { ...shared, values: branches };\n\t\t};\n\n\t\tlet result: PagedResult<GitBranch>;\n\n\t\t// Use paging cursor to bypass cache if paginating\n\t\tif (options?.paging?.cursor != null) {\n\t\t\tconst commonPath = this.cache.getCommonPath(repoPath);\n\t\t\tconst shared = await getCore(commonPath);\n\t\t\t// Still apply the mapper to ensure correct repoPath and current flag for the requesting worktree\n\t\t\tresult = await mapBranches(shared, repoPath, commonPath);\n\t\t} else {\n\t\t\tresult = await this.cache.getBranches(repoPath, getCore, mapBranches, cancellation);\n\t\t}\n\n\t\tif (options?.filter != null) {\n\t\t\tresult = {\n\t\t\t\t...result,\n\t\t\t\tvalues: result.values.filter(options.filter),\n\t\t\t};\n\t\t}\n\n\t\tif (options?.sort) {\n\t\t\tsortBranches(result.values, typeof options.sort === 'boolean' ? undefined : options.sort);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t@debug()\n\tasync getBranchContributionsOverview(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: {\n\t\t\tassociatedPullRequest?: Promise<\n\t\t\t\t{ refs?: { base?: { branch: string } }; stack?: { position: number } } | undefined\n\t\t\t>;\n\t\t\tpriority?: GitCommandPriority;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<BranchContributionsOverview | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst priority = options?.priority;\n\t\tconst priorityOpts = priority != null ? { priority: priority } : undefined;\n\n\t\t// Expensive body — runs only on cache miss. Closes over `mergeTarget` so the cache key\n\t\t// (`${ref}|${mergeTarget}`) fully captures every input that affects the result.\n\t\tconst fetchBody = async (\n\t\t\tmergeTarget: string,\n\t\t\tsignal: AbortSignal | undefined,\n\t\t): Promise<BranchContributionsOverview | undefined> => {\n\t\t\tconst mergeBase = await this.provider.refs.getMergeBase(repoPath, ref, mergeTarget, priorityOpts, signal);\n\t\t\tif (mergeBase == null) return undefined;\n\n\t\t\t// Fetch the merge-base commit's dates in parallel with contributors so consumers\n\t\t\t// (e.g. the graph minimap scope window) don't pay a separate round-trip for them.\n\t\t\t// `allSettled` so a transient failure in one side doesn't drop the overview entirely.\n\t\t\tconst [contributorsSettled, mergeBaseDatesSettled] = await Promise.allSettled([\n\t\t\t\tthis.provider.contributors.getContributors(\n\t\t\t\t\trepoPath,\n\t\t\t\t\tcreateRevisionRange(mergeBase, ref, '..'),\n\t\t\t\t\t{ stats: true },\n\t\t\t\t\tsignal,\n\t\t\t\t),\n\t\t\t\tthis.provider.commits.getCommitDates(repoPath, mergeBase, signal),\n\t\t\t]);\n\n\t\t\tif (signal?.aborted) throw new CancellationError();\n\n\t\t\tconst result = getSettledValue(contributorsSettled) ?? { contributors: [] };\n\t\t\tconst mergeBaseDates = getSettledValue(mergeBaseDatesSettled);\n\n\t\t\tsortContributors(result.contributors, { orderBy: 'score:desc' });\n\n\t\t\tlet totalCommits = 0;\n\t\t\tlet totalFiles = 0;\n\t\t\tlet totalAdditions = 0;\n\t\t\tlet totalDeletions = 0;\n\t\t\tlet firstCommitTimestamp;\n\t\t\tlet latestCommitTimestamp;\n\n\t\t\tfor (const c of result.contributors) {\n\t\t\t\ttotalCommits += c.contributionCount;\n\t\t\t\ttotalFiles += c.stats?.files ?? 0;\n\t\t\t\ttotalAdditions += c.stats?.additions ?? 0;\n\t\t\t\ttotalDeletions += c.stats?.deletions ?? 0;\n\n\t\t\t\tconst firstTimestamp = c.firstCommitDate?.getTime();\n\t\t\t\tconst latestTimestamp = c.latestCommitDate?.getTime();\n\n\t\t\t\tif (firstTimestamp != null || latestTimestamp != null) {\n\t\t\t\t\tfirstCommitTimestamp =\n\t\t\t\t\t\tfirstCommitTimestamp != null\n\t\t\t\t\t\t\t? Math.min(firstCommitTimestamp, firstTimestamp ?? Infinity, latestTimestamp ?? Infinity)\n\t\t\t\t\t\t\t: (firstTimestamp ?? latestTimestamp);\n\n\t\t\t\t\tlatestCommitTimestamp =\n\t\t\t\t\t\tlatestCommitTimestamp != null\n\t\t\t\t\t\t\t? Math.max(latestCommitTimestamp, firstTimestamp ?? -Infinity, latestTimestamp ?? -Infinity)\n\t\t\t\t\t\t\t: (latestTimestamp ?? firstTimestamp);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\trepoPath: repoPath,\n\t\t\t\tbranch: ref,\n\t\t\t\tmergeTarget: mergeTarget,\n\t\t\t\tmergeBase: mergeBase,\n\t\t\t\tmergeBaseDate: mergeBaseDates?.committerDate,\n\n\t\t\t\tcommits: totalCommits,\n\t\t\t\tfiles: totalFiles,\n\t\t\t\tadditions: totalAdditions,\n\t\t\t\tdeletions: totalDeletions,\n\n\t\t\t\tlatestCommitDate: latestCommitTimestamp != null ? new Date(latestCommitTimestamp) : undefined,\n\t\t\t\tfirstCommitDate: firstCommitTimestamp != null ? new Date(firstCommitTimestamp) : undefined,\n\n\t\t\t\tcontributors: result.contributors,\n\t\t\t};\n\t\t};\n\n\t\ttry {\n\t\t\t// Resolve `mergeTarget` through Tier 1 → Tier 2 → Tier 3. The pieces of each tier are\n\t\t\t// already individually cached (`getStoredMergeTargetBranchName`, `getBaseBranchName`,\n\t\t\t// `getDefaultBranchName`), so this resolution path is cheap on warm caches. Only the\n\t\t\t// expensive body below (`getMergeBase` + `getContributors` w/ stats + `getCommitDates`)\n\t\t\t// is wrapped by `cache.getBranchOverview`, keyed on the resolved `mergeTarget` so any\n\t\t\t// caller that resolves to the same target shares; differing targets get independent\n\t\t\t// slots, which is the correctness constraint that previously forced the Tier 2/3 paths\n\t\t\t// to bypass the cache entirely.\n\t\t\tlet mergeTarget: string | undefined;\n\n\t\t\t// Tier 1: Stored merge target (user-set or previously detected from PR).\n\t\t\tconst storedTarget = await this.getStoredMergeTargetBranchName(repoPath, ref);\n\t\t\tif (storedTarget) {\n\t\t\t\tconst validated = await this.provider.refs.getSymbolicReferenceName(\n\t\t\t\t\trepoPath,\n\t\t\t\t\tstoredTarget,\n\t\t\t\t\tpriorityOpts,\n\t\t\t\t\tcancellation,\n\t\t\t\t);\n\t\t\t\tmergeTarget = validated || storedTarget;\n\t\t\t}\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\tmergeTarget = `${branch.remoteName}/${pr.refs.base.branch}`;\n\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// Storing it would leave a stored target naming a branch that no longer exists — and\n\t\t\t\t\t// a stored target beats every other tier, so it would keep winning until cleared by\n\t\t\t\t\t// hand. Use it for this lookup, but don't persist it.\n\t\t\t\t\tif (pr.stack == null) {\n\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// `branchOverviews` invalidation that the write would otherwise trigger: we're\n\t\t\t\t\t\t// about to populate `${ref}|${mergeTarget}` with this exact target, so evicting\n\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// do not affect `baseBranchName`, so no need to skip that target.)\n\t\t\t\t\t\tvoid this.storeMergeTargetBranchName(repoPath, ref, mergeTarget, {\n\t\t\t\t\t\t\tskipInvalidation: ['branchOverviews'],\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Tier 3: Base branch, then default branch.\n\t\t\tmergeTarget ??= await this.getBaseBranchName(repoPath, ref, priorityOpts, cancellation);\n\t\t\tmergeTarget ??= await this.getDefaultBranchName(repoPath, undefined, priorityOpts, cancellation);\n\n\t\t\tif (mergeTarget == null) return undefined;\n\n\t\t\tconst resolvedTarget = mergeTarget;\n\t\t\treturn await this.cache.getBranchOverview(\n\t\t\t\trepoPath,\n\t\t\t\t`${ref}|${resolvedTarget}`,\n\t\t\t\t(_commonPath, _cacheable, signal) => fetchBody(resolvedTarget, signal ?? cancellation),\n\t\t\t\t{ cancellation: cancellation },\n\t\t\t);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@debug()\n\tasync getBranchesWithCommits(\n\t\trepoPath: string,\n\t\tcommits: string[],\n\t\tbranch?: string,\n\t\toptions?:\n\t\t\t| { all?: boolean; commitDate?: Date; mode?: 'contains' | 'pointsAt' }\n\t\t\t| { commitDate?: Date; mode?: 'contains' | 'pointsAt'; remotes?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<string[]> {\n\t\tif (branch != null) {\n\t\t\tconst result = await this.branchesContainingCore(\n\t\t\t\trepoPath,\n\t\t\t\tcommits,\n\t\t\t\t{ mode: 'contains', name: branch },\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst data = result.stdout.trim();\n\t\t\treturn data ? [data] : [];\n\t\t}\n\n\t\tconst result = await this.branchesContainingCore(repoPath, commits, options, cancellation);\n\t\tif (!result.stdout) return [];\n\n\t\treturn filterMap(result.stdout.split('\\n'), b => b.trim() || undefined);\n\t}\n\n\tprivate async branchesContainingCore(\n\t\trepoPath: string,\n\t\trefs: string[],\n\t\toptions?: {\n\t\t\tall?: boolean;\n\t\t\tmode?: 'contains' | 'pointsAt';\n\t\t\tname?: string;\n\t\t\tremotes?: boolean;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitResult> {\n\t\tconst params: string[] = ['branch'];\n\t\tif (options?.all) {\n\t\t\tparams.push('-a');\n\t\t} else if (options?.remotes) {\n\t\t\tparams.push('-r');\n\t\t}\n\n\t\tparams.push('--format=%(refname:short)');\n\n\t\tfor (const ref of refs) {\n\t\t\tparams.push(options?.mode === 'pointsAt' ? `--points-at=${ref}` : `--contains=${ref}`);\n\t\t}\n\n\t\tif (options?.name != null) {\n\t\t\tparams.push(options.name);\n\t\t}\n\n\t\treturn this.git.run(\n\t\t\t{\n\t\t\t\tcwd: repoPath,\n\t\t\t\tcancellation: cancellation,\n\t\t\t\tconfigs: gitConfigsBranch,\n\t\t\t\terrors: 'ignore',\n\t\t\t},\n\t\t\t...params,\n\t\t);\n\t}\n\n\t@debug()\n\tasync getCurrentBranchReference(\n\t\trepoPath: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranchReference | undefined> {\n\t\tlet ref = await this.getCurrentBranchReferenceCore(repoPath, undefined, cancellation);\n\t\tif (ref != null && isDetachedHead(ref.name)) {\n\t\t\tref = createReference(ref.sha!, repoPath, {\n\t\t\t\trefType: 'branch',\n\t\t\t\tname: formatDetachedHeadName(ref.sha!),\n\t\t\t\tid: getBranchId(repoPath, ref.remote, ref.sha!),\n\t\t\t\tremote: ref.remote,\n\t\t\t\tupstream: ref.upstream,\n\t\t\t\tsha: ref.sha,\n\t\t\t});\n\t\t}\n\t\treturn ref;\n\t}\n\n\tprivate getCurrentBranchReferenceCore(\n\t\trepoPath: string,\n\t\tordering?: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranchReference | undefined> {\n\t\treturn this.cache.currentBranchReference.getOrCreate(\n\t\t\trepoPath,\n\t\t\tasync (_cacheable, signal) => {\n\t\t\t\tconst commitOrdering = ordering;\n\n\t\t\t\tlet data: [string, string | undefined] | undefined;\n\t\t\t\tlet result;\n\t\t\t\ttry {\n\t\t\t\t\tresult = await this.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, cancellation: signal, errors: 'throw' },\n\t\t\t\t\t\t'rev-parse',\n\t\t\t\t\t\t'--abbrev-ref',\n\t\t\t\t\t\t'--symbolic-full-name',\n\t\t\t\t\t\t'@',\n\t\t\t\t\t\t'@{u}',\n\t\t\t\t\t\t'--',\n\t\t\t\t\t);\n\t\t\t\t\tdata = [result.stdout, undefined];\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\t\tconst msg: string = ex?.toString() ?? '';\n\t\t\t\t\tif (GitErrors.badRevision.test(msg) || GitWarnings.noUpstream.test(msg)) {\n\t\t\t\t\t\tif (ex.stdout != null && ex.stdout.length !== 0) {\n\t\t\t\t\t\t\tdata = [ex.stdout, undefined];\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tresult = await this.git.run(\n\t\t\t\t\t\t\t\t\t{ cwd: repoPath, cancellation: signal },\n\t\t\t\t\t\t\t\t\t'symbolic-ref',\n\t\t\t\t\t\t\t\t\t'--short',\n\t\t\t\t\t\t\t\t\t'HEAD',\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (result.stdout) {\n\t\t\t\t\t\t\t\t\tdata = [result.stdout.trim(), undefined];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (data == null) {\n\t\t\t\t\t\t\t\tconst symbolicRef = await this.getDefaultBranchName(\n\t\t\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\t\t\t'origin',\n\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (symbolicRef != null) {\n\t\t\t\t\t\t\t\t\tdata = [\n\t\t\t\t\t\t\t\t\t\tsymbolicRef.startsWith('origin/')\n\t\t\t\t\t\t\t\t\t\t\t? symbolicRef.substring('origin/'.length)\n\t\t\t\t\t\t\t\t\t\t\t: symbolicRef,\n\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (data == null) {\n\t\t\t\t\t\t\t\tconst defaultBranch =\n\t\t\t\t\t\t\t\t\t(await this.provider.config.getConfig(repoPath, 'init.defaultBranch')) ?? 'main';\n\t\t\t\t\t\t\t\tconst configMap = await this.provider.config.getConfigRegex(\n\t\t\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\t\t\t`branch\\\\.${defaultBranch}\\\\.+`,\n\t\t\t\t\t\t\t\t\t{ runGitLocally: true },\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tconst remote = configMap.get(`branch.${defaultBranch}.remote`);\n\t\t\t\t\t\t\t\tconst merge = configMap.get(`branch.${defaultBranch}.merge`);\n\t\t\t\t\t\t\t\tconst remoteBranch = merge?.startsWith('refs/heads/')\n\t\t\t\t\t\t\t\t\t? merge.substring('refs/heads/'.length)\n\t\t\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\t\t\t\tdata = [\n\t\t\t\t\t\t\t\t\t`${defaultBranch}${remote && remoteBranch ? `\\n${remote}/${remoteBranch}` : ''}`,\n\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (GitWarnings.headNotABranch.test(msg)) {\n\t\t\t\t\t\tresult = await this.git.run(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcwd: repoPath,\n\t\t\t\t\t\t\t\tcancellation: signal,\n\t\t\t\t\t\t\t\tconfigs: gitConfigsLog,\n\t\t\t\t\t\t\t\terrors: 'ignore',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'log',\n\t\t\t\t\t\t\t'-n1',\n\t\t\t\t\t\t\t'--format=%H',\n\t\t\t\t\t\t\tcommitOrdering ? `--${commitOrdering}-order` : undefined,\n\t\t\t\t\t\t\t'--',\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif (result.completion.status === 'cancelled' || signal?.aborted) {\n\t\t\t\t\t\t\tthrow new CancellationError();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst sha = result.stdout.trim();\n\t\t\t\t\t\tif (sha) {\n\t\t\t\t\t\t\tdata = [`(HEAD detached at ${shortenRevision(sha)})`, sha];\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tLogger.warn(`[${repoPath}] Unable to get current branch: ${ex}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (data == null) return undefined;\n\n\t\t\t\tconst [name, upstream] = data[0].split('\\n');\n\n\t\t\t\treturn createReference(name, repoPath, {\n\t\t\t\t\trefType: 'branch',\n\t\t\t\t\tname: name,\n\t\t\t\t\tid: getBranchId(repoPath, false, name),\n\t\t\t\t\tremote: false,\n\t\t\t\t\tupstream: upstream ? { name: upstream, missing: false } : undefined,\n\t\t\t\t\tsha: data[1],\n\t\t\t\t});\n\t\t\t},\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\t@debug({ exit: true })\n\tasync getDefaultBranchName(\n\t\trepoPath: string | undefined,\n\t\tremote?: string,\n\t\toptions?: { priority?: GitCommandPriority; local?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<string | undefined> {\n\t\tif (repoPath == null) return undefined;\n\n\t\tremote ??= 'origin';\n\t\tconst priority = options?.priority;\n\t\tconst priorityOpts = priority != null ? { priority: priority } : undefined;\n\n\t\t// Local-only: read just the existing local symref, never contacting the remote. Cached under a\n\t\t// `${remote}:local` key — a colon can't appear in a refname component, so it can never collide\n\t\t// with a real remote name used by the networked variant below. Invalidated by the same\n\t\t// remotes/branches cache cascades as the networked lookup.\n\t\tif (options?.local) {\n\t\t\treturn this.cache.getDefaultBranchName(\n\t\t\t\trepoPath,\n\t\t\t\t`${remote}:local`,\n\t\t\t\tasync (commonPath, cacheable, signal) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Bind to the aggregate `signal` (fires only when ALL current callers abort), not\n\t\t\t\t\t\t// this-caller's `cancellation` — otherwise a superseded caller's abort would kill the\n\t\t\t\t\t\t// shared command and reject concurrent riders that never cancelled.\n\t\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t\t{ cwd: commonPath, cancellation: signal ?? cancellation, ...priorityOpts },\n\t\t\t\t\t\t\t'symbolic-ref',\n\t\t\t\t\t\t\t'--short',\n\t\t\t\t\t\t\t`refs/remotes/${remote}/HEAD`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn result.stdout.trim() || undefined;\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\t\t\t// `symbolic-ref` on an absent `refs/remotes/<remote>/HEAD` exits fatal rather than\n\t\t\t\t\t\t// empty, and that message matches no `GitWarnings` entry, so it arrives here as a\n\t\t\t\t\t\t// throw. It is still an ANSWER — the ref genuinely isn't set — and the overwhelmingly\n\t\t\t\t\t\t// common one, so cache it. Invalidating instead means every caller re-probes and the\n\t\t\t\t\t\t// whole point of caching this lookup is lost.\n\t\t\t\t\t\tconst stderr = (ex as { stderr?: string }).stderr ?? '';\n\t\t\t\t\t\tif (stderr.includes('is not a symbolic ref')) return undefined;\n\n\t\t\t\t\t\t// Anything else never produced an answer (spawn failure, queue rejection). This entry\n\t\t\t\t\t\t// has no TTL, so caching that would pin \"no default branch\" for the session.\n\t\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t}\n\n\t\treturn this.cache.getDefaultBranchName(\n\t\t\trepoPath,\n\t\t\tremote,\n\t\t\tasync (commonPath, cacheable, signal) => {\n\t\t\t\tlet retried = false;\n\t\t\t\twhile (true) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t\t{ cwd: commonPath, cancellation: signal ?? cancellation, ...priorityOpts },\n\t\t\t\t\t\t\t'symbolic-ref',\n\t\t\t\t\t\t\t'--short',\n\t\t\t\t\t\t\t`refs/remotes/${remote}/HEAD`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn result.stdout.trim() || undefined;\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\t// Only \"no HEAD ref configured\" is an ANSWER here; every other throw means the lookup\n\t\t\t\t\t\t// never happened. This entry has no TTL, so caching a failure — an offline `ls-remote`\n\t\t\t\t\t\t// being the likely one — would pin \"no default branch\" for the session.\n\t\t\t\t\t\tlet answered = false;\n\t\t\t\t\t\tif (/is not a symbolic ref/.test(ex.stderr)) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tif (!retried) {\n\t\t\t\t\t\t\t\t\tretried = true;\n\t\t\t\t\t\t\t\t\tawait this.git.run(\n\t\t\t\t\t\t\t\t\t\t{ cwd: commonPath, cancellation: signal ?? cancellation, ...priorityOpts },\n\t\t\t\t\t\t\t\t\t\t'remote',\n\t\t\t\t\t\t\t\t\t\t'set-head',\n\t\t\t\t\t\t\t\t\t\t'-a',\n\t\t\t\t\t\t\t\t\t\tremote,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t// This just created `refs/remotes/<remote>/HEAD`, which the `local` variant\n\t\t\t\t\t\t\t\t\t// may already have cached a miss for. The watcher would also catch the new\n\t\t\t\t\t\t\t\t\t// ref, but evict directly so consumers of this package that don't wire up a\n\t\t\t\t\t\t\t\t\t// watcher aren't stuck with that miss.\n\t\t\t\t\t\t\t\t\tthis.cache.deleteDefaultBranchName(commonPath, `${remote}:local`);\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t\t\t\t{ cwd: commonPath, cancellation: signal ?? cancellation, ...priorityOpts },\n\t\t\t\t\t\t\t\t\t'ls-remote',\n\t\t\t\t\t\t\t\t\t'--symref',\n\t\t\t\t\t\t\t\t\tremote,\n\t\t\t\t\t\t\t\t\t'HEAD',\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (result.stdout) {\n\t\t\t\t\t\t\t\t\tconst match = /ref:\\s(\\S+)\\s+HEAD/m.exec(result.stdout);\n\t\t\t\t\t\t\t\t\tif (match != null) {\n\t\t\t\t\t\t\t\t\t\tconst [, branch] = match;\n\t\t\t\t\t\t\t\t\t\treturn `${remote}/${branch.substring('refs/heads/'.length).trim()}`;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// `ls-remote` ran and the remote advertised no HEAD — a real \"none\".\n\t\t\t\t\t\t\t\tanswered = true;\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!answered) {\n\t\t\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\t@debug()\n\tasync createBranch(repoPath: string, name: string, ref: string, options?: { noTracking?: boolean }): Promise<void> {\n\t\tconst args = ['branch', name, ref];\n\t\tif (options?.noTracking) {\n\t\t\targs.push('--no-track');\n\t\t}\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t\t// Evict the cached base so the new branch re-derives its own. The PERSISTED `branch.<ref>.gk-*`\n\t\t\t// keys are left alone: they're dropped when GitLens deletes a branch, never when one is created.\n\t\t\t// Removing them here would mean treating a reused name as proof of a different branch, which\n\t\t\t// nothing can establish — so the trade is that a branch reusing a name deleted outside GitLens\n\t\t\t// inherits the orphaned section.\n\t\t\tthis.cache.deleteBaseBranchName(repoPath, name);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['heads']);\n\t\t} catch (ex) {\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'branch',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew BranchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\taction: 'create',\n\t\t\t\t\t\t\tbranch: name,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t@debug()\n\tasync deleteLocalBranch(repoPath: string, names: string | string[], options?: { force?: boolean }): Promise<void> {\n\t\tconst branches = ensureArray(names);\n\t\tconst args = ['branch', options?.force ? '-D' : '-d', ...branches];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t\tfor (const branch of branches) {\n\t\t\t\tawait this.forgetDeletedBranch(repoPath, branch);\n\t\t\t}\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['heads']);\n\t\t} catch (ex) {\n\t\t\t// A multi-name delete partially succeeds: `git branch -d a bad c` removes `a` and `c`, refuses\n\t\t\t// `bad`, and still exits non-zero — so the loop above never ran for the branches that did go.\n\t\t\t// Clean those up here rather than leave persisted gk metadata behind for a name a later branch\n\t\t\t// can reuse.\n\t\t\tconst anyDeleted = await this.cleanupDeletedBranchMetadata(repoPath, branches);\n\n\t\t\t// The success path's notifications never ran, but some branches DID go — without these the\n\t\t\t// branch caches stay stale and consumers wait on the filesystem watcher (which never fires\n\t\t\t// for a packed ref).\n\t\t\tif (anyDeleted) {\n\t\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['heads']);\n\t\t\t}\n\n\t\t\tif (ex instanceof BranchError) {\n\t\t\t\tthrow ex.update({\n\t\t\t\t\taction: options?.force ? 'force delete' : 'delete',\n\t\t\t\t\tbranch: branches.join(', '),\n\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Classify the failure (e.g. not fully merged) so consumers like the delete wizard can offer a\n\t\t\t// force retry — without this the reason would be undefined and every failure reads as 'other'.\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'branch',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew BranchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\taction: options?.force ? 'force delete' : 'delete',\n\t\t\t\t\t\t\tbranch: branches.join(', '),\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Drops what GitLens keeps for a local branch beyond its ref, for both ways one is deleted\n\t * (`deleteLocalBranch` and `refs.deleteReference`). The persisted gk metadata goes too, not just the\n\t * cached resolution: `getBaseBranchName` reads `branch.<ref>.gk-merge-base` before falling back to the\n\t * reflog, so leaving it behind would hand a later branch reusing this name its predecessor's base.\n\t */\n\tasync forgetDeletedBranch(repoPath: string, name: string): Promise<void> {\n\t\tthis.cache.deleteBaseBranchName(repoPath, name);\n\t\tawait this.provider.config.removeGkConfigBranchSection(repoPath, name);\n\t}\n\n\t/**\n\t * Drops the cached and persisted per-branch metadata for whichever of `names` no longer exists. Only\n\t * for the partial-failure path — one extra `for-each-ref` is cheap while already handling an error,\n\t * and keeps the success path free of it.\n\t *\n\t * Returns whether any of `names` is confirmed gone; `false` when the probe couldn't answer, so a\n\t * spurious notification is never fired on an unrelated failure.\n\t */\n\tprivate async cleanupDeletedBranchMetadata(repoPath: string, names: string[]): Promise<boolean> {\n\t\ttry {\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, errors: 'ignore' },\n\t\t\t\t'for-each-ref',\n\t\t\t\t// Full refname, stripped here rather than by git. NOT `%(refname:short)`: that yields the\n\t\t\t\t// shortest UNAMBIGUOUS name, so a branch with a same-named tag comes back as `heads/<name>`,\n\t\t\t\t// never matches the requested name, and would read as deleted — wiping a live branch's\n\t\t\t\t// metadata. `%(refname:strip=2)` also solves that, but `%(refname)` is the oldest, plainest\n\t\t\t\t// field and needs no assumption about which git version gained `strip`.\n\t\t\t\t'--format=%(refname)',\n\t\t\t\t...names.map(n => `refs/heads/${n}`),\n\t\t\t);\n\t\t\t// `errors: 'ignore'` means a failed probe RESOLVES empty, which is indistinguishable from \"none\n\t\t\t// of them survived\" — and would delete every name's metadata, including user-owned keys like\n\t\t\t// `gk-disposition` and `gk-associated-issues`. Only act on a genuine answer.\n\t\t\t//\n\t\t\t// BOTH conditions: `exitCode !== 0` catches a probe git ran and rejected, `status !== 'exited'`\n\t\t\t// catches one that never produced an answer — a spawn failure or queue rejection (no exit code at\n\t\t\t// all), or a swallowed warning (which carries git's real code, so the exit-code test alone can\n\t\t\t// still read it as \"none survived\").\n\t\t\tif (result.completion.status !== 'exited' || result.exitCode !== 0) return false;\n\n\t\t\tconst prefix = 'refs/heads/';\n\t\t\tconst surviving = new Set(\n\t\t\t\tresult.stdout\n\t\t\t\t\t.split('\\n')\n\t\t\t\t\t.map(l => l.trim())\n\t\t\t\t\t.filter(l => l.startsWith(prefix))\n\t\t\t\t\t.map(l => l.substring(prefix.length)),\n\t\t\t);\n\n\t\t\tlet anyDeleted = false;\n\t\t\tfor (const name of names) {\n\t\t\t\tif (surviving.has(name)) continue;\n\n\t\t\t\tanyDeleted = true;\n\t\t\t\tawait this.forgetDeletedBranch(repoPath, name);\n\t\t\t}\n\n\t\t\treturn anyDeleted;\n\t\t} catch {\n\t\t\t// Best-effort bookkeeping while already unwinding a failure — never mask the original error.\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t@debug()\n\tasync deleteRemoteBranch(repoPath: string, names: string | string[], remote: string): Promise<void> {\n\t\tconst branches = ensureArray(names);\n\t\tconst args = ['push', '-d', remote, ...branches];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['remotes']);\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof BranchError) {\n\t\t\t\tthrow ex.update({\n\t\t\t\t\taction: 'delete',\n\t\t\t\t\tbranch: branches.join(', '),\n\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Classify against the underlying `git push -d` failure modes; map the \"remote ref does not\n\t\t\t// exist\" case onto BranchError's noRemoteReference so consumers get an actionable reason.\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'push',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew BranchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason === 'rejectedRefDoesNotExist' ? 'noRemoteReference' : 'other',\n\t\t\t\t\t\t\taction: 'delete',\n\t\t\t\t\t\t\tbranch: branches.join(', '),\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t@debug()\n\tasync getBranchMergedStatus(\n\t\trepoPath: string,\n\t\tbranch: GitBranchReference,\n\t\tinto: GitBranchReference,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranchMergedStatus> {\n\t\tif (branch.name === into.name || branch.upstream?.name === into.name) {\n\t\t\treturn { merged: false };\n\t\t}\n\n\t\t// Hoisted so it can feed the cache key below (its tip is a 3rd key input) and the mapper\n\t\t// below reuses it instead of resolving it a second time.\n\t\tconst localInto = into.remote\n\t\t\t? await this.getLocalBranchByUpstream(repoPath, into.name, cancellation)\n\t\t\t: undefined;\n\n\t\t// Cache key omits repoPath so worktrees of the same common repo share the cached answer.\n\t\t// Content-keyed on the involved tip shas (the result is a pure function of them), so tip\n\t\t// movement mints a new key instead of relying on eviction; falls back to the name-only\n\t\t// identity when a sha is missing (defensive — the sole caller always supplies both tips).\n\t\tconst cacheKey =\n\t\t\tbranch.sha != null && into.sha != null\n\t\t\t\t? `${branch.remote ? 'r' : 'l'}:${branch.name}@${branch.sha}|${into.remote ? 'r' : 'l'}:${into.name}@${into.sha}${\n\t\t\t\t\t\tlocalInto?.sha != null ? `|L:${localInto.name}@${localInto.sha}` : ''\n\t\t\t\t\t}`\n\t\t\t\t: `${branch.remote ? 'r' : 'l'}:${branch.name}|${into.remote ? 'r' : 'l'}:${into.name}`;\n\n\t\treturn this.cache.getBranchMergedStatus(\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tasync (commonPath, _cacheable, signal) => {\n\t\t\t\tconst result = await this.getBranchMergedStatusCore(commonPath, branch, into, signal);\n\t\t\t\tif (result.merged) return result;\n\n\t\t\t\t// If there is a local branch and it is not the branch we are checking, check if it has been merged into it\n\t\t\t\tif (localInto != null && localInto.name !== branch.name) {\n\t\t\t\t\t// Skip the second full merge-check cycle when the local branch points at the same commit as the remote —\n\t\t\t\t\t// the merge-base/cherry/diff/apply pipeline would produce the same answer we already got for `into` above\n\t\t\t\t\tif (localInto.sha != null && localInto.sha === into.sha) {\n\t\t\t\t\t\treturn { merged: false };\n\t\t\t\t\t}\n\n\t\t\t\t\tconst result = await this.getBranchMergedStatusCore(commonPath, branch, localInto, signal);\n\t\t\t\t\tif (result.merged) {\n\t\t\t\t\t\t// `localBranchOnly` is built against `commonPath` here; the cache mapper rewrites\n\t\t\t\t\t\t// `repoPath`/`id` to the requesting worktree on retrieval.\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\tlocalBranchOnly: createReference(localInto.ref, commonPath, {\n\t\t\t\t\t\t\t\tid: getBranchId(commonPath, localInto.remote, localInto.name),\n\t\t\t\t\t\t\t\trefType: 'branch',\n\t\t\t\t\t\t\t\tname: localInto.name,\n\t\t\t\t\t\t\t\tremote: localInto.remote,\n\t\t\t\t\t\t\t\tupstream: localInto.upstream,\n\t\t\t\t\t\t\t\tsha: localInto.sha,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn { merged: false };\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate async getBranchMergedStatusCore(\n\t\trepoPath: string,\n\t\tbranch: GitBranchReference,\n\t\tinto: GitBranchReference,\n\t\tcancellation?: AbortSignal,\n\t): Promise<Exclude<GitBranchMergedStatus, 'localBranchOnly'>> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\t// Check if branch is direct ancestor (handles FF merges)\n\t\t\ttry {\n\t\t\t\tawait this.git.run(\n\t\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t\t'merge-base',\n\t\t\t\t\t'--is-ancestor',\n\t\t\t\t\tbranch.name,\n\t\t\t\t\tinto.name,\n\t\t\t\t);\n\t\t\t\treturn { merged: true, confidence: 'highest' };\n\t\t\t} catch (ex) {\n\t\t\t\tif (isCancellationError(ex)) throw ex;\n\t\t\t}\n\n\t\t\t// Cherry-pick detection (handles cherry-picks, rebases, etc)\n\t\t\tlet result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation },\n\t\t\t\t'cherry',\n\t\t\t\t'--abbrev',\n\t\t\t\t'-v',\n\t\t\t\tinto.name,\n\t\t\t\tbranch.name,\n\t\t\t);\n\t\t\t// Check if there are no lines or all lines startwith a `-` (i.e. likely merged)\n\t\t\tif (\n\t\t\t\t!result.stdout ||\n\t\t\t\tresult.stdout\n\t\t\t\t\t.trim()\n\t\t\t\t\t.split('\\n')\n\t\t\t\t\t.every(l => l.startsWith('-'))\n\t\t\t) {\n\t\t\t\treturn { merged: true, confidence: 'high' };\n\t\t\t}\n\n\t\t\t// Attempt to detect squash merges by checking if the diff of the branch can be cleanly removed from the target\n\t\t\tconst mergeBase = await this.provider.refs.getMergeBase(\n\t\t\t\trepoPath,\n\t\t\t\tinto.name,\n\t\t\t\tbranch.name,\n\t\t\t\tundefined,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tresult = await this.git.run({ cwd: repoPath, cancellation: cancellation }, 'diff', mergeBase, branch.name);\n\t\t\tif (result.stdout) {\n\t\t\t\t// Create a temporary index file\n\t\t\t\tawait using disposableIndex = await this.provider.staging.createTemporaryIndex(\n\t\t\t\t\trepoPath,\n\t\t\t\t\t'ref',\n\t\t\t\t\tinto.name,\n\t\t\t\t);\n\t\t\t\tconst { env } = disposableIndex;\n\n\t\t\t\tresult = await this.git.run(\n\t\t\t\t\t{\n\t\t\t\t\t\tcwd: repoPath,\n\t\t\t\t\t\tcancellation: cancellation,\n\t\t\t\t\t\tenv: env,\n\t\t\t\t\t\terrors: 'ignore',\n\t\t\t\t\t\tstdin: result.stdout,\n\t\t\t\t\t},\n\t\t\t\t\t'apply',\n\t\t\t\t\t'--cached',\n\t\t\t\t\t'--reverse',\n\t\t\t\t\t'--check',\n\t\t\t\t\t'-',\n\t\t\t\t);\n\n\t\t\t\tif (result.exitCode === 0 && !result.stdout.trim() && !result.stderr?.trim()) {\n\t\t\t\t\treturn { merged: true, confidence: 'medium' };\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { merged: false };\n\t\t} catch (ex) {\n\t\t\tif (Logger.enabled('trace')) {\n\t\t\t\tscope?.error(ex);\n\t\t\t}\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn { merged: false };\n\t\t}\n\t}\n\n\t@debug()\n\tasync getLocalBranchByUpstream(\n\t\trepoPath: string,\n\t\tremoteBranchName: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranch | undefined> {\n\t\tconst branches = new PageableResult<GitBranch>(p =>\n\t\t\tthis.getBranches(repoPath, p != null ? { paging: p } : undefined, cancellation),\n\t\t);\n\t\treturn getLocalBranchByUpstream(remoteBranchName, branches);\n\t}\n\n\t/** Detects potential conflicts when applying commits onto a target branch (git rebase and cherry-pick) */\n\t@debug()\n\tasync getPotentialApplyConflicts(\n\t\trepoPath: string,\n\t\ttargetBranch: string,\n\t\tshas: string[],\n\t\toptions?: { stopOnFirstConflict?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<ConflictDetectionResult> {\n\t\tif (!shas.length) return { status: 'clean' };\n\n\t\tconst cacheKey: ConflictDetectionCacheKey = `apply:${targetBranch}:${shas.join(',')}:${options?.stopOnFirstConflict ?? false}`;\n\t\treturn this.cache.conflictDetection.getOrCreate(\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tasync (_cacheable, signal) => {\n\t\t\t\t// Resolve all parent refs in a single call - fails if any commit is a root commit (no parent)\n\t\t\t\tconst parentRefs = shas.map(c => `${c}^`);\n\t\t\t\tlet parentShas: string[];\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, cancellation: signal, errors: 'throw' },\n\t\t\t\t\t\t'rev-parse',\n\t\t\t\t\t\t...parentRefs,\n\t\t\t\t\t);\n\t\t\t\t\tparentShas = result.stdout.trim().split('\\n');\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\t\t\t\t\t// If any commit doesn't have a parent (root commit), we can't do conflict detection\n\t\t\t\t\treturn createConflictDetectionError('noParent');\n\t\t\t\t}\n\n\t\t\t\tif (parentShas.length !== shas.length) {\n\t\t\t\t\treturn createConflictDetectionError('refNotFound');\n\t\t\t\t}\n\n\t\t\t\tconst commitsWithParents = shas.map((c, i) => ({ sha: c, parent: parentShas[i] }));\n\t\t\t\treturn this.checkForPotentialConflicts(repoPath, commitsWithParents, targetBranch, signal, options);\n\t\t\t},\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\t/** Detects potential conflict when merge a branch into a target branch (git merge) */\n\t@debug()\n\tasync getPotentialMergeConflicts(\n\t\trepoPath: string,\n\t\tbranch: string,\n\t\ttargetBranch: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<ConflictDetectionResult> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst cacheKey: ConflictDetectionCacheKey = `merge:${branch}:${targetBranch}`;\n\t\treturn this.cache.conflictDetection.getOrCreate(\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tasync (_cacheable, signal) => {\n\t\t\t\tif (!(await this.git.supports('git:merge-tree:write-tree'))) {\n\t\t\t\t\treturn createConflictDetectionError('unsupported');\n\t\t\t\t}\n\n\t\t\t\tlet data;\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, cancellation: signal, errors: 'throw' },\n\t\t\t\t\t\t'merge-tree',\n\t\t\t\t\t\t'-z',\n\t\t\t\t\t\t'--name-only',\n\t\t\t\t\t\t'--no-messages',\n\t\t\t\t\t\tbranch,\n\t\t\t\t\t\ttargetBranch,\n\t\t\t\t\t);\n\t\t\t\t\tdata = result.stdout;\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t\t\tconst msg: string = ex?.toString() ?? '';\n\t\t\t\t\tif (GitErrors.notAValidObjectName.test(msg)) {\n\t\t\t\t\t\tscope?.error(\n\t\t\t\t\t\t\tex,\n\t\t\t\t\t\t\t`'${targetBranch}' or '${branch}' not found - ensure the branches exist and are fully qualified (e.g. 'refs/heads/main')`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn createConflictDetectionError('refNotFound');\n\t\t\t\t\t} else if (GitErrors.badRevision.test(msg)) {\n\t\t\t\t\t\tscope?.error(ex, `Invalid branch name: ${msg.slice(msg.indexOf(\"'\"))}`);\n\t\t\t\t\t\treturn createConflictDetectionError('refNotFound');\n\t\t\t\t\t} else if (GitErrors.noMergeBase.test(msg)) {\n\t\t\t\t\t\tscope?.error(\n\t\t\t\t\t\t\tex,\n\t\t\t\t\t\t\t`Unable to merge '${branch}' and '${targetBranch}' as they have no common ancestor`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn createConflictDetectionError('noMergeBase');\n\t\t\t\t\t} else if (ex instanceof GitError) {\n\t\t\t\t\t\tdata = ex.stdout;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tscope?.error(ex);\n\t\t\t\t\t\treturn createConflictDetectionError('other');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!data) return { status: 'clean' };\n\n\t\t\t\tconst mergeConflict = parseMergeTreeConflict(data);\n\t\t\t\tif (!mergeConflict.conflicts.length) return { status: 'clean', treeOid: mergeConflict.treeOid };\n\n\t\t\t\treturn {\n\t\t\t\t\tstatus: 'conflicts',\n\t\t\t\t\tconflict: {\n\t\t\t\t\t\trepoPath: repoPath,\n\t\t\t\t\t\tbranch: branch,\n\t\t\t\t\t\ttarget: targetBranch,\n\t\t\t\t\t\tfiles: mergeConflict.conflicts,\n\t\t\t\t\t\tshas: undefined, // Merge conflicts don't have a specific commit SHA\n\t\t\t\t\t},\n\t\t\t\t\ttreeOid: mergeConflict.treeOid,\n\t\t\t\t};\n\t\t\t},\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\t/** Detects conflicts when an autostash is reapplied onto the tree an integration produced */\n\t@debug()\n\tasync getPotentialStashReapplyConflicts(\n\t\trepoPath: string,\n\t\tontoTreeOid: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<ConflictDetectionResult> {\n\t\t// Requires Git v2.38+ for --write-tree with 3-arg form\n\t\t// `runMergeTreeStep` relies on `--merge-base`\n\t\tif (!(await this.git.supports('git:merge-tree:merge-base'))) {\n\t\t\treturn createConflictDetectionError('unsupported');\n\t\t}\n\n\t\t// git stash create writes commit objects but touches neither the working tree nor the stash ref, and\n\t\t// captures tracked changes only — which is exactly what autostash does\n\t\tlet stashSha: string;\n\t\ttry {\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t'stash',\n\t\t\t\t'create',\n\t\t\t);\n\t\t\tstashSha = result.stdout.trim();\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn createConflictDetectionError('other');\n\t\t}\n\n\t\tif (!stashSha) return { status: 'clean' };\n\n\t\t// Key on what the simulation actually consumes — the stash's tree and its first parent (the HEAD it was\n\t\t// taken against, and so the merge base). The stash SHA itself embeds a commit timestamp, so two runs over\n\t\t// an identical tree produce different SHAs and a SHA-keyed entry could never be hit.\n\t\tlet stashTree: string;\n\t\tlet stashParent: string;\n\t\ttry {\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t'rev-parse',\n\t\t\t\t`${stashSha}^{tree}`,\n\t\t\t\t`${stashSha}^`,\n\t\t\t);\n\t\t\t[stashTree, stashParent] = result.stdout.trim().split('\\n');\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\treturn createConflictDetectionError('other');\n\t\t}\n\n\t\tconst cacheKey: ConflictDetectionCacheKey = `reapply:${ontoTreeOid}:${stashTree}.${stashParent}`;\n\t\treturn this.cache.conflictDetection.getOrCreate(\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tasync (_cacheable, signal) => {\n\t\t\t\t// The stash commit's first parent is the HEAD it was taken against, which is the correct merge\n\t\t\t\t// base for a reapply — ours is the post-integration tree, theirs is the stash\n\t\t\t\tconst step = await this.runMergeTreeStep(repoPath, `${stashSha}^`, ontoTreeOid, stashSha, signal);\n\t\t\t\tif (!step.ok) return createConflictDetectionError(step.reason);\n\n\t\t\t\tif (!step.result.conflicts.length) return { status: 'clean', treeOid: step.result.treeOid };\n\n\t\t\t\treturn {\n\t\t\t\t\tstatus: 'conflicts',\n\t\t\t\t\tconflict: {\n\t\t\t\t\t\trepoPath: repoPath,\n\t\t\t\t\t\tbranch: stashSha,\n\t\t\t\t\t\ttarget: ontoTreeOid,\n\t\t\t\t\t\tfiles: step.result.conflicts,\n\t\t\t\t\t\tshas: undefined,\n\t\t\t\t\t},\n\t\t\t\t\ttreeOid: step.result.treeOid,\n\t\t\t\t};\n\t\t\t},\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\tprivate async runMergeTreeStep(\n\t\trepoPath: string,\n\t\tbase: string,\n\t\tours: string,\n\t\ttheirs: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<{ ok: true; result: GitMergeConflict } | { ok: false; reason: ConflictDetectionErrorReason }> {\n\t\tconst scope = getScopedLogger();\n\n\t\tlet data;\n\t\ttry {\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t'merge-tree',\n\t\t\t\t'--write-tree',\n\t\t\t\t'-z',\n\t\t\t\t'--name-only',\n\t\t\t\t'--no-messages',\n\t\t\t\t`--merge-base=${base}`,\n\t\t\t\tours,\n\t\t\t\ttheirs,\n\t\t\t);\n\t\t\tdata = result.stdout;\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\tconst msg: string = ex?.toString() ?? '';\n\t\t\tif (GitErrors.notAValidObjectName.test(msg)) {\n\t\t\t\tscope?.error(ex, `'${ours}' or '${theirs}' not found - ensure the branches/commits exist`);\n\t\t\t\treturn { ok: false, reason: 'refNotFound' };\n\t\t\t} else if (GitErrors.badRevision.test(msg)) {\n\t\t\t\tscope?.error(ex, `Invalid revision: ${msg.slice(msg.indexOf(\"'\"))}`);\n\t\t\t\treturn { ok: false, reason: 'refNotFound' };\n\t\t\t} else if (GitErrors.noMergeBase.test(msg)) {\n\t\t\t\tscope?.error(ex, `Unable to merge '${ours}' and '${theirs}' as they have no common ancestor`);\n\t\t\t\treturn { ok: false, reason: 'noMergeBase' };\n\t\t\t} else if (ex instanceof GitError) {\n\t\t\t\tdata = ex.stdout;\n\t\t\t} else {\n\t\t\t\tscope?.error(ex, 'Failed to execute merge-tree for conflict check');\n\t\t\t\treturn { ok: false, reason: 'other' };\n\t\t\t}\n\t\t}\n\n\t\treturn { ok: true, result: parseMergeTreeConflict(data ?? '') };\n\t}\n\n\tprivate async checkForPotentialConflicts(\n\t\trepoPath: string,\n\t\tcommits: Iterable<{ sha: string; parent: string }>,\n\t\ttargetBranch: string,\n\t\tcancellation?: AbortSignal,\n\t\toptions?: { stopOnFirstConflict?: boolean },\n\t): Promise<ConflictDetectionResult> {\n\t\tconst scope = getScopedLogger();\n\n\t\t// Requires Git v2.38+ for --write-tree with 3-arg form\n\t\t// `runMergeTreeStep` relies on `--merge-base`\n\t\tif (!(await this.git.supports('git:merge-tree:merge-base'))) {\n\t\t\treturn createConflictDetectionError('unsupported');\n\t\t}\n\n\t\tlet currentTreeOid: string;\n\t\ttry {\n\t\t\t// Get the initial target branch tree OID\n\t\t\tconst treeResult = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'throw' },\n\t\t\t\t'rev-parse',\n\t\t\t\t`${targetBranch}^{tree}`,\n\t\t\t);\n\t\t\tcurrentTreeOid = treeResult.stdout.trim();\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\tscope?.error(ex, `Failed to resolve target branch '${targetBranch}'`);\n\t\t\treturn createConflictDetectionError('refNotFound');\n\t\t}\n\n\t\tconst conflictingShas: string[] = [];\n\t\tconst conflictingFilePaths = new Set<string>();\n\n\t\tfor (const commit of commits) {\n\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t// Use merge-tree --write-tree with --merge-base to simulate cherry-pick:\n\t\t\t// merge-tree --write-tree --merge-base=<commit-parent> <current-tree> <commit>\n\t\t\t// This performs a 3-way merge where:\n\t\t\t// - base = commit.parent (where the commit started)\n\t\t\t// - ours = currentTreeOid (current state of the target)\n\t\t\t// - theirs = commit.sha (what we're cherry-picking)\n\t\t\tconst step = await this.runMergeTreeStep(repoPath, commit.parent, currentTreeOid, commit.sha, cancellation);\n\t\t\tif (!step.ok) return createConflictDetectionError(step.reason);\n\n\t\t\tconst mergeConflict = step.result;\n\n\t\t\tif (mergeConflict.conflicts.length) {\n\t\t\t\tconflictingShas.push(commit.sha);\n\t\t\t\tfor (const file of mergeConflict.conflicts) {\n\t\t\t\t\tconflictingFilePaths.add(file.path);\n\t\t\t\t}\n\n\t\t\t\tif (options?.stopOnFirstConflict) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstatus: 'conflicts',\n\t\t\t\t\t\tconflict: {\n\t\t\t\t\t\t\trepoPath: repoPath,\n\t\t\t\t\t\t\tbranch: commit.sha,\n\t\t\t\t\t\t\ttarget: targetBranch,\n\t\t\t\t\t\t\tfiles: mergeConflict.conflicts,\n\t\t\t\t\t\t\tshas: [commit.sha],\n\t\t\t\t\t\t},\n\t\t\t\t\t\tstoppedOnFirstConflict: true,\n\t\t\t\t\t\ttreeOid: mergeConflict.treeOid || undefined,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Update currentTreeOid to the result tree OID for the next iteration\n\t\t\t// This works even when there are conflicts - the tree contains conflict markers\n\t\t\tif (mergeConflict.treeOid) {\n\t\t\t\tcurrentTreeOid = mergeConflict.treeOid;\n\t\t\t}\n\t\t}\n\n\t\tif (conflictingShas.length) {\n\t\t\treturn {\n\t\t\t\tstatus: 'conflicts',\n\t\t\t\tconflict: {\n\t\t\t\t\trepoPath: repoPath,\n\t\t\t\t\tbranch: conflictingShas[0],\n\t\t\t\t\ttarget: targetBranch,\n\t\t\t\t\tfiles: Array.from(conflictingFilePaths, path => ({ path: path })),\n\t\t\t\t\tshas: conflictingShas,\n\t\t\t\t},\n\t\t\t\tstoppedOnFirstConflict: false,\n\t\t\t\ttreeOid: currentTreeOid,\n\t\t\t};\n\t\t}\n\n\t\treturn { status: 'clean', treeOid: currentTreeOid };\n\t}\n\n\t@debug({ exit: true })\n\tgetBaseBranchName(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: { priority?: GitCommandPriority },\n\t\tcancellation?: AbortSignal,\n\t): Promise<string | undefined> {\n\t\tconst priority = options?.priority;\n\t\tconst priorityOpts = priority != null ? { priority: priority } : undefined;\n\n\t\treturn this.cache.getBaseBranchName(\n\t\t\trepoPath,\n\t\t\tref,\n\t\t\tasync (commonPath, cacheable, signal) => {\n\t\t\t\ttry {\n\t\t\t\t\t// getGkConfig has built-in fallback to regular config for backward compatibility\n\t\t\t\t\tlet mergeBase = await this.provider.config.getGkConfig(commonPath, `branch.${ref}.gk-merge-base`);\n\t\t\t\t\tlet update = false;\n\n\t\t\t\t\t// Also check vscode-merge-base in regular config (VS Code compatibility)\n\t\t\t\t\tif (mergeBase == null) {\n\t\t\t\t\t\tmergeBase = await this.provider.config.getConfig(commonPath, `branch.${ref}.vscode-merge-base`);\n\t\t\t\t\t\tupdate = mergeBase != null;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (mergeBase != null) {\n\t\t\t\t\t\tconst branch = await this.provider.refs.getSymbolicReferenceName(\n\t\t\t\t\t\t\tcommonPath,\n\t\t\t\t\t\t\tmergeBase,\n\t\t\t\t\t\t\tpriorityOpts,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (branch != null) {\n\t\t\t\t\t\t\tif (update) {\n\t\t\t\t\t\t\t\t// Self-write: the value we're storing is exactly what this factory is\n\t\t\t\t\t\t\t\t// returning, so any in-flight `branchOverviews` or `baseBranchName` entry\n\t\t\t\t\t\t\t\t// being populated against this resolution should NOT be evicted.\n\t\t\t\t\t\t\t\tvoid this.storeBaseBranchName(commonPath, ref, branch, {\n\t\t\t\t\t\t\t\t\tskipInvalidation: ['branchOverviews', 'baseBranchName'],\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn branch;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch {}\n\n\t\t\t\tconst reflog = await this.getBaseBranchFromReflog(\n\t\t\t\t\tcommonPath,\n\t\t\t\t\tref,\n\t\t\t\t\t{ upstream: true, priority: priority },\n\t\t\t\t\tsignal,\n\t\t\t\t);\n\t\t\t\tif (reflog.branch != null) {\n\t\t\t\t\t// Self-write: see comment on the migration path above.\n\t\t\t\t\tvoid this.storeBaseBranchName(commonPath, ref, reflog.branch, {\n\t\t\t\t\t\tskipInvalidation: ['branchOverviews', 'baseBranchName'],\n\t\t\t\t\t});\n\t\t\t\t\treturn reflog.branch;\n\t\t\t\t}\n\n\t\t\t\t// This entry has no TTL and the `'branches'` cascade no longer clears it (a tip move can't\n\t\t\t\t// change a base), so a failed read cached as `undefined` would read as \"no base branch\" for\n\t\t\t\t// the rest of the session. Only a reflog that actually RAN and found nothing is an answer.\n\t\t\t\tif (reflog.failed) {\n\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\t/**\n\t * `failed` separates \"the reflog ran and had no answer\" from \"the read never happened\" — the caller\n\t * caches the former forever and must not cache the latter.\n\t */\n\tprivate async getBaseBranchFromReflog(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: { upstream: true; priority?: GitCommandPriority },\n\t\tcancellation?: AbortSignal,\n\t): Promise<{ branch: string | undefined; failed: boolean }> {\n\t\tconst priority = options?.priority;\n\t\tconst priorityOpts = priority != null ? { priority: priority } : undefined;\n\n\t\ttry {\n\t\t\tlet entries = await this.provider.refs.getReflogEntries(\n\t\t\t\trepoPath,\n\t\t\t\tref,\n\t\t\t\t{ grep: 'branch: Created from *.', priority: priority },\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (entries.length !== 1) return { branch: undefined, failed: false };\n\n\t\t\t// Check if branch created from an explicit branch\n\t\t\tlet match = entries[0].message.match(/branch: Created from (.*)$/);\n\t\t\tif (match?.length === 2) {\n\t\t\t\tlet name: string | undefined = match[1];\n\t\t\t\tif (name !== 'HEAD') {\n\t\t\t\t\tif (options?.upstream) {\n\t\t\t\t\t\tconst upstream = await this.provider.refs.getSymbolicReferenceName(\n\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\t`${name}@{u}`,\n\t\t\t\t\t\t\tpriorityOpts,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (upstream) return { branch: upstream, failed: false };\n\t\t\t\t\t}\n\n\t\t\t\t\tname = await this.provider.refs.getSymbolicReferenceName(repoPath, name, priorityOpts);\n\t\t\t\t\tif (name) return { branch: name, failed: false };\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Check if branch was created from HEAD\n\t\t\tentries = await this.provider.refs.getReflogEntries(\n\t\t\t\trepoPath,\n\t\t\t\t'HEAD',\n\t\t\t\t{ grep: `checkout: moving from .* to ${ref.replace('refs/heads/', '')}`, priority: priority },\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (!entries.length) return { branch: undefined, failed: false };\n\n\t\t\tmatch = entries.at(-1)!.message.match(/checkout: moving from ([^\\s]+)\\s/);\n\t\t\tif (match?.length === 2) {\n\t\t\t\tlet name: string | undefined = match[1];\n\t\t\t\tif (options?.upstream) {\n\t\t\t\t\tconst upstream = await this.provider.refs.getSymbolicReferenceName(\n\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t`${name}@{u}`,\n\t\t\t\t\t\tpriorityOpts,\n\t\t\t\t\t);\n\t\t\t\t\tif (upstream) return { branch: upstream, failed: false };\n\t\t\t\t}\n\n\t\t\t\tname = await this.provider.refs.getSymbolicReferenceName(repoPath, name, priorityOpts);\n\t\t\t\tif (name) return { branch: name, failed: false };\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\t// A ref that is unborn, or gone since it was listed, has no reflog to read: an answer, not a failure\n\t\t\tconst msg: string = ex?.toString() ?? '';\n\t\t\tconst stderr = ex instanceof GitError ? ex.stderr : undefined;\n\t\t\tif (\n\t\t\t\t[GitErrors.badRevision, GitErrors.ambiguousArgument].some(\n\t\t\t\t\terror => error.test(msg) || (stderr != null && error.test(stderr)),\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn { branch: undefined, failed: false };\n\t\t\t}\n\n\t\t\t// `getReflogEntries` rejects on a failed read, so a read that never happened isn't taken as \"no base\"\n\t\t\treturn { branch: undefined, failed: true };\n\t\t}\n\n\t\treturn { branch: undefined, failed: false };\n\t}\n\n\t@debug({ exit: true })\n\tasync getStoredMergeTargetBranchName(repoPath: string, ref: string): Promise<string | undefined> {\n\t\tconst target =\n\t\t\t(await this.getStoredUserMergeTargetBranchName?.(repoPath, ref)) ??\n\t\t\t(await this.getStoredDetectedMergeTargetBranchName?.(repoPath, ref));\n\t\treturn target?.trim() || undefined;\n\t}\n\n\t@debug({ exit: true })\n\tasync getStoredDetectedMergeTargetBranchName(repoPath: string, ref: string): Promise<string | undefined> {\n\t\tconst target =\n\t\t\t(await this.provider.config.getGkConfig(repoPath, `branch.${ref}.gk-merge-target`)) ??\n\t\t\t(await this.provider.config.getGkConfig(repoPath, `branch.${ref}.gk-target-base`)); // legacy key\n\t\treturn target?.trim() || undefined;\n\t}\n\n\t@debug()\n\tasync getStoredUserMergeTargetBranchName(repoPath: string, ref: string): Promise<string | undefined> {\n\t\tconst target = await this.provider.config.getGkConfig(repoPath, `branch.${ref}.gk-merge-target-user`);\n\t\treturn target?.trim() || undefined;\n\t}\n\n\t/** Updates the last accessed timestamp for the current branch */\n\t@debounce(2.5 * 60 * 1000)\n\t@debug()\n\tasync onCurrentBranchAccessed(repoPath: string): Promise<void> {\n\t\tconst branch = await this.getBranch(repoPath);\n\t\tif (branch == null || branch.remote || branch.detached) return;\n\n\t\tawait this.storeBranchMetadata(repoPath, 'gk-last-accessed', branch.name, new Date());\n\t}\n\n\t/** Updates the last accessed and modified timestamp for the current branch */\n\t@debounce(2.5 * 60 * 1000)\n\t@debug()\n\tasync onCurrentBranchModified(repoPath: string): Promise<void> {\n\t\tconst branch = await this.getBranch(repoPath);\n\t\tif (branch == null || branch.remote || branch.detached) return;\n\n\t\tconst now = new Date();\n\t\tawait this.storeBranchMetadata(repoPath, 'gk-last-accessed', branch.name, now);\n\t\tawait this.storeBranchMetadata(repoPath, 'gk-last-modified', branch.name, now);\n\t}\n\n\t/** Updates the agent last activity timestamp for the current branch */\n\t@debounce(2.5 * 60 * 1000)\n\t@debug()\n\tasync onCurrentBranchAgentActivity(repoPath: string): Promise<void> {\n\t\tconst branch = await this.getBranch(repoPath);\n\t\tif (branch == null || branch.remote || branch.detached) return;\n\n\t\tawait this.storeBranchMetadata(repoPath, 'gk-agent-last-activity', branch.name, new Date());\n\t}\n\n\t@debug()\n\tasync renameBranch(repoPath: string, oldName: string, newName: string): Promise<void> {\n\t\tconst args = ['branch', '-m', oldName, newName];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t\t// The branch keeps its identity across a rename, so move its stored gk metadata with it —\n\t\t\t// otherwise the new name re-derives a base it already had, and the old name is left holding\n\t\t\t// metadata for a branch that no longer exists under it.\n\t\t\tawait this.provider.config.renameGkConfigBranchSection(repoPath, oldName, newName);\n\t\t\t// Old name's entry is now orphaned; the new name must not inherit a predecessor's base\n\t\t\tthis.cache.deleteBaseBranchName(repoPath, oldName);\n\t\t\tthis.cache.deleteBaseBranchName(repoPath, newName);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['heads']);\n\t\t} catch (ex) {\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'branch',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew BranchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\taction: 'rename',\n\t\t\t\t\t\t\tbranch: oldName,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t@debug()\n\tasync setUpstreamBranch(repoPath: string, name: string, upstream: string | undefined): Promise<void> {\n\t\tconst args =\n\t\t\tupstream == null ? ['branch', '--unset-upstream', name] : ['branch', '--set-upstream-to', upstream, name];\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['heads']);\n\t\t} catch (ex) {\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'branch',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew BranchError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\taction: upstream == null ? 'unset upstream of' : `set upstream to '${upstream}' for`,\n\t\t\t\t\t\t\tbranch: name,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t@debug()\n\tasync storeBaseBranchName(\n\t\trepoPath: string,\n\t\tref: string,\n\t\tbase: string,\n\t\toptions?: { skipInvalidation?: readonly GkConfigInvalidationTarget[] },\n\t): Promise<void> {\n\t\tawait this.provider.config.setGkConfig(repoPath, `branch.${ref}.gk-merge-base`, base, options);\n\t}\n\n\t@debug()\n\tasync storeMergeTargetBranchName(\n\t\trepoPath: string,\n\t\tref: string,\n\t\ttarget: string,\n\t\toptions?: { skipInvalidation?: readonly GkConfigInvalidationTarget[] },\n\t): Promise<void> {\n\t\tawait this.provider.config.setGkConfig(repoPath, `branch.${ref}.gk-merge-target`, target, options);\n\t}\n\n\t@debug()\n\tasync storeUserMergeTargetBranchName(repoPath: string, ref: string, target: string | undefined): Promise<void> {\n\t\tawait this.provider.config.setGkConfig(repoPath, `branch.${ref}.gk-merge-target-user`, target);\n\t}\n\n\t/**\n\t * Gets all branch metadata (dates and disposition) from git config in a single batch operation.\n\t * @returns A map of branch name to metadata.\n\t */\n\tprivate getBranchMetadataMap(repoPath: string): Promise<Map<string, BranchMetadata>> {\n\t\treturn this.cache.getBranchMetadataMap(repoPath, async commonPath => {\n\t\t\tconst scope = getScopedLogger();\n\t\t\tconst metadataMap = new Map<string, BranchMetadata>();\n\n\t\t\ttry {\n\t\t\t\t// Use git config --get-regexp to load all gk-* branch metadata in one call\n\t\t\t\tconst configMap = await this.provider.config.getGkConfigRegex(\n\t\t\t\t\tcommonPath,\n\t\t\t\t\t'^branch\\\\..*\\\\.gk-(last-(accessed|modified)|disposition|agent-last-activity)$',\n\t\t\t\t);\n\t\t\t\tif (!configMap.size) return metadataMap;\n\n\t\t\t\tfor (const [key, value] of configMap) {\n\t\t\t\t\t// Extract branch name and metadata key from \"branch.{name}.gk-{key}\"\n\t\t\t\t\tif (!key.startsWith('branch.')) continue;\n\n\t\t\t\t\tconst keyParts = key.split('.');\n\t\t\t\t\tif (keyParts.length < 3) continue;\n\n\t\t\t\t\t// Branch name is everything between \"branch.\" and the last \".gk-*\"\n\t\t\t\t\tconst metaKey = keyParts.at(-1);\n\t\t\t\t\tconst branchName = keyParts.slice(1, -1).join('.');\n\n\t\t\t\t\tlet metadata = metadataMap.get(branchName);\n\t\t\t\t\tif (metadata == null) {\n\t\t\t\t\t\tmetadata = {};\n\t\t\t\t\t\tmetadataMap.set(branchName, metadata);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (metaKey === 'gk-last-accessed') {\n\t\t\t\t\t\tmetadata.lastAccessedAt = value;\n\t\t\t\t\t} else if (metaKey === 'gk-last-modified') {\n\t\t\t\t\t\tmetadata.lastModifiedAt = value;\n\t\t\t\t\t} else if (metaKey === 'gk-agent-last-activity') {\n\t\t\t\t\t\tmetadata.agentLastActivityAt = value;\n\t\t\t\t\t} else if (metaKey === 'gk-disposition') {\n\t\t\t\t\t\tif (value === 'starred' || value === 'archived') {\n\t\t\t\t\t\t\tmetadata.disposition = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (ex) {\n\t\t\t\tdebugger;\n\t\t\t\tscope?.error(ex);\n\t\t\t}\n\n\t\t\treturn metadataMap;\n\t\t});\n\t}\n\n\tprivate async storeBranchMetadata(\n\t\trepoPath: string,\n\t\tkey: 'gk-last-accessed' | 'gk-last-modified' | 'gk-agent-last-activity',\n\t\tref: string,\n\t\tdate: Date,\n\t): Promise<void> {\n\t\tconst value = await this.provider.config.getGkConfig(repoPath, `branch.${ref}.${key}`);\n\t\t// Skip if incoming date is not at least 5 minutes newer than stored date\n\t\tif (value != null && date.getTime() - new Date(value).getTime() < dateMetadataStaleThresholdMs) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn this.provider.config.setGkConfig(repoPath, `branch.${ref}.${key}`, date.toISOString());\n\t}\n\n\tasync setBranchDisposition(\n\t\trepoPath: string,\n\t\tbranchName: string,\n\t\tdisposition: BranchDisposition | undefined,\n\t): Promise<void> {\n\t\tawait this.provider.config.setGkConfig(repoPath, `branch.${branchName}.gk-disposition`, disposition);\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['starred']);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAM,+BAA+B;AAErC,IAAa,yBAAb,MAAsE;CAEnD;CACA;CACA;CACA;CAJlB,YACC,SACA,KACA,OACA,UACC;EAJgB,KAAA,UAAA;EACA,KAAA,MAAA;EACA,KAAA,QAAA;EACA,KAAA,WAAA;CACf;CAEH,MACM,UACL,UACA,MACA,SACA,cACiC;EACjC,IAAI,SAAS,OACZ,KAAK,MAAM,YAAY,UAAU,UAAU;EAG5C,IAAI,QAAQ,MAAM;GACjB,MAAM,EACL,QAAQ,CAAC,YACN,MAAM,KAAK,YAAY,UAAU,EAAE,SAAQ,MAAK,EAAE,SAAS,KAAK,G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AA,uBAAA,WAAA,8BAAA,IAAA;AA2CN,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,8BAAA,IAAA;AA8EN,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,qCAAA,IAAA;AA2NN,WAAA,CAAA,MAAM,EAAE,MAAM,KAAK,CAAC,CAAA,GAAA,uBAAA,WAAA,qBAAA,IAAA;AA8JpB,WAAA,CAAA,MAAM,EAAE,MAAM,KAAK,CAAC,CAAA,GAAA,uBAAA,WAAA,kCAAA,IAAA;AAQpB,WAAA,CAAA,MAAM,EAAE,MAAM,KAAK,CAAC,CAAA,GAAA,uBAAA,WAAA,0CAAA,IAAA;AAQpB,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,sCAAA,IAAA;AAON,WAAA,CAAA,SAAS,IAAe,GACxB,MAAM,CAAA,GAAA,uBAAA,WAAA,2BAAA,IAAA;AASN,WAAA,CAAA,SAAS,IAAe,GACxB,MAAM,CAAA,GAAA,uBAAA,WAAA,2BAAA,IAAA;AAWN,WAAA,CAAA,SAAS,IAAe,GACxB,MAAM,CAAA,GAAA,uBAAA,WAAA,gCAAA,IAAA;AAQN,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,gBAAA,IAAA;AAgCN,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,qBAAA,IAAA;AA0BN,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,uBAAA,IAAA;AAUN,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,8BAAA,IAAA;AAUN,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,kCAAA,IAAA"}
|
|
@@ -9,7 +9,7 @@ import { GitServiceContext } from "../../git/context.js";
|
|
|
9
9
|
import { GitUser } from "../../git/models/user.js";
|
|
10
10
|
import { GitCommandPriority } from "../../git/run.types.js";
|
|
11
11
|
import { GitReflog } from "../../git/models/reflog.js";
|
|
12
|
-
import { GitCommitReachability, GitCommitsSubProvider, GitLogForPathOptions, GitLogOptions, GitLogShasOptions, GitSearchCommitsOptions, IncomingActivityOptions, LeftRightCommitCountResult, SearchCommitsResult } from "../../git/providers/commits.js";
|
|
12
|
+
import { GitCommitReachability, GitCommitsSubProvider, GitLogForPathOptions, GitLogOptions, GitLogShasOptions, GitRefExclusions, GitSearchCommitsOptions, IncomingActivityOptions, LeftRightCommitCountResult, SearchCommitsResult } from "../../git/providers/commits.js";
|
|
13
13
|
import { Cache } from "../../git/cache.js";
|
|
14
14
|
import { Git } from "../exec/git.js";
|
|
15
15
|
import { CliGitProviderInternal } from "../cliGitProvider.js";
|
|
@@ -44,7 +44,9 @@ export declare class CommitsGitSubProvider implements GitCommitsSubProvider {
|
|
|
44
44
|
source?: unknown;
|
|
45
45
|
}, cancellation?: AbortSignal): Promise<string>;
|
|
46
46
|
getCommit(repoPath: string, rev: string, cancellation?: AbortSignal): Promise<GitCommit | undefined>;
|
|
47
|
-
getCommitCount(repoPath: string, rev: string,
|
|
47
|
+
getCommitCount(repoPath: string, rev: string, options?: {
|
|
48
|
+
excluding?: GitRefExclusions;
|
|
49
|
+
}, cancellation?: AbortSignal): Promise<number | undefined>;
|
|
48
50
|
hasUnpublishedCommits(repoPath: string, rev: string, cancellation?: AbortSignal): Promise<boolean | undefined>;
|
|
49
51
|
filterUnpublishedShas(repoPath: string, shas: readonly string[], options?: {
|
|
50
52
|
priority?: GitCommandPriority;
|