@gitkraken/core-gitlens 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/CHANGELOG.md +78 -1
  2. package/dist/git/cache.d.ts +84 -29
  3. package/dist/git/cache.js +188 -54
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/features.d.ts +1 -1
  6. package/dist/git/features.js +5 -0
  7. package/dist/git/features.js.map +1 -1
  8. package/dist/git/models/branch.d.ts +20 -2
  9. package/dist/git/models/branch.js +28 -6
  10. package/dist/git/models/branch.js.map +1 -1
  11. package/dist/git/models/reference.d.ts +3 -0
  12. package/dist/git/models/status.js +2 -2
  13. package/dist/git/models/worktree.d.ts +4 -1
  14. package/dist/git/models/worktree.js +4 -2
  15. package/dist/git/models/worktree.js.map +1 -1
  16. package/dist/git/parsers/diffParser.js +1 -1
  17. package/dist/git/providers/branches.d.ts +73 -8
  18. package/dist/git/providers/operations.d.ts +3 -2
  19. package/dist/git/providers/pausedOperations.d.ts +6 -0
  20. package/dist/git/providers/provider.d.ts +45 -2
  21. package/dist/git/providers/revision.d.ts +17 -3
  22. package/dist/git/providers/status.d.ts +8 -2
  23. package/dist/git/remotes/azure-devops.js +61 -53
  24. package/dist/git/remotes/azure-devops.js.map +1 -1
  25. package/dist/git/run.types.d.ts +12 -0
  26. package/dist/git/service.d.ts +8 -5
  27. package/dist/git/service.js +16 -8
  28. package/dist/git/service.js.map +1 -1
  29. package/dist/git/utils/branch.utils.d.ts +12 -2
  30. package/dist/git/utils/branch.utils.js +49 -5
  31. package/dist/git/utils/branch.utils.js.map +1 -1
  32. package/dist/git/utils/reference.utils.d.ts +1 -0
  33. package/dist/git/utils/reference.utils.js.map +1 -1
  34. package/dist/git/watching/changeEvent.d.ts +13 -2
  35. package/dist/git/watching/changeEvent.js +17 -3
  36. package/dist/git/watching/changeEvent.js.map +1 -1
  37. package/dist/git/watching/gitDirPoller.d.ts +111 -0
  38. package/dist/git/watching/gitDirPoller.js +266 -0
  39. package/dist/git/watching/gitDirPoller.js.map +1 -0
  40. package/dist/git/watching/provider.d.ts +16 -0
  41. package/dist/git/watching/watchGroup.d.ts +40 -4
  42. package/dist/git/watching/watchGroup.js +143 -17
  43. package/dist/git/watching/watchGroup.js.map +1 -1
  44. package/dist/git/watching/watchService.d.ts +70 -1
  45. package/dist/git/watching/watchService.js +158 -13
  46. package/dist/git/watching/watchService.js.map +1 -1
  47. package/dist/git/watching/watchSession.d.ts +44 -0
  48. package/dist/git/watching/watchSession.js +91 -6
  49. package/dist/git/watching/watchSession.js.map +1 -1
  50. package/dist/git/watching/watcherPatterns.d.ts +21 -0
  51. package/dist/git/watching/watcherPatterns.js +67 -1
  52. package/dist/git/watching/watcherPatterns.js.map +1 -1
  53. package/dist/git/watching/worktreeSummary.d.ts +34 -7
  54. package/dist/git/watching/worktreeSummary.js +39 -12
  55. package/dist/git/watching/worktreeSummary.js.map +1 -1
  56. package/dist/git-cli/cliGitProvider.d.ts +40 -2
  57. package/dist/git-cli/cliGitProvider.js +182 -18
  58. package/dist/git-cli/cliGitProvider.js.map +1 -1
  59. package/dist/git-cli/exec/commandClassifier.d.ts +15 -0
  60. package/dist/git-cli/exec/commandClassifier.js +48 -2
  61. package/dist/git-cli/exec/commandClassifier.js.map +1 -1
  62. package/dist/git-cli/exec/git.d.ts +20 -3
  63. package/dist/git-cli/exec/git.js +63 -19
  64. package/dist/git-cli/exec/git.js.map +1 -1
  65. package/dist/git-cli/exec/gitQueue.d.ts +2 -0
  66. package/dist/git-cli/exec/gitQueue.js +2 -1
  67. package/dist/git-cli/exec/gitQueue.js.map +1 -1
  68. package/dist/git-cli/exec/indexLock.d.ts +39 -0
  69. package/dist/git-cli/exec/indexLock.js +160 -0
  70. package/dist/git-cli/exec/indexLock.js.map +1 -0
  71. package/dist/git-cli/parsers/blameParser.js +2 -2
  72. package/dist/git-cli/parsers/refParser.js +4 -2
  73. package/dist/git-cli/parsers/refParser.js.map +1 -1
  74. package/dist/git-cli/parsers/statusParser.d.ts +6 -0
  75. package/dist/git-cli/parsers/statusParser.js +33 -3
  76. package/dist/git-cli/parsers/statusParser.js.map +1 -1
  77. package/dist/git-cli/parsers/worktreeParser.js +42 -2
  78. package/dist/git-cli/parsers/worktreeParser.js.map +1 -1
  79. package/dist/git-cli/providers/branchRemote.d.ts +14 -0
  80. package/dist/git-cli/providers/branchRemote.js +36 -0
  81. package/dist/git-cli/providers/branchRemote.js.map +1 -0
  82. package/dist/git-cli/providers/branches.d.ts +109 -10
  83. package/dist/git-cli/providers/branches.js +630 -134
  84. package/dist/git-cli/providers/branches.js.map +1 -1
  85. package/dist/git-cli/providers/commits.js +2 -2
  86. package/dist/git-cli/providers/config.d.ts +9 -5
  87. package/dist/git-cli/providers/config.js +58 -25
  88. package/dist/git-cli/providers/config.js.map +1 -1
  89. package/dist/git-cli/providers/contributors.js +1 -1
  90. package/dist/git-cli/providers/graph.js +9 -6
  91. package/dist/git-cli/providers/graph.js.map +1 -1
  92. package/dist/git-cli/providers/operations.d.ts +17 -0
  93. package/dist/git-cli/providers/operations.js +172 -111
  94. package/dist/git-cli/providers/operations.js.map +1 -1
  95. package/dist/git-cli/providers/pausedOperations.d.ts +8 -0
  96. package/dist/git-cli/providers/pausedOperations.js +59 -39
  97. package/dist/git-cli/providers/pausedOperations.js.map +1 -1
  98. package/dist/git-cli/providers/refs.js +11 -8
  99. package/dist/git-cli/providers/refs.js.map +1 -1
  100. package/dist/git-cli/providers/remotes.js +19 -10
  101. package/dist/git-cli/providers/remotes.js.map +1 -1
  102. package/dist/git-cli/providers/revision.d.ts +6 -2
  103. package/dist/git-cli/providers/revision.js +38 -12
  104. package/dist/git-cli/providers/revision.js.map +1 -1
  105. package/dist/git-cli/providers/staging.js +39 -14
  106. package/dist/git-cli/providers/staging.js.map +1 -1
  107. package/dist/git-cli/providers/stash.d.ts +2 -0
  108. package/dist/git-cli/providers/stash.js +33 -18
  109. package/dist/git-cli/providers/stash.js.map +1 -1
  110. package/dist/git-cli/providers/status.d.ts +3 -1
  111. package/dist/git-cli/providers/status.js +40 -22
  112. package/dist/git-cli/providers/status.js.map +1 -1
  113. package/dist/git-cli/providers/tags.js +6 -4
  114. package/dist/git-cli/providers/tags.js.map +1 -1
  115. package/dist/git-cli/providers/worktrees.d.ts +1 -0
  116. package/dist/git-cli/providers/worktrees.js +60 -31
  117. package/dist/git-cli/providers/worktrees.js.map +1 -1
  118. package/dist/git-cli/service.d.ts +6 -0
  119. package/dist/git-cli/service.js +5 -2
  120. package/dist/git-cli/service.js.map +1 -1
  121. package/dist/plus/git-github/providers/github/revision.d.ts +6 -2
  122. package/dist/plus/git-github/providers/github/revision.js +15 -10
  123. package/dist/plus/git-github/providers/github/revision.js.map +1 -1
  124. package/dist/plus/git-github/providers/github/status.d.ts +3 -1
  125. package/dist/plus/git-github/providers/github/status.js +2 -2
  126. package/dist/plus/git-github/providers/github/status.js.map +1 -1
  127. package/dist/plus/integrations/collectionMetadata.d.ts +13 -2
  128. package/dist/plus/integrations/collectionMetadata.js +14 -2
  129. package/dist/plus/integrations/collectionMetadata.js.map +1 -1
  130. package/dist/plus/integrations/index.d.ts +2 -2
  131. package/dist/plus/integrations/index.js.map +1 -1
  132. package/dist/plus/integrations/integrationService.d.ts +1 -0
  133. package/dist/plus/integrations/integrationService.js +1 -1
  134. package/dist/plus/integrations/integrationService.js.map +1 -1
  135. package/dist/plus/integrations/manager.d.ts +1 -0
  136. package/dist/plus/integrations/models/gitHostIntegration.d.ts +41 -5
  137. package/dist/plus/integrations/models/gitHostIntegration.js +106 -29
  138. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  139. package/dist/plus/integrations/models/issueReads.d.ts +17 -4
  140. package/dist/plus/integrations/providers/apiClients.d.ts +2 -0
  141. package/dist/plus/integrations/providers/apiClients.js +7 -1
  142. package/dist/plus/integrations/providers/apiClients.js.map +1 -1
  143. package/dist/plus/integrations/providers/azure/azure.d.ts +5 -4
  144. package/dist/plus/integrations/providers/azure/azure.js +36 -76
  145. package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
  146. package/dist/plus/integrations/providers/azure/azure.utils.js +20 -17
  147. package/dist/plus/integrations/providers/azure/azure.utils.js.map +1 -1
  148. package/dist/plus/integrations/providers/azure/models.d.ts +2 -2
  149. package/dist/plus/integrations/providers/azure/models.js +4 -4
  150. package/dist/plus/integrations/providers/azure/models.js.map +1 -1
  151. package/dist/plus/integrations/providers/azure/workItemStateCategories.d.ts +21 -12
  152. package/dist/plus/integrations/providers/azure/workItemStateCategories.js +74 -17
  153. package/dist/plus/integrations/providers/azure/workItemStateCategories.js.map +1 -1
  154. package/dist/plus/integrations/providers/azureDevOps.d.ts +44 -0
  155. package/dist/plus/integrations/providers/azureDevOps.js +108 -17
  156. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  157. package/dist/plus/integrations/providers/azureDevOpsServer.d.ts +45 -1
  158. package/dist/plus/integrations/providers/azureDevOpsServer.js +121 -6
  159. package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
  160. package/dist/plus/integrations/providers/jira-server.js +18 -14
  161. package/dist/plus/integrations/providers/jira-server.js.map +1 -1
  162. package/dist/plus/integrations/providers/jira.js +18 -14
  163. package/dist/plus/integrations/providers/jira.js.map +1 -1
  164. package/dist/plus/integrations/providers/models.d.ts +1 -2
  165. package/dist/plus/integrations/providers/models.js +9 -2
  166. package/dist/plus/integrations/providers/models.js.map +1 -1
  167. package/dist/plus/integrations/providers/providersApi.d.ts +7 -17
  168. package/dist/plus/integrations/providers/providersApi.js +85 -78
  169. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  170. package/dist/plus/integrations/providers/utils/jiraIssueDrains.d.ts +22 -0
  171. package/dist/plus/integrations/providers/utils/jiraIssueDrains.js +69 -9
  172. package/dist/plus/integrations/providers/utils/jiraIssueDrains.js.map +1 -1
  173. package/dist/plus/integrations/providers/utils/providerPaging.js +8 -2
  174. package/dist/plus/integrations/providers/utils/providerPaging.js.map +1 -1
  175. package/dist/plus/integrations/reads/filters.d.ts +3 -3
  176. package/dist/plus/integrations/reads/filters.js.map +1 -1
  177. package/dist/plus/integrations/reads/issueBatch.d.ts +2 -1
  178. package/dist/plus/integrations/reads/issueBatch.js +1 -1
  179. package/dist/plus/integrations/reads/issueBatch.js.map +1 -1
  180. package/dist/plus/integrations/reads/issueTracker.js +23 -14
  181. package/dist/plus/integrations/reads/issueTracker.js.map +1 -1
  182. package/dist/plus/integrations/reads/issues.d.ts +2 -1
  183. package/dist/plus/integrations/reads/issues.js +18 -3
  184. package/dist/plus/integrations/reads/issues.js.map +1 -1
  185. package/dist/plus/integrations/reads/pullRequestBatch.js +1 -1
  186. package/dist/plus/integrations/reads/resolveRepository.js +12 -3
  187. package/dist/plus/integrations/reads/resolveRepository.js.map +1 -1
  188. package/dist/plus/integrations/reads/warnings.d.ts +11 -4
  189. package/dist/plus/integrations/reads/warnings.js +15 -5
  190. package/dist/plus/integrations/reads/warnings.js.map +1 -1
  191. package/dist/plus/integrations/results.d.ts +36 -2
  192. package/dist/plus/integrations/results.js +33 -13
  193. package/dist/plus/integrations/results.js.map +1 -1
  194. package/dist/utils/promiseCache.d.ts +10 -0
  195. package/dist/utils/promiseCache.js +17 -2
  196. package/dist/utils/promiseCache.js.map +1 -1
  197. package/docs/integrations.md +52 -20
  198. package/package.json +2 -2
@@ -11,12 +11,12 @@ import { isRevisionRange, isSha, isUncommitted, isUncommittedStaged } from "../.
11
11
  import __decorate from "../../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
12
12
  import { SigningError } from "../../git/errors.js";
13
13
  import { GitErrors, classifySigningError, gitConfigsLog, gitConfigsLogWithFiles } from "../exec/git.js";
14
+ import { maybeStopWatch } from "../../utils/stopwatch.js";
15
+ import _usingCtx from "../../_virtual/@oxc-project+runtime/helpers/esm/usingCtx.js";
14
16
  import { GitFileChange } from "../../git/models/fileChange.js";
15
17
  import { createUncommittedChangesCommit } from "../../git/utils/commit.utils.js";
16
18
  import { GitCommit, GitCommitIdentity } from "../../git/models/commit.js";
17
19
  import { isUserMatch } from "../../git/utils/user.utils.js";
18
- import { maybeStopWatch } from "../../utils/stopwatch.js";
19
- import _usingCtx from "../../_virtual/@oxc-project+runtime/helpers/esm/usingCtx.js";
20
20
  import { compareReachableRefs } from "../../git/utils/sorting.js";
21
21
  import { parseSearchQueryGitCommand } from "../../git/utils/search.utils.js";
22
22
  import { getCommitsLogParser, getShaAndDatesLogParser, getShaAndFilesAndStatsLogParser, getShaLogParser } from "../parsers/logParser.js";
@@ -48,11 +48,14 @@ export declare class ConfigGitSubProvider implements GitConfigSubProvider {
48
48
  */
49
49
  private readonly _gkConfigReconciles;
50
50
  /**
51
- * Pending `setGkConfig` writes keyed by `(commonPath, key, value, skip-option)`. Concurrent
52
- * callers writing the same `(key, value)` pair share the in-flight Promise so only one
53
- * `git config --set` subprocess actually runs. Cleared on settle.
51
+ * The latest pending `setGkConfig` write of each `commonPath\0key`. A call writing the same value with the same
52
+ * skip option joins it; any other call chains after it, so one key's writes land in call order. Cleared on settle.
54
53
  */
55
54
  private readonly _pendingGkConfigWrites;
55
+ /** Maps from failed bulk reads, which a reconcile must not diff as the file's content */
56
+ private readonly _failedGkConfigMaps;
57
+ /** Writes each `.git/gk/config` one at a time — concurrent `git config` writes fail on its lock */
58
+ private readonly _gkConfigWrites;
56
59
  getConfig(repoPath: string | undefined, key: GitConfigKeys, options?: {
57
60
  global?: boolean;
58
61
  runGitLocally?: boolean;
@@ -103,14 +106,15 @@ export declare class ConfigGitSubProvider implements GitConfigSubProvider {
103
106
  * The worst case is metadata that stays behind until the next op on that name.
104
107
  *
105
108
  * Returns whether `.git/gk/config` now reflects the command (it ran, or there was nothing to do), so the
106
- * caller can record its own write in the merge-key snapshot only when it actually landed.
109
+ * caller can record its own write in the reconcile snapshot only when it actually landed.
107
110
  */
108
111
  private runGkConfigSectionCommand;
109
112
  /**
110
113
  * Reconciles a watcher-observed `'gkConfig'` change — registered with the shared `Cache` as its
111
114
  * gk-config reconciler (see the constructor). Re-reads the bulk map (hard-evicted by
112
115
  * `Cache.handleGkConfigChanged`, so this hits disk) and diffs it against `priorSnapshot` to cascade
113
- * `baseBranchName`/`branchOverviews` only for refs whose merge-relevant keys actually changed.
116
+ * `baseBranchName`/`branchOverviews` only for refs whose merge-relevant keys actually changed, and to evict the
117
+ * branches only when a branch metadata key (another process's activity stamp) changed.
114
118
  *
115
119
  * Serialized per commonPath: a reconcile is a read-then-diff against a single shared baseline, so
116
120
  * two overlapping passes would both diff against the same snapshot and the later change could fall
@@ -4,9 +4,11 @@ import { getScopedLogger } from "../../utils/logger.scoped.js";
4
4
  import { debug, trace } from "../../utils/decorators/log.js";
5
5
  import { fileUri } from "../../utils/uri.js";
6
6
  import { dirname, getBestPath, isAbsolute, joinPaths, normalizePath } from "../../utils/path.js";
7
+ import { parseBranchMetadataGkConfigKey } from "../../git/utils/branch.utils.js";
7
8
  import __decorate from "../../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
8
9
  import { WorkspaceUntrustedError } from "../../git/errors.js";
9
10
  import { fsExists } from "../../utils/env/node/exec.js";
11
+ import { KeyedSequencer } from "../exec/indexLock.js";
10
12
  import { gate } from "../../utils/decorators/gate.js";
11
13
  import { promises } from "fs";
12
14
  import { env } from "process";
@@ -87,11 +89,14 @@ var ConfigGitSubProvider = class {
87
89
  */
88
90
  _gkConfigReconciles = /* @__PURE__ */ new Map();
89
91
  /**
90
- * Pending `setGkConfig` writes keyed by `(commonPath, key, value, skip-option)`. Concurrent
91
- * callers writing the same `(key, value)` pair share the in-flight Promise so only one
92
- * `git config --set` subprocess actually runs. Cleared on settle.
92
+ * The latest pending `setGkConfig` write of each `commonPath\0key`. A call writing the same value with the same
93
+ * skip option joins it; any other call chains after it, so one key's writes land in call order. Cleared on settle.
93
94
  */
94
95
  _pendingGkConfigWrites = /* @__PURE__ */ new Map();
96
+ /** Maps from failed bulk reads, which a reconcile must not diff as the file's content */
97
+ _failedGkConfigMaps = /* @__PURE__ */ new WeakSet();
98
+ /** Writes each `.git/gk/config` one at a time — concurrent `git config` writes fail on its lock */
99
+ _gkConfigWrites = new KeyedSequencer();
95
100
  getConfig(repoPath, key, options) {
96
101
  const global = options?.global || repoPath == null;
97
102
  return this.cache.getConfig(global ? void 0 : repoPath, key, () => this.getConfigCore(repoPath, key, options));
@@ -126,6 +131,7 @@ var ConfigGitSubProvider = class {
126
131
  async setConfig(repoPath, key, value, options) {
127
132
  await this.setConfigCore(repoPath, key, value, options);
128
133
  if (repoPath != null && !options?.file && /^branch\..+\.(?:remote|merge)$/i.test(key)) this.context.hooks?.cache?.onReset?.(repoPath, "branches");
134
+ if (repoPath != null && !options?.file && !options?.global) this.context.hooks?.repository?.onChanged?.(repoPath, ["config"]);
129
135
  }
130
136
  async setConfigCore(repoPath, key, value, options) {
131
137
  const args = ["config"];
@@ -246,7 +252,10 @@ var ConfigGitSubProvider = class {
246
252
  await this.migrateGkConfigFromGitConfig(this.cache.getCommonPath(repoPath));
247
253
  return this.cache.getGkConfigMap(repoPath, async (cacheable) => {
248
254
  const { map, failed } = await this.getGkConfigRegexCore(repoPath, gkConfigAllPattern);
249
- if (failed) cacheable.invalidate();
255
+ if (failed) {
256
+ cacheable.invalidate();
257
+ this._failedGkConfigMaps.add(map);
258
+ }
250
259
  return map;
251
260
  });
252
261
  }
@@ -270,12 +279,19 @@ var ConfigGitSubProvider = class {
270
279
  async setGkConfig(repoPath, key, value, options) {
271
280
  const commonPath = this.cache.getCommonPath(repoPath);
272
281
  const skipKey = options?.skipInvalidation?.length ? options.skipInvalidation.toSorted().join(",") : "";
273
- const dedupKey = `${commonPath}\0${key}\0${value ?? ""}\0${skipKey}`;
274
- const pending = this._pendingGkConfigWrites.get(dedupKey);
275
- if (pending != null) return pending;
276
- const promise = this.setGkConfigCore(repoPath, key, value, options);
277
- this._pendingGkConfigWrites.set(dedupKey, promise);
278
- promise.finally(() => this._pendingGkConfigWrites.delete(dedupKey)).catch(() => {});
282
+ const pendingKey = `${commonPath}\0${key}`;
283
+ const previous = this._pendingGkConfigWrites.get(pendingKey);
284
+ if (previous != null && previous.value === value && previous.skipKey === skipKey) return previous.promise;
285
+ const promise = previous != null ? previous.promise.catch(() => {}).then(() => this.setGkConfigCore(repoPath, key, value, options)) : this.setGkConfigCore(repoPath, key, value, options);
286
+ const pending = {
287
+ value,
288
+ skipKey,
289
+ promise
290
+ };
291
+ this._pendingGkConfigWrites.set(pendingKey, pending);
292
+ promise.finally(() => {
293
+ if (this._pendingGkConfigWrites.get(pendingKey) === pending) this._pendingGkConfigWrites.delete(pendingKey);
294
+ }).catch(() => {});
279
295
  return promise;
280
296
  }
281
297
  async setGkConfigCore(repoPath, key, value, options) {
@@ -284,9 +300,16 @@ var ConfigGitSubProvider = class {
284
300
  if (!gkConfigPath) return;
285
301
  const gkConfigFolder = joinPaths(gkConfigPath, "..");
286
302
  if (!await this.ensureGkConfigFolder(gkConfigFolder, scope)) return;
287
- await this.setConfigCore(repoPath, key, value, { file: gkConfigPath });
303
+ if (this.cache.needsGkConfigSnapshot(repoPath, key)) await this.getGkConfigMap(repoPath);
304
+ await this._gkConfigWrites.run(gkConfigPath, void 0, () => this.setConfigCore(repoPath, key, value, { file: gkConfigPath }));
288
305
  this.cache.deleteGkConfig(repoPath, key, options);
289
- this.cache.recordGkConfigWrite(repoPath, key, value);
306
+ this.cache.recordGkConfigWrite(repoPath, key, value, { announce: options?.skipInvalidation == null });
307
+ const metadataKey = parseBranchMetadataGkConfigKey(key);
308
+ if (metadataKey != null) this.cache.patchBranchMetadata(repoPath, [{
309
+ branch: metadataKey.branch,
310
+ key: metadataKey.key,
311
+ value
312
+ }]);
290
313
  }
291
314
  async removeGkConfigBranchSection(repoPath, ref) {
292
315
  if (await this.runGkConfigSectionCommand(repoPath, ref, "--remove-section", `branch.${ref}`)) this.cache.recordGkConfigSectionWrite(repoPath, ref);
@@ -305,7 +328,7 @@ var ConfigGitSubProvider = class {
305
328
  * The worst case is metadata that stays behind until the next op on that name.
306
329
  *
307
330
  * Returns whether `.git/gk/config` now reflects the command (it ran, or there was nothing to do), so the
308
- * caller can record its own write in the merge-key snapshot only when it actually landed.
331
+ * caller can record its own write in the reconcile snapshot only when it actually landed.
309
332
  */
310
333
  async runGkConfigSectionCommand(repoPath, ref, ...args) {
311
334
  const scope = getScopedLogger();
@@ -316,11 +339,11 @@ var ConfigGitSubProvider = class {
316
339
  const gkConfigPath = await this.getGkConfigPath(repoPath);
317
340
  if (!gkConfigPath) return false;
318
341
  if (!await fsExists(gkConfigPath)) return true;
319
- const result = await this.git.run({
342
+ const result = await this._gkConfigWrites.run(gkConfigPath, void 0, () => this.git.run({
320
343
  cwd: repoPath,
321
344
  runLocally: true,
322
345
  errors: "ignore"
323
- }, "config", "-f", gkConfigPath, ...args);
346
+ }, "config", "-f", gkConfigPath, ...args));
324
347
  const succeeded = result.completion.status === "exited" && result.exitCode === 0;
325
348
  if (!succeeded) scope?.warn(`Failed to update gk config section for '${ref}' in '${repoPath}': ${result.completion.status === "exited" ? `git config exited ${result.exitCode}` : `${result.completion.status} · ${result.completion.error.message}`}`);
326
349
  this.cache.deleteGkConfigMap(repoPath);
@@ -334,7 +357,8 @@ var ConfigGitSubProvider = class {
334
357
  * Reconciles a watcher-observed `'gkConfig'` change — registered with the shared `Cache` as its
335
358
  * gk-config reconciler (see the constructor). Re-reads the bulk map (hard-evicted by
336
359
  * `Cache.handleGkConfigChanged`, so this hits disk) and diffs it against `priorSnapshot` to cascade
337
- * `baseBranchName`/`branchOverviews` only for refs whose merge-relevant keys actually changed.
360
+ * `baseBranchName`/`branchOverviews` only for refs whose merge-relevant keys actually changed, and to evict the
361
+ * branches only when a branch metadata key (another process's activity stamp) changed.
338
362
  *
339
363
  * Serialized per commonPath: a reconcile is a read-then-diff against a single shared baseline, so
340
364
  * two overlapping passes would both diff against the same snapshot and the later change could fall
@@ -379,9 +403,10 @@ var ConfigGitSubProvider = class {
379
403
  if (readPath == null) return "reconciled";
380
404
  this.cache.deleteGkConfigMap(readPath);
381
405
  const freshMap = await this.getGkConfigMap(readPath);
406
+ if (this._failedGkConfigMaps.has(freshMap)) throw new Error(`Failed to read the gk config through '${readPath}'`);
382
407
  if (!this.pruneClosedReconcilePaths(entry.paths).size) return "reconciled";
383
- if (this.cache.reconcileGkConfigMap(readPath, snapshot, freshMap)) for (const path of entry.paths.keys()) this.context.hooks?.repository?.onChanged?.(path, ["gkConfig"]);
384
- snapshot = this.cache.getGkConfigMergeSnapshot(readPath);
408
+ if (this.cache.reconcileGkConfigMap(readPath, snapshot, freshMap)) for (const path of entry.paths.keys()) this.provider.notifyHost(path, ["gkConfig"]);
409
+ snapshot = this.cache.getGkConfigSnapshot(readPath);
385
410
  } while (entry.pending);
386
411
  return "reconciled";
387
412
  } catch (ex) {
@@ -417,16 +442,24 @@ var ConfigGitSubProvider = class {
417
442
  }
418
443
  async setSigningConfig(repoPath, config, options) {
419
444
  const scope = getScopedLogger();
445
+ const entries = [];
446
+ if (config.enabled != null) entries.push(["commit.gpgsign", config.enabled ? "true" : "false"]);
447
+ if (config.format != null) entries.push(["gpg.format", config.format]);
448
+ if (config.signingKey != null) entries.push(["user.signingkey", config.signingKey]);
449
+ if (config.gpgProgram != null) entries.push(["gpg.program", config.gpgProgram]);
450
+ if (config.sshProgram != null) entries.push(["gpg.ssh.program", config.sshProgram]);
451
+ if (config.allowedSignersFile != null) entries.push(["gpg.ssh.allowedSignersFile", config.allowedSignersFile]);
452
+ let wrote = false;
420
453
  try {
421
- if (config.enabled != null) await this.setConfig(repoPath, "commit.gpgsign", config.enabled ? "true" : "false", options);
422
- if (config.format != null) await this.setConfig(repoPath, "gpg.format", config.format, options);
423
- if (config.signingKey != null) await this.setConfig(repoPath, "user.signingkey", config.signingKey, options);
424
- if (config.gpgProgram != null) await this.setConfig(repoPath, "gpg.program", config.gpgProgram, options);
425
- if (config.sshProgram != null) await this.setConfig(repoPath, "gpg.ssh.program", config.sshProgram, options);
426
- if (config.allowedSignersFile != null) await this.setConfig(repoPath, "gpg.ssh.allowedSignersFile", config.allowedSignersFile, options);
454
+ for (const [key, value] of entries) {
455
+ await this.setConfigCore(repoPath, key, value, options);
456
+ wrote = true;
457
+ }
427
458
  } catch (ex) {
428
459
  scope?.error(ex);
429
460
  throw ex;
461
+ } finally {
462
+ if (wrote && !options?.global) this.context.hooks?.repository?.onChanged?.(repoPath, ["config"]);
430
463
  }
431
464
  }
432
465
  getSigningConfigFlags(config) {
@@ -591,7 +624,7 @@ var ConfigGitSubProvider = class {
591
624
  }
592
625
  scope?.info(`Migrating ${String(migrateConfig.size)} GK config entries from git config to .git/gk/config`);
593
626
  for (const [key, value] of [...migrateConfig]) try {
594
- await this.setConfigCore(repoPath, key, value, { file: gkConfigPath });
627
+ await this._gkConfigWrites.run(gkConfigPath, void 0, () => this.setConfigCore(repoPath, key, value, { file: gkConfigPath }));
595
628
  } catch (ex) {
596
629
  scope?.error(ex, `Failed to migrate key '${key}' to GK config`);
597
630
  migrateConfig.delete(key);
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":["process_env","fs"],"sources":["../../../../git-cli/src/providers/config.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport { hostname, userInfo } from 'os';\nimport { env as process_env } from 'process';\nimport type { Cache, GkConfigInvalidationTarget, GkReconcileOutcome } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport { WorkspaceUntrustedError } from '@gitlens/git/errors.js';\nimport type { GitDir } from '@gitlens/git/models/repository.js';\nimport type { SigningConfig, SigningFormat, ValidationResult } from '@gitlens/git/models/signature.js';\nimport type { GitUser } from '@gitlens/git/models/user.js';\nimport type {\n\tDeprecatedGkConfigKeys,\n\tGitConfigKeys,\n\tGitConfigSubProvider,\n\tGitConfigType,\n\tGkConfigKeys,\n} from '@gitlens/git/providers/config.js';\nimport { gate } from '@gitlens/utils/decorators/gate.js';\nimport { debug, trace } from '@gitlens/utils/decorators/log.js';\nimport { first, some } from '@gitlens/utils/iterable.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { dirname, getBestPath, isAbsolute, joinPaths, normalizePath } from '@gitlens/utils/path.js';\nimport { fileUri } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport { fsExists } from '../exec/exec.js';\nimport type { Git } from '../exec/git.js';\n\nconst mappedAuthorRegex = /(.+)\\s<(.+)>/;\nconst emptyArray: readonly never[] = Object.freeze([]);\n\n/** Catch-all pattern matching every key in `.git/gk/config` for the one-shot bulk read. */\nconst gkConfigAllPattern = '.';\n\n/**\n * Canonicalizes a git config key for lookup against `--get-regexp` output, which git emits with the\n * section and variable-name lowercased and only the subsection case-preserved. Without this a\n * subsection-less key like `gk.defaultRemote` would miss the lowercased `gk.defaultremote` in the map.\n */\nexport function canonicalizeGitConfigKey(key: string): string {\n\tconst first = key.indexOf('.');\n\tif (first === -1) return key.toLowerCase();\n\n\tconst last = key.lastIndexOf('.');\n\t// `section.name` (no subsection) → fully lowercased; `section.subsection.name` → lowercase\n\t// section + name, preserve the case-sensitive subsection in the middle.\n\tif (first === last) return key.toLowerCase();\n\treturn `${key.slice(0, first).toLowerCase()}${key.slice(first, last)}${key.slice(last).toLowerCase()}`;\n}\n\n/**\n * Parses git config --get-regex output into a Map.\n * The output format is \"key value\" per line, where key and value are space-separated.\n *\n * A line with NO space at all is git's rendering of a bareword/valueless entry (`key`, no `=`) — git's\n * OWN config parser reads that as boolean TRUE (git-config(1): \"a variable defined without `= <value>`\n * is taken as true\"), confirmed against git's `format_config` (builtin/config.c): the key-delimiter is\n * appended unconditionally, then backed out ONLY when the stored value is NULL (the bareword case) —\n * an explicit empty value (`key =`) is a real, non-NULL empty string, so its line KEEPS the trailing\n * space and is already handled by the branch below, byte-distinct from a bareword line.\n *\n * By default a bareword line is skipped (the historical behavior, which reads as \"unset\" — wrong, but\n * safe); pass `includeValueless` to map it to the literal string `'true'` instead, so `parseGitBoolean`\n * and callers checking `.has()` for \"configured\" both read it correctly.\n */\nexport function parseConfigRegexOutput(\n\tdata: string | undefined,\n\toptions?: { includeValueless?: boolean },\n): Map<string, string> {\n\tconst configMap = new Map<string, string>();\n\tif (!data) return configMap;\n\n\tfor (const line of data.split('\\n')) {\n\t\tif (!line) continue;\n\n\t\tconst spaceIndex = line.indexOf(' ');\n\t\tif (spaceIndex === -1) {\n\t\t\tif (options?.includeValueless) {\n\t\t\t\tconfigMap.set(line, 'true');\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tconfigMap.set(line.substring(0, spaceIndex), line.substring(spaceIndex + 1));\n\t}\n\n\treturn configMap;\n}\n\nexport function parseGitBoolean(value: string | undefined): boolean {\n\tif (value == null) return false;\n\n\tconst normalized = value.toLowerCase().trim();\n\treturn normalized === 'true' || normalized === 'yes' || normalized === 'on' || normalized === '1';\n}\n\n/** Whether a git config value spells boolean-false (`false`/`no`/`off`/`0`/empty), per git's maybe-bool parsing. */\nexport function isGitBooleanFalse(value: string): boolean {\n\tconst normalized = value.toLowerCase().trim();\n\treturn (\n\t\tnormalized === '' || normalized === 'false' || normalized === 'no' || normalized === 'off' || normalized === '0'\n\t);\n}\n\nexport class ConfigGitSubProvider implements GitConfigSubProvider {\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\t\tthis.cache.setGkConfigReconciler((repoPath, priorSnapshot) => this.reconcileGkConfig(repoPath, priorSnapshot));\n\t}\n\n\t/**\n\t * In-flight gk-config reconciles keyed by commonPath. `pending` records that another `'gkConfig'`\n\t * event landed mid-pass, so one trailing pass runs after the current one settles. `paths` holds every\n\t * worktree path that reported the change, mapped to its close generation at that moment — the pass\n\t * reads through one that's still open and notifies all of them.\n\t */\n\tprivate readonly _gkConfigReconciles = new Map<string, { pending: boolean; paths: Map<string, number> }>();\n\n\t/**\n\t * Pending `setGkConfig` writes keyed by `(commonPath, key, value, skip-option)`. Concurrent\n\t * callers writing the same `(key, value)` pair share the in-flight Promise so only one\n\t * `git config --set` subprocess actually runs. Cleared on settle.\n\t */\n\tprivate readonly _pendingGkConfigWrites = new Map<string, Promise<void>>();\n\n\t@trace()\n\tgetConfig(\n\t\trepoPath: string | undefined,\n\t\tkey: GitConfigKeys,\n\t\toptions?: { global?: boolean; runGitLocally?: boolean; type?: GitConfigType },\n\t): Promise<string | undefined> {\n\t\tconst global = options?.global || repoPath == null;\n\t\treturn this.cache.getConfig(global ? undefined : repoPath, key, () =>\n\t\t\tthis.getConfigCore(repoPath, key, options),\n\t\t);\n\t}\n\n\tprivate async getConfigCore(\n\t\trepoPath: string | undefined,\n\t\tkey: string,\n\t\toptions?: { file?: string; global?: boolean; runGitLocally?: boolean; type?: GitConfigType },\n\t): Promise<string | undefined> {\n\t\tconst args = ['config', '--get'];\n\t\tif (options?.file) {\n\t\t\targs.push('-f', options.file);\n\t\t} else if (options?.global || repoPath == null) {\n\t\t\targs.push('--global');\n\t\t}\n\t\tif (options?.type) {\n\t\t\targs.push(`--type=${options.type}`);\n\t\t}\n\t\targs.push(key);\n\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath ?? '', errors: 'ignore', runLocally: options?.runGitLocally },\n\t\t\t...args,\n\t\t);\n\t\treturn result.stdout.trim() || undefined;\n\t}\n\n\t@trace()\n\tgetConfigRegex(\n\t\trepoPath: string | undefined,\n\t\tpattern: string,\n\t\toptions?: { global?: boolean; runGitLocally?: boolean },\n\t): Promise<Map<string, string>> {\n\t\tconst global = options?.global || repoPath == null;\n\t\treturn this.cache.getConfigRegex(global ? undefined : repoPath, pattern, () =>\n\t\t\tthis.getConfigRegexCore(repoPath, pattern, options),\n\t\t);\n\t}\n\n\tprivate async getConfigRegexCore(\n\t\trepoPath: string | undefined,\n\t\tpattern: string,\n\t\toptions?: { file?: string; global?: boolean; runGitLocally?: boolean },\n\t): Promise<Map<string, string>> {\n\t\tconst args = ['config', '--get-regex'];\n\t\tif (options?.file) {\n\t\t\targs.push('-f', options.file);\n\t\t} else if (options?.global || repoPath == null) {\n\t\t\targs.push('--global');\n\t\t}\n\t\targs.push(pattern);\n\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath ?? '', errors: 'ignore', runLocally: options?.runGitLocally },\n\t\t\t...args,\n\t\t);\n\t\t// Deliberately NOT `.trim()`-ed: an explicit-empty value's LAST line ends in a meaningful trailing\n\t\t// space, and `.trim()`-ing the whole (possibly multi-line) buffer strips it — `parseConfigRegexOutput`\n\t\t// already skips the blank line a trailing newline produces, so no trim is needed.\n\t\treturn parseConfigRegexOutput(result.stdout);\n\t}\n\n\t@debug()\n\tasync setConfig(\n\t\trepoPath: string | undefined,\n\t\tkey: GitConfigKeys,\n\t\tvalue: string | undefined,\n\t\toptions?: { file?: string; global?: boolean },\n\t): Promise<void> {\n\t\tawait this.setConfigCore(repoPath, key, value, options);\n\n\t\t// A branch's upstream (`remote`/`merge`) is read back through the cached branch list, which a\n\t\t// `'config'` reset alone leaves serving the old tracking info.\n\t\tif (repoPath != null && !options?.file && /^branch\\..+\\.(?:remote|merge)$/i.test(key)) {\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t}\n\t}\n\n\tprivate async setConfigCore(\n\t\trepoPath: string | undefined,\n\t\tkey: string,\n\t\tvalue: string | undefined,\n\t\toptions?: { file?: string; global?: boolean },\n\t): Promise<void> {\n\t\tconst args: string[] = ['config'];\n\n\t\tif (options?.file) {\n\t\t\targs.push('-f', options.file);\n\t\t} else {\n\t\t\tconst global = options?.global || repoPath == null;\n\t\t\targs.push(global ? '--global' : '--local');\n\t\t}\n\n\t\tif (value == null) {\n\t\t\targs.push('--unset', key);\n\t\t} else {\n\t\t\targs.push(key, value);\n\t\t}\n\n\t\tawait this.git.run({ cwd: repoPath ?? '', runLocally: true }, ...args);\n\n\t\t// Only invalidate cache when not using a custom file (custom files aren't cached)\n\t\tif (!options?.file) {\n\t\t\tconst global = options?.global || repoPath == null;\n\t\t\t// Invalidate the cached value for this key and clear all regex patterns for this scope\n\t\t\tthis.cache.deleteConfig(global ? undefined : repoPath, key);\n\t\t}\n\t}\n\n\t@gate()\n\t@debug()\n\tasync getCurrentUser(repoPath: string): Promise<GitUser | undefined> {\n\t\tif (!repoPath) return undefined;\n\n\t\tconst scope = getScopedLogger();\n\n\t\tconst cached = this.cache.currentUser.get(repoPath);\n\t\tif (cached != null) return cached;\n\t\t// If we found null, user data was not found - don't bother trying again\n\t\tif (cached === null) return undefined;\n\n\t\tconst user: GitUser = { name: undefined, email: undefined };\n\n\t\ttry {\n\t\t\tconst configMap = await this.getConfigRegex(repoPath, '^user\\\\.(name|email)$', {\n\t\t\t\trunGitLocally: true,\n\t\t\t});\n\t\t\tif (configMap.size) {\n\t\t\t\tuser.name = configMap.get('user.name');\n\t\t\t\tuser.email = configMap.get('user.email');\n\t\t\t} else {\n\t\t\t\tuser.name =\n\t\t\t\t\tprocess_env.GIT_AUTHOR_NAME || process_env.GIT_COMMITTER_NAME || userInfo()?.username || undefined;\n\t\t\t\tif (!user.name) {\n\t\t\t\t\t// If we found no user data, mark it so we won't bother trying again\n\t\t\t\t\tthis.cache.currentUser.set(repoPath, null);\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tuser.email =\n\t\t\t\t\tprocess_env.GIT_AUTHOR_EMAIL ||\n\t\t\t\t\tprocess_env.GIT_COMMITTER_EMAIL ||\n\t\t\t\t\tprocess_env.EMAIL ||\n\t\t\t\t\t`${user.name}@${hostname()}`;\n\t\t\t}\n\n\t\t\tconst author = `${user.name} <${user.email}>`;\n\t\t\t// Check if there is a mailmap for the current user\n\t\t\tconst result = await this.git.run({ cwd: repoPath, errors: 'ignore' }, 'check-mailmap', author);\n\n\t\t\tif (result.stdout && result.stdout !== author) {\n\t\t\t\tconst match = mappedAuthorRegex.exec(result.stdout);\n\t\t\t\tif (match != null) {\n\t\t\t\t\t[, user.name, user.email] = match;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.cache.currentUser.set(repoPath, user);\n\t\t\treturn user;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\n\t\t\t// Mark it so we won't bother trying again\n\t\t\tthis.cache.currentUser.set(repoPath, null);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@gate()\n\t@trace({ exit: r => `returned ${r}` })\n\tasync getDefaultWorktreePath(repoPath: string): Promise<string | undefined> {\n\t\tconst gitDir = await this.getGitDir(repoPath);\n\t\tif (gitDir == null) return undefined;\n\n\t\tconst basePath = (gitDir.commonUri ?? gitDir.uri).fsPath;\n\t\treturn getBestPath(normalizePath(joinPaths(basePath, '..')));\n\t}\n\n\t@gate()\n\t@trace({\n\t\texit: r =>\n\t\t\t`returned ${r.uri.toString(true)}, commonUri=${r.commonUri?.toString(true)}, parentUri=${r.parentUri?.toString(true)}`,\n\t})\n\tasync getGitDir(repoPath: string): Promise<GitDir> {\n\t\tconst cached = this.cache.gitDir.get(repoPath);\n\t\tif (cached != null) return cached;\n\n\t\tconst scope = getScopedLogger();\n\t\tconst repoInfo = await this.getRepositoryInfo(repoPath);\n\n\t\tlet gitDir: GitDir;\n\t\tif (!Array.isArray(repoInfo) && repoInfo != null) {\n\t\t\tgitDir = {\n\t\t\t\turi: fileUri(repoInfo.gitDir),\n\t\t\t\tcommonUri: repoInfo.commonGitDir ? fileUri(repoInfo.commonGitDir) : undefined,\n\t\t\t\tparentUri: repoInfo.superprojectPath ? fileUri(repoInfo.superprojectPath) : undefined,\n\t\t\t};\n\t\t} else {\n\t\t\tgitDir = {\n\t\t\t\turi: this.provider.getAbsoluteUri(joinPaths(repoPath, '.git'), repoPath),\n\t\t\t};\n\n\t\t\tconst gitDirPath = gitDir.uri.toString(true);\n\t\t\tscope?.warn(`rev-parse failed for '${repoPath}'; falling back to '${gitDirPath}'`);\n\t\t\tthis.context.hooks?.operations?.onGitDirResolveFailed?.(\n\t\t\t\trepoPath,\n\t\t\t\tgitDirPath,\n\t\t\t\t`rev_parse returned ${JSON.stringify(repoInfo)}`,\n\t\t\t);\n\t\t}\n\t\tthis.cache.gitDir.set(repoPath, gitDir);\n\n\t\treturn gitDir;\n\t}\n\n\t/**\n\t * Gets the path to the .git/gk/config file for storing GitKraken-specific metadata.\n\t * Uses commonPath for worktrees so all worktrees share the same data.\n\t */\n\tprivate async getGkConfigPath(repoPath: string): Promise<string | undefined> {\n\t\tconst gitDir = await this.getGitDir(repoPath);\n\t\tif (gitDir == null) return undefined;\n\n\t\t// Use commonUri (main .git dir) for worktrees, otherwise use uri\n\t\tconst basePath = (gitDir.commonUri ?? gitDir.uri).fsPath;\n\t\treturn joinPaths(basePath, 'gk', 'config');\n\t}\n\n\t@debug()\n\tasync getGkConfig(repoPath: string, key: GkConfigKeys | DeprecatedGkConfigKeys): Promise<string | undefined> {\n\t\t// Served in-memory from a single bulk read of the whole `.git/gk/config` (no gk read needs `--type`).\n\t\t// Canonicalize the key the way git does for `--get-regexp` output so subsection-less keys\n\t\t// (e.g. `gk.defaultRemote`) match, and coerce an empty value to undefined to match the old\n\t\t// `git config --get` (`.trim() || undefined`) contract.\n\t\treturn (await this.getGkConfigMap(repoPath)).get(canonicalizeGitConfigKey(key)) || undefined;\n\t}\n\n\t@debug()\n\tasync getGkConfigRegex(repoPath: string, pattern: string): Promise<Map<string, string>> {\n\t\tconst all = await this.getGkConfigMap(repoPath);\n\n\t\t// Filter the bulk map in-memory. The old path passed `pattern` to `git config --get-regex`\n\t\t// (errors ignored → empty result on a bad pattern); preserve that no-throw contract here\n\t\t// rather than letting an invalid-JS pattern reject the read.\n\t\tlet re: RegExp;\n\t\ttry {\n\t\t\tre = new RegExp(pattern);\n\t\t} catch {\n\t\t\treturn new Map();\n\t\t}\n\n\t\tconst result = new Map<string, string>();\n\t\tfor (const [k, v] of all) {\n\t\t\tif (re.test(k)) {\n\t\t\t\tresult.set(k, v);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Reads the entire `.git/gk/config` in one `git config --get-regexp` and caches the parsed map\n\t * per commonPath. Per-key (getGkConfig) and per-namespace (getGkConfigRegex) lookups are served\n\t * from this single cached read — so a branch-overview render that fans out across several gk\n\t * namespaces costs one `git config` call instead of one per namespace.\n\t */\n\tprivate async getGkConfigMap(repoPath: string): Promise<Map<string, string>> {\n\t\t// Migrate BEFORE populating the cache, not inside the factory: a first-time migration calls\n\t\t// clearCaches('gkConfig'), which would otherwise evict the in-flight gkConfigMap entry the\n\t\t// cache wrapper synchronously stored and force a redundant bulk re-read.\n\t\tawait this.migrateGkConfigFromGitConfig(this.cache.getCommonPath(repoPath));\n\t\treturn this.cache.getGkConfigMap(repoPath, async cacheable => {\n\t\t\tconst { map, failed } = await this.getGkConfigRegexCore(repoPath, gkConfigAllPattern);\n\t\t\t// This map has no TTL and everything gk-related reads through it, so a failed read cached as an\n\t\t\t// empty map would report every branch as having no stored base or merge target for the session —\n\t\t\t// and would make the section-cleanup pre-checks skip real work. Only cache a read that happened.\n\t\t\tif (failed) {\n\t\t\t\tcacheable.invalidate();\n\t\t\t}\n\t\t\treturn map;\n\t\t});\n\t}\n\n\tprivate async getGkConfigRegexCore(\n\t\trepoPath: string,\n\t\tpattern: string,\n\t): Promise<{ map: Map<string, string>; failed: boolean }> {\n\t\tconst gkConfigPath = await this.getGkConfigPath(repoPath);\n\t\t// No `.git/gk/config` yet is a real answer, not a failure — a repo GitLens has never written to.\n\t\tif (!gkConfigPath) return { map: new Map(), failed: false };\n\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath, errors: 'ignore', runLocally: true },\n\t\t\t'config',\n\t\t\t'--get-regex',\n\t\t\t'-f',\n\t\t\tgkConfigPath,\n\t\t\tpattern,\n\t\t);\n\t\t// `--get-regex` exits 1 when nothing matches, which IS an answer (an empty gk config).\n\t\tconst exited = result.completion.status === 'exited';\n\t\treturn {\n\t\t\t// Deliberately NOT `.trim()`-ed — see `getConfigRegexCore`'s comment: it strips the trailing\n\t\t\t// space that marks an explicit-empty value's LAST line, silently dropping it from the map.\n\t\t\tmap: parseConfigRegexOutput(result.stdout),\n\t\t\tfailed: !exited || (result.exitCode !== 0 && result.exitCode !== 1),\n\t\t};\n\t}\n\n\t@debug()\n\tasync setGkConfig(\n\t\trepoPath: string,\n\t\tkey: GkConfigKeys | DeprecatedGkConfigKeys,\n\t\tvalue: string | undefined,\n\t\toptions?: { skipInvalidation?: readonly GkConfigInvalidationTarget[] },\n\t): Promise<void> {\n\t\t// Encode the skip-invalidation option in the dedup key: a self-write (with skip targets)\n\t\t// and a user-driven write of the same `(key, value)` (no skip targets) have different\n\t\t// cache-invalidation semantics, so sharing their Promise would silently let the user-driven\n\t\t// write skip invalidation. Sort the array so callers passing the same targets in different\n\t\t// orders share a single in-flight write.\n\t\tconst commonPath = this.cache.getCommonPath(repoPath);\n\t\tconst skipKey = options?.skipInvalidation?.length ? options.skipInvalidation.toSorted().join(',') : '';\n\t\tconst dedupKey = `${commonPath}\\0${key}\\0${value ?? ''}\\0${skipKey}`;\n\n\t\tconst pending = this._pendingGkConfigWrites.get(dedupKey);\n\t\tif (pending != null) return pending;\n\n\t\tconst promise = this.setGkConfigCore(repoPath, key, value, options);\n\t\tthis._pendingGkConfigWrites.set(dedupKey, promise);\n\t\t// Swallow the cleanup chain's rejection so a failed write doesn't surface as an unhandled\n\t\t// rejection separate from the caller's own handling of the returned promise.\n\t\tvoid promise.finally(() => this._pendingGkConfigWrites.delete(dedupKey)).catch(() => {});\n\t\treturn promise;\n\t}\n\n\tprivate async setGkConfigCore(\n\t\trepoPath: string,\n\t\tkey: GkConfigKeys | DeprecatedGkConfigKeys,\n\t\tvalue: string | undefined,\n\t\toptions?: { skipInvalidation?: readonly GkConfigInvalidationTarget[] },\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst gkConfigPath = await this.getGkConfigPath(repoPath);\n\t\tif (!gkConfigPath) return;\n\n\t\tconst gkConfigFolder = joinPaths(gkConfigPath, '..');\n\n\t\tif (!(await this.ensureGkConfigFolder(gkConfigFolder, scope))) return;\n\n\t\tawait this.setConfigCore(repoPath, key, value, { file: gkConfigPath });\n\n\t\t// Invalidate the bulk map (so the next read re-fetches) and the derived caches for this key's\n\t\t// ref. The `.git/gk/config` file-watcher also fires `'gkConfig'` shortly after, which reconciles\n\t\t// the same change (see `reconcileGkConfig`) — recording our own write here keeps that later\n\t\t// reconcile from re-diffing this key as an external change.\n\t\tthis.cache.deleteGkConfig(repoPath, key, options);\n\t\tthis.cache.recordGkConfigWrite(repoPath, key, value);\n\t}\n\n\t@debug()\n\tasync removeGkConfigBranchSection(repoPath: string, ref: string): Promise<void> {\n\t\tif (await this.runGkConfigSectionCommand(repoPath, ref, '--remove-section', `branch.${ref}`)) {\n\t\t\tthis.cache.recordGkConfigSectionWrite(repoPath, ref);\n\t\t}\n\t}\n\n\t@debug()\n\tasync renameGkConfigBranchSection(repoPath: string, oldRef: string, newRef: string): Promise<void> {\n\t\t// Clear the destination first, unconditionally. `--rename-section` onto a section that already\n\t\t// exists APPENDS rather than replaces, leaving duplicate keys — and git resolves a duplicated key\n\t\t// to its LAST value, so the orphan left by an earlier branch of this name would win over the\n\t\t// metadata being moved. Doing this outside `runGkConfigSectionCommand` also covers the case where\n\t\t// the source has no gk keys at all, where its pre-check would otherwise skip the whole call and\n\t\t// leave the orphan in place for the renamed branch to inherit.\n\t\tawait this.removeGkConfigBranchSection(repoPath, newRef);\n\t\tif (\n\t\t\tawait this.runGkConfigSectionCommand(\n\t\t\t\trepoPath,\n\t\t\t\toldRef,\n\t\t\t\t'--rename-section',\n\t\t\t\t`branch.${oldRef}`,\n\t\t\t\t`branch.${newRef}`,\n\t\t\t)\n\t\t) {\n\t\t\tthis.cache.recordGkConfigSectionWrite(repoPath, oldRef, newRef);\n\t\t}\n\t}\n\n\t/**\n\t * Runs a section-level `git config` against `.git/gk/config` for `ref`'s section, skipping the\n\t * subprocess entirely when the bulk map (already cached on any warm path) shows that ref has no gk\n\t * keys — the overwhelmingly common case, since most branches never get gk metadata written at all.\n\t *\n\t * Never throws: callers invoke this as bookkeeping after a branch op has already succeeded, so a\n\t * failure here must not be reported as (or roll back) the branch/checkout/worktree operation itself.\n\t * The worst case is metadata that stays behind until the next op on that name.\n\t *\n\t * Returns whether `.git/gk/config` now reflects the command (it ran, or there was nothing to do), so the\n\t * caller can record its own write in the merge-key snapshot only when it actually landed.\n\t */\n\tprivate async runGkConfigSectionCommand(repoPath: string, ref: string, ...args: string[]): Promise<boolean> {\n\t\tconst scope = getScopedLogger();\n\t\ttry {\n\t\t\tconst prefix = `branch.${ref}.`;\n\t\t\tconst map = await this.getGkConfigMap(repoPath);\n\t\t\t// The shortcut needs a map with CONTENT to be trustworthy. A failed bulk read resolves empty\n\t\t\t// (see `getGkConfigMap`) — the cache refuses it, but this caller still holds it — and an empty map\n\t\t\t// read as authoritative would skip the removal entirely, leaving a deleted branch's base,\n\t\t\t// disposition and issue links behind for the next branch reusing that name. When it's empty, run\n\t\t\t// the command: worst case is a no-op on a section that isn't there.\n\t\t\tif (map.size && !some(map.keys(), k => k.startsWith(prefix))) return true;\n\n\t\t\tconst gkConfigPath = await this.getGkConfigPath(repoPath);\n\t\t\tif (!gkConfigPath) return false;\n\t\t\t// `getGkConfigPath` only joins a path, so check the file: with no `.git/gk/config` there is\n\t\t\t// genuinely nothing to remove, and running the command would fail with a fatal we'd then warn\n\t\t\t// about on every branch delete in a repo that has never had gk metadata.\n\t\t\tif (!(await fsExists(gkConfigPath))) return true;\n\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, runLocally: true, errors: 'ignore' },\n\t\t\t\t'config',\n\t\t\t\t'-f',\n\t\t\t\tgkConfigPath,\n\t\t\t\t...args,\n\t\t\t);\n\t\t\t// `errors: 'ignore'` is deliberate — see the note above on why this must never throw — but that\n\t\t\t// also means the `catch` below never sees a failed write, so without this the metadata silently\n\t\t\t// stays behind (or, on a rename, stays under the old name) with nothing recorded anywhere.\n\t\t\t// Reported, not thrown: the branch op it follows has already succeeded.\n\t\t\tconst succeeded = result.completion.status === 'exited' && result.exitCode === 0;\n\t\t\tif (!succeeded) {\n\t\t\t\tscope?.warn(\n\t\t\t\t\t`Failed to update gk config section for '${ref}' in '${repoPath}': ${\n\t\t\t\t\t\tresult.completion.status === 'exited'\n\t\t\t\t\t\t\t? `git config exited ${result.exitCode}`\n\t\t\t\t\t\t\t: `${result.completion.status} · ${result.completion.error.message}`\n\t\t\t\t\t}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\t// A whole section moved or vanished, which the per-key `deleteGkConfig` cascade can't express.\n\t\t\t// Drop the bulk map so the next read hits disk; the derived caches for the affected ref are\n\t\t\t// evicted by the caller's own `deleteBaseBranchName` plus the `'branches'` cascade it fires.\n\t\t\tthis.cache.deleteGkConfigMap(repoPath);\n\t\t\treturn succeeded;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, `Failed to update gk config section for '${ref}' in '${repoPath}'`);\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Reconciles a watcher-observed `'gkConfig'` change — registered with the shared `Cache` as its\n\t * gk-config reconciler (see the constructor). Re-reads the bulk map (hard-evicted by\n\t * `Cache.handleGkConfigChanged`, so this hits disk) and diffs it against `priorSnapshot` to cascade\n\t * `baseBranchName`/`branchOverviews` only for refs whose merge-relevant keys actually changed.\n\t *\n\t * Serialized per commonPath: a reconcile is a read-then-diff against a single shared baseline, so\n\t * two overlapping passes would both diff against the same snapshot and the later change could fall\n\t * out entirely. An event arriving mid-pass instead queues one trailing pass, which re-reads and\n\t * diffs against the baseline the previous pass just established.\n\t *\n\t * `.git/gk/config` lives in the common dir, so the watcher delivers one event per worktree sharing it\n\t * (see `WatchGroup.onCommonEvent`). Siblings never run concurrently — the later ones fold into the\n\t * in-flight pass — but folding in arms the trailing pass, so a fan-out costs one extra read that\n\t * re-reads and diffs an unchanged file. However many siblings land while a pass is running, they\n\t * coalesce into that single trailing pass; the cost is the price of never dropping a real change.\n\t * Every reporting path is retained because `Repository` matches the follow-up change event on exact\n\t * path, and a sibling worktree that never receives one would sit on stale derived values.\n\t */\n\tprivate reconcileGkConfig(\n\t\trepoPath: string,\n\t\tpriorSnapshot: ReadonlyMap<string, string> | undefined,\n\t): GkReconcileOutcome | Promise<GkReconcileOutcome> {\n\t\tconst commonPath = this.cache.getCommonPath(repoPath);\n\n\t\tconst inflight = this._gkConfigReconciles.get(commonPath);\n\t\tif (inflight != null) {\n\t\t\tinflight.paths.set(repoPath, this.cache.getCloseGeneration(repoPath));\n\t\t\tinflight.pending = true;\n\t\t\t// Handed to the in-flight pass's trailing loop, so it IS being reconciled — just not by this\n\t\t\t// call. Reporting a failure here would coarse-clear on every write in a burst.\n\t\t\treturn 'deferred';\n\t\t}\n\n\t\tconst entry = { pending: false, paths: new Map([[repoPath, this.cache.getCloseGeneration(repoPath)]]) };\n\t\tthis._gkConfigReconciles.set(commonPath, entry);\n\t\treturn this.runGkConfigReconcile(commonPath, priorSnapshot, entry);\n\t}\n\n\t/** Drops paths that closed since they reported the change; returns whichever remain. */\n\tprivate pruneClosedReconcilePaths(paths: Map<string, number>): Map<string, number> {\n\t\tfor (const [path, generation] of paths) {\n\t\t\tif (this.cache.getCloseGeneration(path) !== generation) {\n\t\t\t\tpaths.delete(path);\n\t\t\t}\n\t\t}\n\t\treturn paths;\n\t}\n\n\tprivate async runGkConfigReconcile(\n\t\tcommonPath: string,\n\t\tpriorSnapshot: ReadonlyMap<string, string> | undefined,\n\t\tentry: { pending: boolean; paths: Map<string, number> },\n\t): Promise<GkReconcileOutcome> {\n\t\tconst scope = getScopedLogger();\n\t\tlet snapshot = priorSnapshot;\n\n\t\ttry {\n\t\t\tdo {\n\t\t\t\tentry.pending = false;\n\n\t\t\t\t// Read through a path that's still open — one worktree closing must not drop the event for\n\t\t\t\t// its still-open siblings, which is why this reads from the surviving set rather than from\n\t\t\t\t// whichever path happened to report first.\n\t\t\t\tconst readPath = first(this.pruneClosedReconcilePaths(entry.paths).keys());\n\t\t\t\t// Every path that reported the change has since closed — nothing left to reconcile, and\n\t\t\t\t// nothing left holding a stale derived value either.\n\t\t\t\tif (readPath == null) return 'reconciled';\n\n\t\t\t\t// A trailing pass must not reuse the entry the pass before it installed.\n\t\t\t\tthis.cache.deleteGkConfigMap(readPath);\n\t\t\t\tconst freshMap = await this.getGkConfigMap(readPath);\n\t\t\t\t// Paths may have closed while the re-read was in flight; if every one did, there's nothing\n\t\t\t\t// left to reconcile against.\n\t\t\t\tif (!this.pruneClosedReconcilePaths(entry.paths).size) return 'reconciled';\n\n\t\t\t\tif (this.cache.reconcileGkConfigMap(readPath, snapshot, freshMap)) {\n\t\t\t\t\t// Fire a follow-up change: a consumer that re-read on the original event may have done so\n\t\t\t\t\t// before this async cascade landed, so it would otherwise hold a stale derived value with\n\t\t\t\t\t// nothing left to prompt another re-read.\n\t\t\t\t\tfor (const path of entry.paths.keys()) {\n\t\t\t\t\t\tthis.context.hooks?.repository?.onChanged?.(path, ['gkConfig']);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// `reconcileGkConfigMap` advanced the stored baseline to what we just read; a trailing pass\n\t\t\t\t// diffs its own read against that.\n\t\t\t\tsnapshot = this.cache.getGkConfigMergeSnapshot(readPath);\n\t\t\t} while (entry.pending);\n\n\t\t\treturn 'reconciled';\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, `Failed to reconcile gk config for '${commonPath}'`);\n\t\t\t// The caller falls back to the coarse clear — derived caches are otherwise left holding\n\t\t\t// pre-change values with nothing to correct them.\n\t\t\treturn 'failed';\n\t\t} finally {\n\t\t\tthis._gkConfigReconciles.delete(commonPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync getSigningConfig(repoPath: string): Promise<SigningConfig> {\n\t\t// Fetch all signing-related config in one call\n\t\tconst configMap = await this.getConfigRegex(\n\t\t\trepoPath,\n\t\t\t'^(commit\\\\.gpgsign|gpg\\\\.format|user\\\\.signingkey|gpg\\\\.program|gpg\\\\.ssh\\\\.program|gpg\\\\.ssh\\\\.allowedsignersfile)$',\n\t\t);\n\n\t\t// Extract values (keys are lowercase in git output)\n\t\tconst enabledRaw = configMap.get('commit.gpgsign');\n\t\tconst format = configMap.get('gpg.format');\n\t\tconst signingKey = configMap.get('user.signingkey');\n\t\tconst gpgProgram = configMap.get('gpg.program');\n\t\tconst sshProgram = configMap.get('gpg.ssh.program');\n\t\tconst allowedSignersFile = configMap.get('gpg.ssh.allowedsignersfile');\n\n\t\t// Check if git config has commit signing enabled, falling back to the host-level override\n\t\t// (e.g. VS Code's `git.enableCommitSigning`) when `commit.gpgsign` is unset/false. The host\n\t\t// override can only enable signing, never force it off.\n\t\tconst isEnabled = parseGitBoolean(enabledRaw) || this.context.config?.signing?.enabled === true;\n\n\t\treturn {\n\t\t\tenabled: isEnabled,\n\t\t\tformat: (format as SigningFormat) ?? 'gpg',\n\t\t\tsigningKey: signingKey,\n\t\t\tgpgProgram: gpgProgram,\n\t\t\tsshProgram: sshProgram,\n\t\t\tallowedSignersFile: allowedSignersFile,\n\t\t};\n\t}\n\n\t@debug()\n\tasync validateSigningSetup(repoPath: string): Promise<ValidationResult> {\n\t\tconst config = await this.getSigningConfig(repoPath);\n\n\t\tif (!config.signingKey) {\n\t\t\treturn { valid: false, error: 'No signing key configured' };\n\t\t}\n\n\t\t// Basic validation: just check that a signing key is configured\n\t\t// Git will handle the actual validation when signing commits\n\t\treturn { valid: true };\n\t}\n\n\t@debug()\n\tasync setSigningConfig(\n\t\trepoPath: string,\n\t\tconfig: Partial<SigningConfig>,\n\t\toptions?: { global?: boolean },\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tif (config.enabled != null) {\n\t\t\t\tawait this.setConfig(repoPath, 'commit.gpgsign', config.enabled ? 'true' : 'false', options);\n\t\t\t}\n\t\t\tif (config.format != null) {\n\t\t\t\tawait this.setConfig(repoPath, 'gpg.format', config.format, options);\n\t\t\t}\n\t\t\tif (config.signingKey != null) {\n\t\t\t\tawait this.setConfig(repoPath, 'user.signingkey', config.signingKey, options);\n\t\t\t}\n\t\t\tif (config.gpgProgram != null) {\n\t\t\t\tawait this.setConfig(repoPath, 'gpg.program', config.gpgProgram, options);\n\t\t\t}\n\t\t\tif (config.sshProgram != null) {\n\t\t\t\tawait this.setConfig(repoPath, 'gpg.ssh.program', config.sshProgram, options);\n\t\t\t}\n\t\t\tif (config.allowedSignersFile != null) {\n\t\t\t\tawait this.setConfig(repoPath, 'gpg.ssh.allowedSignersFile', config.allowedSignersFile, options);\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\tgetSigningConfigFlags(config: SigningConfig): string[] {\n\t\tconst flags: string[] = [];\n\n\t\tif (config.gpgProgram) {\n\t\t\tflags.push('-c', `gpg.program=${config.gpgProgram}`);\n\t\t}\n\t\tif (config.format && config.format !== 'gpg') {\n\t\t\tflags.push('-c', `gpg.format=${config.format}`);\n\t\t}\n\t\tif (config.sshProgram) {\n\t\t\tflags.push('-c', `gpg.ssh.program=${config.sshProgram}`);\n\t\t}\n\t\tif (config.allowedSignersFile) {\n\t\t\tflags.push('-c', `gpg.ssh.allowedSignersFile=${config.allowedSignersFile}`);\n\t\t}\n\n\t\treturn flags;\n\t}\n\n\tasync getRepositoryInfo(\n\t\tcwd: string,\n\t): Promise<\n\t\t| { repoPath: string; gitDir: string; commonGitDir: string | undefined; superprojectPath: string | undefined }\n\t\t| [safe: true, repoPath: string]\n\t\t| [safe: false]\n\t\t| []\n\t> {\n\t\tlet result;\n\n\t\tif (this.context.workspace?.isTrusted === false) {\n\t\t\ttry {\n\t\t\t\tawait fs.stat(joinPaths(cwd, 'HEAD'));\n\t\t\t\tresult = await this.git.run(\n\t\t\t\t\t{ cwd: cwd, errors: 'throw', configs: ['-C', cwd] },\n\t\t\t\t\t'rev-parse',\n\t\t\t\t\t'--show-cdup',\n\t\t\t\t);\n\t\t\t\tif (!result.stdout.trim()) {\n\t\t\t\t\tLogger.warn(`Skipping (untrusted); bare clone repository detected in '${cwd}'`);\n\t\t\t\t\treturn emptyArray as [];\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// If this throws, we should be good to open the repo\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tresult = await this.git.run(\n\t\t\t\t{ cwd: cwd, errors: 'throw' },\n\t\t\t\t'rev-parse',\n\t\t\t\t'--show-toplevel',\n\t\t\t\t'--git-dir',\n\t\t\t\t'--git-common-dir',\n\t\t\t\t'--show-superproject-working-tree',\n\t\t\t);\n\t\t\tif (!result.stdout) return emptyArray as [];\n\n\t\t\t// Output is 3-4 lines: show-toplevel, git-dir, git-common-dir, [show-superproject-working-tree]\n\t\t\t// The 4th line is only present for submodules\n\t\t\tconst lines = result.stdout.split('\\n').map(r => r.trimStart());\n\t\t\tconst [repoPath, dotGitPath, commonDotGitPath, superprojectPath] = lines;\n\n\t\t\tif (!repoPath) return emptyArray as [];\n\n\t\t\tconst normalizedRepoPath = normalizePath(repoPath.replace(/[\\r|\\n]+$/, ''));\n\n\t\t\tlet gitDir = dotGitPath;\n\t\t\tif (gitDir && !isAbsolute(gitDir)) {\n\t\t\t\tgitDir = joinPaths(cwd, gitDir);\n\t\t\t}\n\t\t\tgitDir = normalizePath(gitDir);\n\n\t\t\tlet commonGitDir: string | undefined;\n\t\t\tif (commonDotGitPath) {\n\t\t\t\tcommonGitDir = commonDotGitPath;\n\t\t\t\tif (!isAbsolute(commonGitDir)) {\n\t\t\t\t\tcommonGitDir = joinPaths(cwd, commonGitDir);\n\t\t\t\t}\n\t\t\t\tcommonGitDir = normalizePath(commonGitDir);\n\t\t\t\tif (commonGitDir === gitDir) {\n\t\t\t\t\tcommonGitDir = undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\trepoPath: normalizedRepoPath,\n\t\t\t\tgitDir: gitDir,\n\t\t\t\tcommonGitDir: commonGitDir,\n\t\t\t\tsuperprojectPath: superprojectPath?.trim() || undefined,\n\t\t\t};\n\t\t} catch (ex: any) {\n\t\t\tif (ex instanceof WorkspaceUntrustedError) return emptyArray as [];\n\n\t\t\tconst unsafeMatch =\n\t\t\t\t/(?:^fatal:\\s*detected dubious ownership in repository at '([^']+)'|unsafe repository \\('([^']+)' is owned by someone else\\))[\\s\\S]*(git config --global --add safe\\.directory [^\\n\\u2022]+)/m.exec(\n\t\t\t\t\tex.stderr,\n\t\t\t\t);\n\t\t\tif (unsafeMatch != null) {\n\t\t\t\tLogger.warn(\n\t\t\t\t\t`Skipping; unsafe repository detected in '${unsafeMatch[1] || unsafeMatch[2]}'; run '${\n\t\t\t\t\t\tunsafeMatch[3]\n\t\t\t\t\t}' to allow it`,\n\t\t\t\t);\n\t\t\t\treturn [false];\n\t\t\t}\n\n\t\t\tconst inDotGit = /this operation must be run in a work tree/.test(ex.stderr);\n\t\t\tif (inDotGit && this.context.workspace?.isTrusted !== false) {\n\t\t\t\tresult = await this.git.run({ cwd: cwd, errors: 'ignore' }, 'rev-parse', '--is-bare-repository');\n\t\t\t\tif (result.stdout.trim() === 'true') {\n\t\t\t\t\tconst result = await this.revParseGitDir(cwd);\n\t\t\t\t\tconst repoPath = result?.commonPath ?? result?.path;\n\t\t\t\t\tif (repoPath?.length) return [true, repoPath];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (inDotGit || ex.code === 'ENOENT') {\n\t\t\t\tlet exists = inDotGit ? false : await fsExists(cwd);\n\t\t\t\tif (!exists) {\n\t\t\t\t\tdo {\n\t\t\t\t\t\tconst parent = dirname(cwd);\n\t\t\t\t\t\tif (parent === cwd || parent.length === 0) return emptyArray as [];\n\n\t\t\t\t\t\tcwd = parent;\n\t\t\t\t\t\texists = await fsExists(cwd);\n\t\t\t\t\t} while (!exists);\n\n\t\t\t\t\treturn this.getRepositoryInfo(cwd);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn emptyArray as [];\n\t\t}\n\t}\n\n\tprivate async revParseGitDir(cwd: string): Promise<{ path: string; commonPath?: string } | undefined> {\n\t\tconst result = await this.git.run({ cwd: cwd, errors: 'ignore' }, 'rev-parse', '--git-dir', '--git-common-dir');\n\t\tif (!result.stdout) return undefined;\n\n\t\tlet [dotGitPath, commonDotGitPath] = result.stdout.split('\\n').map(r => r.trimStart());\n\n\t\tif (!isAbsolute(dotGitPath)) {\n\t\t\tdotGitPath = joinPaths(cwd, dotGitPath);\n\t\t}\n\t\tdotGitPath = normalizePath(dotGitPath);\n\n\t\tif (commonDotGitPath) {\n\t\t\tif (!isAbsolute(commonDotGitPath)) {\n\t\t\t\tcommonDotGitPath = joinPaths(cwd, commonDotGitPath);\n\t\t\t}\n\t\t\tcommonDotGitPath = normalizePath(commonDotGitPath);\n\n\t\t\treturn { path: dotGitPath, commonPath: commonDotGitPath !== dotGitPath ? commonDotGitPath : undefined };\n\t\t}\n\n\t\treturn { path: dotGitPath };\n\t}\n\n\t/**\n\t * Ensures the `.git/gk/` folder exists, but only if the parent `.git` directory already exists.\n\t * This prevents creating stray `.git` directories if the computed path is wrong.\n\t * Returns `true` if the folder was ensured, `false` if the parent `.git` does not exist.\n\t */\n\tprivate async ensureGkConfigFolder(\n\t\tgkConfigFolder: string,\n\t\tscope: ReturnType<typeof getScopedLogger>,\n\t): Promise<boolean> {\n\t\t// Verify the .git directory already exists — never create it from scratch\n\t\tconst dotGitDir = joinPaths(gkConfigFolder, '..');\n\t\ttry {\n\t\t\tawait fs.stat(dotGitDir);\n\t\t} catch {\n\t\t\tscope?.warn(`Skipping GK config write — expected git directory '${dotGitDir}' does not exist`);\n\t\t\treturn false;\n\t\t}\n\n\t\ttry {\n\t\t\tawait fs.mkdir(gkConfigFolder, { recursive: true });\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, `Failed to create '${gkConfigFolder}' directory`);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tprivate _migratedRepos = new Set<string>();\n\n\t/**\n\t * One-time migration of GK config entries from regular git config to `.git/gk/config`.\n\t * If `.git/gk/config` already exists, assumes migration is complete (or data is already there).\n\t * Preserves existing `.git/gk/config` values as source of truth (won't overwrite).\n\t * Removes migrated keys from regular git config to stop cluttering it.\n\t */\n\t@gate()\n\t@debug()\n\tprivate async migrateGkConfigFromGitConfig(repoPath: string): Promise<void> {\n\t\tif (this._migratedRepos.has(repoPath)) return;\n\n\t\tconst scope = getScopedLogger();\n\n\t\tconst gkConfigPath = await this.getGkConfigPath(repoPath);\n\t\tif (!gkConfigPath) {\n\t\t\tthis._migratedRepos.add(repoPath);\n\t\t\treturn;\n\t\t}\n\n\t\tconst gkConfigFolder = joinPaths(gkConfigPath, '..');\n\n\t\t// If .git/gk/config already exists, consider migration done — it was either\n\t\t// already migrated or values were written there directly via setGkConfig\n\t\ttry {\n\t\t\tawait fs.stat(gkConfigPath);\n\t\t\tthis._migratedRepos.add(repoPath);\n\t\t\treturn;\n\t\t} catch {\n\t\t\t// file doesn't exist, proceed with migration\n\t\t}\n\n\t\t// If .git/gk/config doesn't exist, create an empty file to prevent multiple migration attempts in future sessions\n\t\tif (!(await this.ensureGkConfigFolder(gkConfigFolder, scope))) return;\n\n\t\ttry {\n\t\t\tawait fs.writeFile(gkConfigPath, new Uint8Array());\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, `Failed to create '${gkConfigPath}' file`);\n\t\t}\n\n\t\t// Read legacy gk-* keys from regular git config\n\t\tlet migrateConfig: Map<string, string>;\n\t\ttry {\n\t\t\tmigrateConfig = await this.getConfigRegexCore(repoPath, '^branch\\\\..*\\\\.gk-', { runGitLocally: true });\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, 'Failed to read legacy GK config entries');\n\t\t\tthis._migratedRepos.add(repoPath);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!migrateConfig.size) {\n\t\t\tthis._migratedRepos.add(repoPath);\n\t\t\treturn;\n\t\t}\n\n\t\tscope?.info(`Migrating ${String(migrateConfig.size)} GK config entries from git config to .git/gk/config`);\n\n\t\t// Copy legacy entries to .git/gk/config\n\t\tfor (const [key, value] of [...migrateConfig]) {\n\t\t\ttry {\n\t\t\t\tawait this.setConfigCore(repoPath, key, value, { file: gkConfigPath });\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex, `Failed to migrate key '${key}' to GK config`);\n\t\t\t\t// If we failed to migrate, delete it from the list so we won't try to remove it from git config later\n\t\t\t\tmigrateConfig.delete(key);\n\t\t\t}\n\t\t}\n\n\t\t// Remove legacy keys from regular git config (use --unset-all defensively)\n\t\tfor (const [key] of migrateConfig) {\n\t\t\ttry {\n\t\t\t\tawait this.git.run(\n\t\t\t\t\t{ cwd: repoPath, errors: 'ignore', runLocally: true },\n\t\t\t\t\t'config',\n\t\t\t\t\t'--local',\n\t\t\t\t\t'--unset-all',\n\t\t\t\t\tkey,\n\t\t\t\t);\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex, `Failed to remove migrated key '${key}' from git config`);\n\t\t\t}\n\t\t}\n\n\t\t// Clear caches since we modified both config files\n\t\tthis.cache.clearCaches(repoPath, 'config', 'gkConfig');\n\n\t\tthis._migratedRepos.add(repoPath);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AA2BA,MAAM,oBAAoB;AAC1B,MAAM,aAA+B,OAAO,OAAO,CAAC,CAAC;;AAGrD,MAAM,qBAAqB;;;;;;AAO3B,SAAgB,yBAAyB,KAAqB;CAC7D,MAAM,QAAQ,IAAI,QAAQ,GAAG;CAC7B,IAAI,UAAU,IAAI,OAAO,IAAI,YAAY;CAEzC,MAAM,OAAO,IAAI,YAAY,GAAG;CAGhC,IAAI,UAAU,MAAM,OAAO,IAAI,YAAY;CAC3C,OAAO,GAAG,IAAI,MAAM,GAAG,KAAK,CAAC,CAAC,YAAY,IAAI,IAAI,MAAM,OAAO,IAAI,IAAI,IAAI,MAAM,IAAI,CAAC,CAAC,YAAY;AACpG;;;;;;;;;;;;;;;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A,KAAK,GACL,MAAM,EAAE,OAAM,MAAK,YAAY,IAAI,CAAC,CAAA,GAAA,qBAAA,WAAA,0BAAA,IAAA;AASpC,WAAA,CAAA,KAAK,GACL,MAAM,EACN,OAAM,MACL,YAAY,EAAE,IAAI,SAAS,IAAI,EAAE,cAAc,EAAE,WAAW,SAAS,IAAI,EAAE,cAAc,EAAE,WAAW,SAAS,IAAI,IACrH,CAAC,CAAA,GAAA,qBAAA,WAAA,aAAA,IAAA;AA8CA,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,eAAA,IAAA;AASN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,oBAAA,IAAA;AAwEN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,eAAA,IAAA;AAoDN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,+BAAA,IAAA;AAON,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,+BAAA,IAAA;AA0LN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,oBAAA,IAAA;AA+BN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,wBAAA,IAAA;AAaN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,oBAAA,IAAA;AAkON,WAAA,CAAA,KAAK,GACL,MAAM,CAAA,GAAA,qBAAA,WAAA,gCAAA,IAAA"}
1
+ {"version":3,"file":"config.js","names":["process_env","fs"],"sources":["../../../../git-cli/src/providers/config.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport { hostname, userInfo } from 'os';\nimport { env as process_env } from 'process';\nimport type { Cache, GkConfigInvalidationTarget, GkReconcileOutcome } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport { WorkspaceUntrustedError } from '@gitlens/git/errors.js';\nimport type { GitDir } from '@gitlens/git/models/repository.js';\nimport type { SigningConfig, SigningFormat, ValidationResult } from '@gitlens/git/models/signature.js';\nimport type { GitUser } from '@gitlens/git/models/user.js';\nimport type {\n\tDeprecatedGkConfigKeys,\n\tGitConfigKeys,\n\tGitConfigSubProvider,\n\tGitConfigType,\n\tGkConfigKeys,\n} from '@gitlens/git/providers/config.js';\nimport { parseBranchMetadataGkConfigKey } from '@gitlens/git/utils/branch.utils.js';\nimport { gate } from '@gitlens/utils/decorators/gate.js';\nimport { debug, trace } from '@gitlens/utils/decorators/log.js';\nimport { first, some } from '@gitlens/utils/iterable.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { dirname, getBestPath, isAbsolute, joinPaths, normalizePath } from '@gitlens/utils/path.js';\nimport { fileUri } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport { fsExists } from '../exec/exec.js';\nimport type { Git } from '../exec/git.js';\nimport { KeyedSequencer } from '../exec/indexLock.js';\n\nconst mappedAuthorRegex = /(.+)\\s<(.+)>/;\nconst emptyArray: readonly never[] = Object.freeze([]);\n\n/** Catch-all pattern matching every key in `.git/gk/config` for the one-shot bulk read. */\nconst gkConfigAllPattern = '.';\n\n/**\n * Canonicalizes a git config key for lookup against `--get-regexp` output, which git emits with the\n * section and variable-name lowercased and only the subsection case-preserved. Without this a\n * subsection-less key like `gk.defaultRemote` would miss the lowercased `gk.defaultremote` in the map.\n */\nexport function canonicalizeGitConfigKey(key: string): string {\n\tconst first = key.indexOf('.');\n\tif (first === -1) return key.toLowerCase();\n\n\tconst last = key.lastIndexOf('.');\n\t// `section.name` (no subsection) → fully lowercased; `section.subsection.name` → lowercase\n\t// section + name, preserve the case-sensitive subsection in the middle.\n\tif (first === last) return key.toLowerCase();\n\treturn `${key.slice(0, first).toLowerCase()}${key.slice(first, last)}${key.slice(last).toLowerCase()}`;\n}\n\n/**\n * Parses git config --get-regex output into a Map.\n * The output format is \"key value\" per line, where key and value are space-separated.\n *\n * A line with NO space at all is git's rendering of a bareword/valueless entry (`key`, no `=`) — git's\n * OWN config parser reads that as boolean TRUE (git-config(1): \"a variable defined without `= <value>`\n * is taken as true\"), confirmed against git's `format_config` (builtin/config.c): the key-delimiter is\n * appended unconditionally, then backed out ONLY when the stored value is NULL (the bareword case) —\n * an explicit empty value (`key =`) is a real, non-NULL empty string, so its line KEEPS the trailing\n * space and is already handled by the branch below, byte-distinct from a bareword line.\n *\n * By default a bareword line is skipped (the historical behavior, which reads as \"unset\" — wrong, but\n * safe); pass `includeValueless` to map it to the literal string `'true'` instead, so `parseGitBoolean`\n * and callers checking `.has()` for \"configured\" both read it correctly.\n */\nexport function parseConfigRegexOutput(\n\tdata: string | undefined,\n\toptions?: { includeValueless?: boolean },\n): Map<string, string> {\n\tconst configMap = new Map<string, string>();\n\tif (!data) return configMap;\n\n\tfor (const line of data.split('\\n')) {\n\t\tif (!line) continue;\n\n\t\tconst spaceIndex = line.indexOf(' ');\n\t\tif (spaceIndex === -1) {\n\t\t\tif (options?.includeValueless) {\n\t\t\t\tconfigMap.set(line, 'true');\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tconfigMap.set(line.substring(0, spaceIndex), line.substring(spaceIndex + 1));\n\t}\n\n\treturn configMap;\n}\n\nexport function parseGitBoolean(value: string | undefined): boolean {\n\tif (value == null) return false;\n\n\tconst normalized = value.toLowerCase().trim();\n\treturn normalized === 'true' || normalized === 'yes' || normalized === 'on' || normalized === '1';\n}\n\n/** Whether a git config value spells boolean-false (`false`/`no`/`off`/`0`/empty), per git's maybe-bool parsing. */\nexport function isGitBooleanFalse(value: string): boolean {\n\tconst normalized = value.toLowerCase().trim();\n\treturn (\n\t\tnormalized === '' || normalized === 'false' || normalized === 'no' || normalized === 'off' || normalized === '0'\n\t);\n}\n\nexport class ConfigGitSubProvider implements GitConfigSubProvider {\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\t\tthis.cache.setGkConfigReconciler((repoPath, priorSnapshot) => this.reconcileGkConfig(repoPath, priorSnapshot));\n\t}\n\n\t/**\n\t * In-flight gk-config reconciles keyed by commonPath. `pending` records that another `'gkConfig'`\n\t * event landed mid-pass, so one trailing pass runs after the current one settles. `paths` holds every\n\t * worktree path that reported the change, mapped to its close generation at that moment — the pass\n\t * reads through one that's still open and notifies all of them.\n\t */\n\tprivate readonly _gkConfigReconciles = new Map<string, { pending: boolean; paths: Map<string, number> }>();\n\n\t/**\n\t * The latest pending `setGkConfig` write of each `commonPath\\0key`. A call writing the same value with the same\n\t * skip option joins it; any other call chains after it, so one key's writes land in call order. Cleared on settle.\n\t */\n\tprivate readonly _pendingGkConfigWrites = new Map<\n\t\tstring,\n\t\t{ value: string | undefined; skipKey: string; promise: Promise<void> }\n\t>();\n\n\t/** Maps from failed bulk reads, which a reconcile must not diff as the file's content */\n\tprivate readonly _failedGkConfigMaps = new WeakSet<Map<string, string>>();\n\n\t/** Writes each `.git/gk/config` one at a time — concurrent `git config` writes fail on its lock */\n\tprivate readonly _gkConfigWrites = new KeyedSequencer();\n\n\t@trace()\n\tgetConfig(\n\t\trepoPath: string | undefined,\n\t\tkey: GitConfigKeys,\n\t\toptions?: { global?: boolean; runGitLocally?: boolean; type?: GitConfigType },\n\t): Promise<string | undefined> {\n\t\tconst global = options?.global || repoPath == null;\n\t\treturn this.cache.getConfig(global ? undefined : repoPath, key, () =>\n\t\t\tthis.getConfigCore(repoPath, key, options),\n\t\t);\n\t}\n\n\tprivate async getConfigCore(\n\t\trepoPath: string | undefined,\n\t\tkey: string,\n\t\toptions?: { file?: string; global?: boolean; runGitLocally?: boolean; type?: GitConfigType },\n\t): Promise<string | undefined> {\n\t\tconst args = ['config', '--get'];\n\t\tif (options?.file) {\n\t\t\targs.push('-f', options.file);\n\t\t} else if (options?.global || repoPath == null) {\n\t\t\targs.push('--global');\n\t\t}\n\t\tif (options?.type) {\n\t\t\targs.push(`--type=${options.type}`);\n\t\t}\n\t\targs.push(key);\n\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath ?? '', errors: 'ignore', runLocally: options?.runGitLocally },\n\t\t\t...args,\n\t\t);\n\t\treturn result.stdout.trim() || undefined;\n\t}\n\n\t@trace()\n\tgetConfigRegex(\n\t\trepoPath: string | undefined,\n\t\tpattern: string,\n\t\toptions?: { global?: boolean; runGitLocally?: boolean },\n\t): Promise<Map<string, string>> {\n\t\tconst global = options?.global || repoPath == null;\n\t\treturn this.cache.getConfigRegex(global ? undefined : repoPath, pattern, () =>\n\t\t\tthis.getConfigRegexCore(repoPath, pattern, options),\n\t\t);\n\t}\n\n\tprivate async getConfigRegexCore(\n\t\trepoPath: string | undefined,\n\t\tpattern: string,\n\t\toptions?: { file?: string; global?: boolean; runGitLocally?: boolean },\n\t): Promise<Map<string, string>> {\n\t\tconst args = ['config', '--get-regex'];\n\t\tif (options?.file) {\n\t\t\targs.push('-f', options.file);\n\t\t} else if (options?.global || repoPath == null) {\n\t\t\targs.push('--global');\n\t\t}\n\t\targs.push(pattern);\n\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath ?? '', errors: 'ignore', runLocally: options?.runGitLocally },\n\t\t\t...args,\n\t\t);\n\t\t// Deliberately NOT `.trim()`-ed: an explicit-empty value's LAST line ends in a meaningful trailing\n\t\t// space, and `.trim()`-ing the whole (possibly multi-line) buffer strips it — `parseConfigRegexOutput`\n\t\t// already skips the blank line a trailing newline produces, so no trim is needed.\n\t\treturn parseConfigRegexOutput(result.stdout);\n\t}\n\n\t@debug()\n\tasync setConfig(\n\t\trepoPath: string | undefined,\n\t\tkey: GitConfigKeys,\n\t\tvalue: string | undefined,\n\t\toptions?: { file?: string; global?: boolean },\n\t): Promise<void> {\n\t\tawait this.setConfigCore(repoPath, key, value, options);\n\n\t\t// A branch's upstream (`remote`/`merge`) is read back through the cached branch list, which a\n\t\t// `'config'` reset alone leaves serving the old tracking info.\n\t\tif (repoPath != null && !options?.file && /^branch\\..+\\.(?:remote|merge)$/i.test(key)) {\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t}\n\n\t\t// A `--global` or custom-`file` write isn't this repository's `.git/config`\n\t\tif (repoPath != null && !options?.file && !options?.global) {\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['config']);\n\t\t}\n\t}\n\n\tprivate async setConfigCore(\n\t\trepoPath: string | undefined,\n\t\tkey: string,\n\t\tvalue: string | undefined,\n\t\toptions?: { file?: string; global?: boolean },\n\t): Promise<void> {\n\t\tconst args: string[] = ['config'];\n\n\t\tif (options?.file) {\n\t\t\targs.push('-f', options.file);\n\t\t} else {\n\t\t\tconst global = options?.global || repoPath == null;\n\t\t\targs.push(global ? '--global' : '--local');\n\t\t}\n\n\t\tif (value == null) {\n\t\t\targs.push('--unset', key);\n\t\t} else {\n\t\t\targs.push(key, value);\n\t\t}\n\n\t\tawait this.git.run({ cwd: repoPath ?? '', runLocally: true }, ...args);\n\n\t\t// Only invalidate cache when not using a custom file (custom files aren't cached)\n\t\tif (!options?.file) {\n\t\t\tconst global = options?.global || repoPath == null;\n\t\t\t// Invalidate the cached value for this key and clear all regex patterns for this scope\n\t\t\tthis.cache.deleteConfig(global ? undefined : repoPath, key);\n\t\t}\n\t}\n\n\t@gate()\n\t@debug()\n\tasync getCurrentUser(repoPath: string): Promise<GitUser | undefined> {\n\t\tif (!repoPath) return undefined;\n\n\t\tconst scope = getScopedLogger();\n\n\t\tconst cached = this.cache.currentUser.get(repoPath);\n\t\tif (cached != null) return cached;\n\t\t// If we found null, user data was not found - don't bother trying again\n\t\tif (cached === null) return undefined;\n\n\t\tconst user: GitUser = { name: undefined, email: undefined };\n\n\t\ttry {\n\t\t\tconst configMap = await this.getConfigRegex(repoPath, '^user\\\\.(name|email)$', {\n\t\t\t\trunGitLocally: true,\n\t\t\t});\n\t\t\tif (configMap.size) {\n\t\t\t\tuser.name = configMap.get('user.name');\n\t\t\t\tuser.email = configMap.get('user.email');\n\t\t\t} else {\n\t\t\t\tuser.name =\n\t\t\t\t\tprocess_env.GIT_AUTHOR_NAME || process_env.GIT_COMMITTER_NAME || userInfo()?.username || undefined;\n\t\t\t\tif (!user.name) {\n\t\t\t\t\t// If we found no user data, mark it so we won't bother trying again\n\t\t\t\t\tthis.cache.currentUser.set(repoPath, null);\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tuser.email =\n\t\t\t\t\tprocess_env.GIT_AUTHOR_EMAIL ||\n\t\t\t\t\tprocess_env.GIT_COMMITTER_EMAIL ||\n\t\t\t\t\tprocess_env.EMAIL ||\n\t\t\t\t\t`${user.name}@${hostname()}`;\n\t\t\t}\n\n\t\t\tconst author = `${user.name} <${user.email}>`;\n\t\t\t// Check if there is a mailmap for the current user\n\t\t\tconst result = await this.git.run({ cwd: repoPath, errors: 'ignore' }, 'check-mailmap', author);\n\n\t\t\tif (result.stdout && result.stdout !== author) {\n\t\t\t\tconst match = mappedAuthorRegex.exec(result.stdout);\n\t\t\t\tif (match != null) {\n\t\t\t\t\t[, user.name, user.email] = match;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.cache.currentUser.set(repoPath, user);\n\t\t\treturn user;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\n\t\t\t// Mark it so we won't bother trying again\n\t\t\tthis.cache.currentUser.set(repoPath, null);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@gate()\n\t@trace({ exit: r => `returned ${r}` })\n\tasync getDefaultWorktreePath(repoPath: string): Promise<string | undefined> {\n\t\tconst gitDir = await this.getGitDir(repoPath);\n\t\tif (gitDir == null) return undefined;\n\n\t\tconst basePath = (gitDir.commonUri ?? gitDir.uri).fsPath;\n\t\treturn getBestPath(normalizePath(joinPaths(basePath, '..')));\n\t}\n\n\t@gate()\n\t@trace({\n\t\texit: r =>\n\t\t\t`returned ${r.uri.toString(true)}, commonUri=${r.commonUri?.toString(true)}, parentUri=${r.parentUri?.toString(true)}`,\n\t})\n\tasync getGitDir(repoPath: string): Promise<GitDir> {\n\t\tconst cached = this.cache.gitDir.get(repoPath);\n\t\tif (cached != null) return cached;\n\n\t\tconst scope = getScopedLogger();\n\t\tconst repoInfo = await this.getRepositoryInfo(repoPath);\n\n\t\tlet gitDir: GitDir;\n\t\tif (!Array.isArray(repoInfo) && repoInfo != null) {\n\t\t\tgitDir = {\n\t\t\t\turi: fileUri(repoInfo.gitDir),\n\t\t\t\tcommonUri: repoInfo.commonGitDir ? fileUri(repoInfo.commonGitDir) : undefined,\n\t\t\t\tparentUri: repoInfo.superprojectPath ? fileUri(repoInfo.superprojectPath) : undefined,\n\t\t\t};\n\t\t} else {\n\t\t\tgitDir = {\n\t\t\t\turi: this.provider.getAbsoluteUri(joinPaths(repoPath, '.git'), repoPath),\n\t\t\t};\n\n\t\t\tconst gitDirPath = gitDir.uri.toString(true);\n\t\t\tscope?.warn(`rev-parse failed for '${repoPath}'; falling back to '${gitDirPath}'`);\n\t\t\tthis.context.hooks?.operations?.onGitDirResolveFailed?.(\n\t\t\t\trepoPath,\n\t\t\t\tgitDirPath,\n\t\t\t\t`rev_parse returned ${JSON.stringify(repoInfo)}`,\n\t\t\t);\n\t\t}\n\t\tthis.cache.gitDir.set(repoPath, gitDir);\n\n\t\treturn gitDir;\n\t}\n\n\t/**\n\t * Gets the path to the .git/gk/config file for storing GitKraken-specific metadata.\n\t * Uses commonPath for worktrees so all worktrees share the same data.\n\t */\n\tprivate async getGkConfigPath(repoPath: string): Promise<string | undefined> {\n\t\tconst gitDir = await this.getGitDir(repoPath);\n\t\tif (gitDir == null) return undefined;\n\n\t\t// Use commonUri (main .git dir) for worktrees, otherwise use uri\n\t\tconst basePath = (gitDir.commonUri ?? gitDir.uri).fsPath;\n\t\treturn joinPaths(basePath, 'gk', 'config');\n\t}\n\n\t@debug()\n\tasync getGkConfig(repoPath: string, key: GkConfigKeys | DeprecatedGkConfigKeys): Promise<string | undefined> {\n\t\t// Served in-memory from a single bulk read of the whole `.git/gk/config` (no gk read needs `--type`).\n\t\t// Canonicalize the key the way git does for `--get-regexp` output so subsection-less keys\n\t\t// (e.g. `gk.defaultRemote`) match, and coerce an empty value to undefined to match the old\n\t\t// `git config --get` (`.trim() || undefined`) contract.\n\t\treturn (await this.getGkConfigMap(repoPath)).get(canonicalizeGitConfigKey(key)) || undefined;\n\t}\n\n\t@debug()\n\tasync getGkConfigRegex(repoPath: string, pattern: string): Promise<Map<string, string>> {\n\t\tconst all = await this.getGkConfigMap(repoPath);\n\n\t\t// Filter the bulk map in-memory. The old path passed `pattern` to `git config --get-regex`\n\t\t// (errors ignored → empty result on a bad pattern); preserve that no-throw contract here\n\t\t// rather than letting an invalid-JS pattern reject the read.\n\t\tlet re: RegExp;\n\t\ttry {\n\t\t\tre = new RegExp(pattern);\n\t\t} catch {\n\t\t\treturn new Map();\n\t\t}\n\n\t\tconst result = new Map<string, string>();\n\t\tfor (const [k, v] of all) {\n\t\t\tif (re.test(k)) {\n\t\t\t\tresult.set(k, v);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Reads the entire `.git/gk/config` in one `git config --get-regexp` and caches the parsed map\n\t * per commonPath. Per-key (getGkConfig) and per-namespace (getGkConfigRegex) lookups are served\n\t * from this single cached read — so a branch-overview render that fans out across several gk\n\t * namespaces costs one `git config` call instead of one per namespace.\n\t */\n\tprivate async getGkConfigMap(repoPath: string): Promise<Map<string, string>> {\n\t\t// Migrate BEFORE populating the cache, not inside the factory: a first-time migration calls\n\t\t// clearCaches('gkConfig'), which would otherwise evict the in-flight gkConfigMap entry the\n\t\t// cache wrapper synchronously stored and force a redundant bulk re-read.\n\t\tawait this.migrateGkConfigFromGitConfig(this.cache.getCommonPath(repoPath));\n\t\treturn this.cache.getGkConfigMap(repoPath, async cacheable => {\n\t\t\tconst { map, failed } = await this.getGkConfigRegexCore(repoPath, gkConfigAllPattern);\n\t\t\t// This map has no TTL and everything gk-related reads through it, so a failed read cached as an\n\t\t\t// empty map would report every branch as having no stored base or merge target for the session —\n\t\t\t// and would make the section-cleanup pre-checks skip real work. Only cache a read that happened.\n\t\t\tif (failed) {\n\t\t\t\tcacheable.invalidate();\n\t\t\t\tthis._failedGkConfigMaps.add(map);\n\t\t\t}\n\t\t\treturn map;\n\t\t});\n\t}\n\n\tprivate async getGkConfigRegexCore(\n\t\trepoPath: string,\n\t\tpattern: string,\n\t): Promise<{ map: Map<string, string>; failed: boolean }> {\n\t\tconst gkConfigPath = await this.getGkConfigPath(repoPath);\n\t\t// No `.git/gk/config` yet is a real answer, not a failure — a repo GitLens has never written to.\n\t\tif (!gkConfigPath) return { map: new Map(), failed: false };\n\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath, errors: 'ignore', runLocally: true },\n\t\t\t'config',\n\t\t\t'--get-regex',\n\t\t\t'-f',\n\t\t\tgkConfigPath,\n\t\t\tpattern,\n\t\t);\n\t\t// `--get-regex` exits 1 when nothing matches, which IS an answer (an empty gk config).\n\t\tconst exited = result.completion.status === 'exited';\n\t\treturn {\n\t\t\t// Deliberately NOT `.trim()`-ed — see `getConfigRegexCore`'s comment: it strips the trailing\n\t\t\t// space that marks an explicit-empty value's LAST line, silently dropping it from the map.\n\t\t\tmap: parseConfigRegexOutput(result.stdout),\n\t\t\tfailed: !exited || (result.exitCode !== 0 && result.exitCode !== 1),\n\t\t};\n\t}\n\n\t@debug()\n\tasync setGkConfig(\n\t\trepoPath: string,\n\t\tkey: GkConfigKeys | DeprecatedGkConfigKeys,\n\t\tvalue: string | undefined,\n\t\toptions?: { skipInvalidation?: readonly GkConfigInvalidationTarget[] },\n\t): Promise<void> {\n\t\t// A self-write (with skip targets) and a user-driven write of the same value have different invalidation\n\t\t// semantics, so only a matching skip option may join: otherwise the user-driven write would skip invalidation.\n\t\t// Sorted, so the same targets in any order match.\n\t\tconst commonPath = this.cache.getCommonPath(repoPath);\n\t\tconst skipKey = options?.skipInvalidation?.length ? options.skipInvalidation.toSorted().join(',') : '';\n\t\tconst pendingKey = `${commonPath}\\0${key}`;\n\n\t\tconst previous = this._pendingGkConfigWrites.get(pendingKey);\n\t\tif (previous != null && previous.value === value && previous.skipKey === skipKey) return previous.promise;\n\n\t\tconst promise =\n\t\t\tprevious != null\n\t\t\t\t? previous.promise.catch(() => {}).then(() => this.setGkConfigCore(repoPath, key, value, options))\n\t\t\t\t: this.setGkConfigCore(repoPath, key, value, options);\n\t\tconst pending = { value: value, skipKey: skipKey, promise: promise };\n\t\tthis._pendingGkConfigWrites.set(pendingKey, pending);\n\t\t// Swallow the cleanup chain's rejection so a failed write doesn't surface as an unhandled\n\t\t// rejection separate from the caller's own handling of the returned promise.\n\t\tvoid promise\n\t\t\t.finally(() => {\n\t\t\t\tif (this._pendingGkConfigWrites.get(pendingKey) === pending) {\n\t\t\t\t\tthis._pendingGkConfigWrites.delete(pendingKey);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch(() => {});\n\t\treturn promise;\n\t}\n\n\tprivate async setGkConfigCore(\n\t\trepoPath: string,\n\t\tkey: GkConfigKeys | DeprecatedGkConfigKeys,\n\t\tvalue: string | undefined,\n\t\toptions?: { skipInvalidation?: readonly GkConfigInvalidationTarget[] },\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst gkConfigPath = await this.getGkConfigPath(repoPath);\n\t\tif (!gkConfigPath) return;\n\n\t\tconst gkConfigFolder = joinPaths(gkConfigPath, '..');\n\n\t\tif (!(await this.ensureGkConfigFolder(gkConfigFolder, scope))) return;\n\n\t\t// Seed the reconcile snapshot from the pre-write file, so the write below can tell whether it changed the\n\t\t// value (first tracked-key write per repository only; the bulk read is cached for everything else)\n\t\tif (this.cache.needsGkConfigSnapshot(repoPath, key)) {\n\t\t\tawait this.getGkConfigMap(repoPath);\n\t\t}\n\n\t\tawait this._gkConfigWrites.run(gkConfigPath, undefined, () =>\n\t\t\tthis.setConfigCore(repoPath, key, value, { file: gkConfigPath }),\n\t\t);\n\n\t\t// Invalidate the bulk map (so the next read re-fetches) and the derived caches for this key's\n\t\t// ref, then record the write, which fires `onDidChangeMergeTargets` when it changed a merge key —\n\t\t// except for a self-write (`skipInvalidation` given: an internal save while answering a read), which\n\t\t// nobody awaits; only another process's watcher reports that one.\n\t\t// The `.git/gk/config` file-watcher also fires `'gkConfig'` shortly after, which reconciles\n\t\t// the same change (see `reconcileGkConfig`) — recording our own write here keeps that later\n\t\t// reconcile from re-diffing this key as an external change.\n\t\tthis.cache.deleteGkConfig(repoPath, key, options);\n\t\tthis.cache.recordGkConfigWrite(repoPath, key, value, { announce: options?.skipInvalidation == null });\n\n\t\t// The watcher's report of this write can't reach the cached branches: the snapshot already holds the value\n\t\tconst metadataKey = parseBranchMetadataGkConfigKey(key);\n\t\tif (metadataKey != null) {\n\t\t\tthis.cache.patchBranchMetadata(repoPath, [\n\t\t\t\t{ branch: metadataKey.branch, key: metadataKey.key, value: value },\n\t\t\t]);\n\t\t}\n\t}\n\n\t@debug()\n\tasync removeGkConfigBranchSection(repoPath: string, ref: string): Promise<void> {\n\t\tif (await this.runGkConfigSectionCommand(repoPath, ref, '--remove-section', `branch.${ref}`)) {\n\t\t\tthis.cache.recordGkConfigSectionWrite(repoPath, ref);\n\t\t}\n\t}\n\n\t@debug()\n\tasync renameGkConfigBranchSection(repoPath: string, oldRef: string, newRef: string): Promise<void> {\n\t\t// Clear the destination first, unconditionally. `--rename-section` onto a section that already\n\t\t// exists APPENDS rather than replaces, leaving duplicate keys — and git resolves a duplicated key\n\t\t// to its LAST value, so the orphan left by an earlier branch of this name would win over the\n\t\t// metadata being moved. Doing this outside `runGkConfigSectionCommand` also covers the case where\n\t\t// the source has no gk keys at all, where its pre-check would otherwise skip the whole call and\n\t\t// leave the orphan in place for the renamed branch to inherit.\n\t\tawait this.removeGkConfigBranchSection(repoPath, newRef);\n\t\tif (\n\t\t\tawait this.runGkConfigSectionCommand(\n\t\t\t\trepoPath,\n\t\t\t\toldRef,\n\t\t\t\t'--rename-section',\n\t\t\t\t`branch.${oldRef}`,\n\t\t\t\t`branch.${newRef}`,\n\t\t\t)\n\t\t) {\n\t\t\tthis.cache.recordGkConfigSectionWrite(repoPath, oldRef, newRef);\n\t\t}\n\t}\n\n\t/**\n\t * Runs a section-level `git config` against `.git/gk/config` for `ref`'s section, skipping the\n\t * subprocess entirely when the bulk map (already cached on any warm path) shows that ref has no gk\n\t * keys — the overwhelmingly common case, since most branches never get gk metadata written at all.\n\t *\n\t * Never throws: callers invoke this as bookkeeping after a branch op has already succeeded, so a\n\t * failure here must not be reported as (or roll back) the branch/checkout/worktree operation itself.\n\t * The worst case is metadata that stays behind until the next op on that name.\n\t *\n\t * Returns whether `.git/gk/config` now reflects the command (it ran, or there was nothing to do), so the\n\t * caller can record its own write in the reconcile snapshot only when it actually landed.\n\t */\n\tprivate async runGkConfigSectionCommand(repoPath: string, ref: string, ...args: string[]): Promise<boolean> {\n\t\tconst scope = getScopedLogger();\n\t\ttry {\n\t\t\tconst prefix = `branch.${ref}.`;\n\t\t\tconst map = await this.getGkConfigMap(repoPath);\n\t\t\t// The shortcut needs a map with CONTENT to be trustworthy. A failed bulk read resolves empty\n\t\t\t// (see `getGkConfigMap`) — the cache refuses it, but this caller still holds it — and an empty map\n\t\t\t// read as authoritative would skip the removal entirely, leaving a deleted branch's base,\n\t\t\t// disposition and issue links behind for the next branch reusing that name. When it's empty, run\n\t\t\t// the command: worst case is a no-op on a section that isn't there.\n\t\t\tif (map.size && !some(map.keys(), k => k.startsWith(prefix))) return true;\n\n\t\t\tconst gkConfigPath = await this.getGkConfigPath(repoPath);\n\t\t\tif (!gkConfigPath) return false;\n\t\t\t// `getGkConfigPath` only joins a path, so check the file: with no `.git/gk/config` there is\n\t\t\t// genuinely nothing to remove, and running the command would fail with a fatal we'd then warn\n\t\t\t// about on every branch delete in a repo that has never had gk metadata.\n\t\t\tif (!(await fsExists(gkConfigPath))) return true;\n\n\t\t\tconst result = await this._gkConfigWrites.run(gkConfigPath, undefined, () =>\n\t\t\t\tthis.git.run(\n\t\t\t\t\t{ cwd: repoPath, runLocally: true, errors: 'ignore' },\n\t\t\t\t\t'config',\n\t\t\t\t\t'-f',\n\t\t\t\t\tgkConfigPath,\n\t\t\t\t\t...args,\n\t\t\t\t),\n\t\t\t);\n\t\t\t// `errors: 'ignore'` is deliberate — see the note above on why this must never throw — but that\n\t\t\t// also means the `catch` below never sees a failed write, so without this the metadata silently\n\t\t\t// stays behind (or, on a rename, stays under the old name) with nothing recorded anywhere.\n\t\t\t// Reported, not thrown: the branch op it follows has already succeeded.\n\t\t\tconst succeeded = result.completion.status === 'exited' && result.exitCode === 0;\n\t\t\tif (!succeeded) {\n\t\t\t\tscope?.warn(\n\t\t\t\t\t`Failed to update gk config section for '${ref}' in '${repoPath}': ${\n\t\t\t\t\t\tresult.completion.status === 'exited'\n\t\t\t\t\t\t\t? `git config exited ${result.exitCode}`\n\t\t\t\t\t\t\t: `${result.completion.status} · ${result.completion.error.message}`\n\t\t\t\t\t}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\t// A whole section moved or vanished, which the per-key `deleteGkConfig` cascade can't express.\n\t\t\t// Drop the bulk map so the next read hits disk; the derived caches for the affected ref are\n\t\t\t// evicted by the caller's own `deleteBaseBranchName` plus the `'branches'` cascade it fires.\n\t\t\tthis.cache.deleteGkConfigMap(repoPath);\n\t\t\treturn succeeded;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, `Failed to update gk config section for '${ref}' in '${repoPath}'`);\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Reconciles a watcher-observed `'gkConfig'` change — registered with the shared `Cache` as its\n\t * gk-config reconciler (see the constructor). Re-reads the bulk map (hard-evicted by\n\t * `Cache.handleGkConfigChanged`, so this hits disk) and diffs it against `priorSnapshot` to cascade\n\t * `baseBranchName`/`branchOverviews` only for refs whose merge-relevant keys actually changed, and to evict the\n\t * branches only when a branch metadata key (another process's activity stamp) changed.\n\t *\n\t * Serialized per commonPath: a reconcile is a read-then-diff against a single shared baseline, so\n\t * two overlapping passes would both diff against the same snapshot and the later change could fall\n\t * out entirely. An event arriving mid-pass instead queues one trailing pass, which re-reads and\n\t * diffs against the baseline the previous pass just established.\n\t *\n\t * `.git/gk/config` lives in the common dir, so the watcher delivers one event per worktree sharing it\n\t * (see `WatchGroup.onCommonEvent`). Siblings never run concurrently — the later ones fold into the\n\t * in-flight pass — but folding in arms the trailing pass, so a fan-out costs one extra read that\n\t * re-reads and diffs an unchanged file. However many siblings land while a pass is running, they\n\t * coalesce into that single trailing pass; the cost is the price of never dropping a real change.\n\t * Every reporting path is retained because `Repository` matches the follow-up change event on exact\n\t * path, and a sibling worktree that never receives one would sit on stale derived values.\n\t */\n\tprivate reconcileGkConfig(\n\t\trepoPath: string,\n\t\tpriorSnapshot: ReadonlyMap<string, string> | undefined,\n\t): GkReconcileOutcome | Promise<GkReconcileOutcome> {\n\t\tconst commonPath = this.cache.getCommonPath(repoPath);\n\n\t\tconst inflight = this._gkConfigReconciles.get(commonPath);\n\t\tif (inflight != null) {\n\t\t\tinflight.paths.set(repoPath, this.cache.getCloseGeneration(repoPath));\n\t\t\tinflight.pending = true;\n\t\t\t// Handed to the in-flight pass's trailing loop, so it IS being reconciled — just not by this\n\t\t\t// call. Reporting a failure here would coarse-clear on every write in a burst.\n\t\t\treturn 'deferred';\n\t\t}\n\n\t\tconst entry = { pending: false, paths: new Map([[repoPath, this.cache.getCloseGeneration(repoPath)]]) };\n\t\tthis._gkConfigReconciles.set(commonPath, entry);\n\t\treturn this.runGkConfigReconcile(commonPath, priorSnapshot, entry);\n\t}\n\n\t/** Drops paths that closed since they reported the change; returns whichever remain. */\n\tprivate pruneClosedReconcilePaths(paths: Map<string, number>): Map<string, number> {\n\t\tfor (const [path, generation] of paths) {\n\t\t\tif (this.cache.getCloseGeneration(path) !== generation) {\n\t\t\t\tpaths.delete(path);\n\t\t\t}\n\t\t}\n\t\treturn paths;\n\t}\n\n\tprivate async runGkConfigReconcile(\n\t\tcommonPath: string,\n\t\tpriorSnapshot: ReadonlyMap<string, string> | undefined,\n\t\tentry: { pending: boolean; paths: Map<string, number> },\n\t): Promise<GkReconcileOutcome> {\n\t\tconst scope = getScopedLogger();\n\t\tlet snapshot = priorSnapshot;\n\n\t\ttry {\n\t\t\tdo {\n\t\t\t\tentry.pending = false;\n\n\t\t\t\t// Read through a path that's still open — one worktree closing must not drop the event for\n\t\t\t\t// its still-open siblings, which is why this reads from the surviving set rather than from\n\t\t\t\t// whichever path happened to report first.\n\t\t\t\tconst readPath = first(this.pruneClosedReconcilePaths(entry.paths).keys());\n\t\t\t\t// Every path that reported the change has since closed — nothing left to reconcile, and\n\t\t\t\t// nothing left holding a stale derived value either.\n\t\t\t\tif (readPath == null) return 'reconciled';\n\n\t\t\t\t// A trailing pass must not reuse the entry the pass before it installed.\n\t\t\t\tthis.cache.deleteGkConfigMap(readPath);\n\t\t\t\tconst freshMap = await this.getGkConfigMap(readPath);\n\t\t\t\t// A failed read diffed as the file's content would remove every key it missed\n\t\t\t\tif (this._failedGkConfigMaps.has(freshMap)) {\n\t\t\t\t\tthrow new Error(`Failed to read the gk config through '${readPath}'`);\n\t\t\t\t}\n\n\t\t\t\t// Paths may have closed while the re-read was in flight; if every one did, there's nothing\n\t\t\t\t// left to reconcile against.\n\t\t\t\tif (!this.pruneClosedReconcilePaths(entry.paths).size) return 'reconciled';\n\n\t\t\t\tif (this.cache.reconcileGkConfigMap(readPath, snapshot, freshMap)) {\n\t\t\t\t\t// Fire a follow-up change: a consumer that re-read on the original event may have done so\n\t\t\t\t\t// before this async cascade landed, so it would otherwise hold a stale derived value with\n\t\t\t\t\t// nothing left to prompt another re-read. Only the host hears it: it is not a write of\n\t\t\t\t\t// core's, and announcing it as one would evict the map just reconciled.\n\t\t\t\t\tfor (const path of entry.paths.keys()) {\n\t\t\t\t\t\tthis.provider.notifyHost(path, ['gkConfig']);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// `reconcileGkConfigMap` advanced the stored baseline to what we just read; a trailing pass\n\t\t\t\t// diffs its own read against that.\n\t\t\t\tsnapshot = this.cache.getGkConfigSnapshot(readPath);\n\t\t\t} while (entry.pending);\n\n\t\t\treturn 'reconciled';\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, `Failed to reconcile gk config for '${commonPath}'`);\n\t\t\t// The caller falls back to the coarse clear — derived caches are otherwise left holding\n\t\t\t// pre-change values with nothing to correct them.\n\t\t\treturn 'failed';\n\t\t} finally {\n\t\t\tthis._gkConfigReconciles.delete(commonPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync getSigningConfig(repoPath: string): Promise<SigningConfig> {\n\t\t// Fetch all signing-related config in one call\n\t\tconst configMap = await this.getConfigRegex(\n\t\t\trepoPath,\n\t\t\t'^(commit\\\\.gpgsign|gpg\\\\.format|user\\\\.signingkey|gpg\\\\.program|gpg\\\\.ssh\\\\.program|gpg\\\\.ssh\\\\.allowedsignersfile)$',\n\t\t);\n\n\t\t// Extract values (keys are lowercase in git output)\n\t\tconst enabledRaw = configMap.get('commit.gpgsign');\n\t\tconst format = configMap.get('gpg.format');\n\t\tconst signingKey = configMap.get('user.signingkey');\n\t\tconst gpgProgram = configMap.get('gpg.program');\n\t\tconst sshProgram = configMap.get('gpg.ssh.program');\n\t\tconst allowedSignersFile = configMap.get('gpg.ssh.allowedsignersfile');\n\n\t\t// Check if git config has commit signing enabled, falling back to the host-level override\n\t\t// (e.g. VS Code's `git.enableCommitSigning`) when `commit.gpgsign` is unset/false. The host\n\t\t// override can only enable signing, never force it off.\n\t\tconst isEnabled = parseGitBoolean(enabledRaw) || this.context.config?.signing?.enabled === true;\n\n\t\treturn {\n\t\t\tenabled: isEnabled,\n\t\t\tformat: (format as SigningFormat) ?? 'gpg',\n\t\t\tsigningKey: signingKey,\n\t\t\tgpgProgram: gpgProgram,\n\t\t\tsshProgram: sshProgram,\n\t\t\tallowedSignersFile: allowedSignersFile,\n\t\t};\n\t}\n\n\t@debug()\n\tasync validateSigningSetup(repoPath: string): Promise<ValidationResult> {\n\t\tconst config = await this.getSigningConfig(repoPath);\n\n\t\tif (!config.signingKey) {\n\t\t\treturn { valid: false, error: 'No signing key configured' };\n\t\t}\n\n\t\t// Basic validation: just check that a signing key is configured\n\t\t// Git will handle the actual validation when signing commits\n\t\treturn { valid: true };\n\t}\n\n\t@debug()\n\tasync setSigningConfig(\n\t\trepoPath: string,\n\t\tconfig: Partial<SigningConfig>,\n\t\toptions?: { global?: boolean },\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst entries: [GitConfigKeys, string][] = [];\n\t\tif (config.enabled != null) {\n\t\t\tentries.push(['commit.gpgsign', config.enabled ? 'true' : 'false']);\n\t\t}\n\t\tif (config.format != null) {\n\t\t\tentries.push(['gpg.format', config.format]);\n\t\t}\n\t\tif (config.signingKey != null) {\n\t\t\tentries.push(['user.signingkey', config.signingKey]);\n\t\t}\n\t\tif (config.gpgProgram != null) {\n\t\t\tentries.push(['gpg.program', config.gpgProgram]);\n\t\t}\n\t\tif (config.sshProgram != null) {\n\t\t\tentries.push(['gpg.ssh.program', config.sshProgram]);\n\t\t}\n\t\tif (config.allowedSignersFile != null) {\n\t\t\tentries.push(['gpg.ssh.allowedSignersFile', config.allowedSignersFile]);\n\t\t}\n\n\t\tlet wrote = false;\n\t\ttry {\n\t\t\tfor (const [key, value] of entries) {\n\t\t\t\tawait this.setConfigCore(repoPath, key, value, options);\n\t\t\t\twrote = true;\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tthrow ex;\n\t\t} finally {\n\t\t\t// One `config` announcement for the keys written, rather than one (each fanned out to every worktree) per key\n\t\t\tif (wrote && !options?.global) {\n\t\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['config']);\n\t\t\t}\n\t\t}\n\t}\n\n\tgetSigningConfigFlags(config: SigningConfig): string[] {\n\t\tconst flags: string[] = [];\n\n\t\tif (config.gpgProgram) {\n\t\t\tflags.push('-c', `gpg.program=${config.gpgProgram}`);\n\t\t}\n\t\tif (config.format && config.format !== 'gpg') {\n\t\t\tflags.push('-c', `gpg.format=${config.format}`);\n\t\t}\n\t\tif (config.sshProgram) {\n\t\t\tflags.push('-c', `gpg.ssh.program=${config.sshProgram}`);\n\t\t}\n\t\tif (config.allowedSignersFile) {\n\t\t\tflags.push('-c', `gpg.ssh.allowedSignersFile=${config.allowedSignersFile}`);\n\t\t}\n\n\t\treturn flags;\n\t}\n\n\tasync getRepositoryInfo(\n\t\tcwd: string,\n\t): Promise<\n\t\t| { repoPath: string; gitDir: string; commonGitDir: string | undefined; superprojectPath: string | undefined }\n\t\t| [safe: true, repoPath: string]\n\t\t| [safe: false]\n\t\t| []\n\t> {\n\t\tlet result;\n\n\t\tif (this.context.workspace?.isTrusted === false) {\n\t\t\ttry {\n\t\t\t\tawait fs.stat(joinPaths(cwd, 'HEAD'));\n\t\t\t\tresult = await this.git.run(\n\t\t\t\t\t{ cwd: cwd, errors: 'throw', configs: ['-C', cwd] },\n\t\t\t\t\t'rev-parse',\n\t\t\t\t\t'--show-cdup',\n\t\t\t\t);\n\t\t\t\tif (!result.stdout.trim()) {\n\t\t\t\t\tLogger.warn(`Skipping (untrusted); bare clone repository detected in '${cwd}'`);\n\t\t\t\t\treturn emptyArray as [];\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// If this throws, we should be good to open the repo\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tresult = await this.git.run(\n\t\t\t\t{ cwd: cwd, errors: 'throw' },\n\t\t\t\t'rev-parse',\n\t\t\t\t'--show-toplevel',\n\t\t\t\t'--git-dir',\n\t\t\t\t'--git-common-dir',\n\t\t\t\t'--show-superproject-working-tree',\n\t\t\t);\n\t\t\tif (!result.stdout) return emptyArray as [];\n\n\t\t\t// Output is 3-4 lines: show-toplevel, git-dir, git-common-dir, [show-superproject-working-tree]\n\t\t\t// The 4th line is only present for submodules\n\t\t\tconst lines = result.stdout.split('\\n').map(r => r.trimStart());\n\t\t\tconst [repoPath, dotGitPath, commonDotGitPath, superprojectPath] = lines;\n\n\t\t\tif (!repoPath) return emptyArray as [];\n\n\t\t\tconst normalizedRepoPath = normalizePath(repoPath.replace(/[\\r|\\n]+$/, ''));\n\n\t\t\tlet gitDir = dotGitPath;\n\t\t\tif (gitDir && !isAbsolute(gitDir)) {\n\t\t\t\tgitDir = joinPaths(cwd, gitDir);\n\t\t\t}\n\t\t\tgitDir = normalizePath(gitDir);\n\n\t\t\tlet commonGitDir: string | undefined;\n\t\t\tif (commonDotGitPath) {\n\t\t\t\tcommonGitDir = commonDotGitPath;\n\t\t\t\tif (!isAbsolute(commonGitDir)) {\n\t\t\t\t\tcommonGitDir = joinPaths(cwd, commonGitDir);\n\t\t\t\t}\n\t\t\t\tcommonGitDir = normalizePath(commonGitDir);\n\t\t\t\tif (commonGitDir === gitDir) {\n\t\t\t\t\tcommonGitDir = undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\trepoPath: normalizedRepoPath,\n\t\t\t\tgitDir: gitDir,\n\t\t\t\tcommonGitDir: commonGitDir,\n\t\t\t\tsuperprojectPath: superprojectPath?.trim() || undefined,\n\t\t\t};\n\t\t} catch (ex: any) {\n\t\t\tif (ex instanceof WorkspaceUntrustedError) return emptyArray as [];\n\n\t\t\tconst unsafeMatch =\n\t\t\t\t/(?:^fatal:\\s*detected dubious ownership in repository at '([^']+)'|unsafe repository \\('([^']+)' is owned by someone else\\))[\\s\\S]*(git config --global --add safe\\.directory [^\\n\\u2022]+)/m.exec(\n\t\t\t\t\tex.stderr,\n\t\t\t\t);\n\t\t\tif (unsafeMatch != null) {\n\t\t\t\tLogger.warn(\n\t\t\t\t\t`Skipping; unsafe repository detected in '${unsafeMatch[1] || unsafeMatch[2]}'; run '${\n\t\t\t\t\t\tunsafeMatch[3]\n\t\t\t\t\t}' to allow it`,\n\t\t\t\t);\n\t\t\t\treturn [false];\n\t\t\t}\n\n\t\t\tconst inDotGit = /this operation must be run in a work tree/.test(ex.stderr);\n\t\t\tif (inDotGit && this.context.workspace?.isTrusted !== false) {\n\t\t\t\tresult = await this.git.run({ cwd: cwd, errors: 'ignore' }, 'rev-parse', '--is-bare-repository');\n\t\t\t\tif (result.stdout.trim() === 'true') {\n\t\t\t\t\tconst result = await this.revParseGitDir(cwd);\n\t\t\t\t\tconst repoPath = result?.commonPath ?? result?.path;\n\t\t\t\t\tif (repoPath?.length) return [true, repoPath];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (inDotGit || ex.code === 'ENOENT') {\n\t\t\t\tlet exists = inDotGit ? false : await fsExists(cwd);\n\t\t\t\tif (!exists) {\n\t\t\t\t\tdo {\n\t\t\t\t\t\tconst parent = dirname(cwd);\n\t\t\t\t\t\tif (parent === cwd || parent.length === 0) return emptyArray as [];\n\n\t\t\t\t\t\tcwd = parent;\n\t\t\t\t\t\texists = await fsExists(cwd);\n\t\t\t\t\t} while (!exists);\n\n\t\t\t\t\treturn this.getRepositoryInfo(cwd);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn emptyArray as [];\n\t\t}\n\t}\n\n\tprivate async revParseGitDir(cwd: string): Promise<{ path: string; commonPath?: string } | undefined> {\n\t\tconst result = await this.git.run({ cwd: cwd, errors: 'ignore' }, 'rev-parse', '--git-dir', '--git-common-dir');\n\t\tif (!result.stdout) return undefined;\n\n\t\tlet [dotGitPath, commonDotGitPath] = result.stdout.split('\\n').map(r => r.trimStart());\n\n\t\tif (!isAbsolute(dotGitPath)) {\n\t\t\tdotGitPath = joinPaths(cwd, dotGitPath);\n\t\t}\n\t\tdotGitPath = normalizePath(dotGitPath);\n\n\t\tif (commonDotGitPath) {\n\t\t\tif (!isAbsolute(commonDotGitPath)) {\n\t\t\t\tcommonDotGitPath = joinPaths(cwd, commonDotGitPath);\n\t\t\t}\n\t\t\tcommonDotGitPath = normalizePath(commonDotGitPath);\n\n\t\t\treturn { path: dotGitPath, commonPath: commonDotGitPath !== dotGitPath ? commonDotGitPath : undefined };\n\t\t}\n\n\t\treturn { path: dotGitPath };\n\t}\n\n\t/**\n\t * Ensures the `.git/gk/` folder exists, but only if the parent `.git` directory already exists.\n\t * This prevents creating stray `.git` directories if the computed path is wrong.\n\t * Returns `true` if the folder was ensured, `false` if the parent `.git` does not exist.\n\t */\n\tprivate async ensureGkConfigFolder(\n\t\tgkConfigFolder: string,\n\t\tscope: ReturnType<typeof getScopedLogger>,\n\t): Promise<boolean> {\n\t\t// Verify the .git directory already exists — never create it from scratch\n\t\tconst dotGitDir = joinPaths(gkConfigFolder, '..');\n\t\ttry {\n\t\t\tawait fs.stat(dotGitDir);\n\t\t} catch {\n\t\t\tscope?.warn(`Skipping GK config write — expected git directory '${dotGitDir}' does not exist`);\n\t\t\treturn false;\n\t\t}\n\n\t\ttry {\n\t\t\tawait fs.mkdir(gkConfigFolder, { recursive: true });\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, `Failed to create '${gkConfigFolder}' directory`);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tprivate _migratedRepos = new Set<string>();\n\n\t/**\n\t * One-time migration of GK config entries from regular git config to `.git/gk/config`.\n\t * If `.git/gk/config` already exists, assumes migration is complete (or data is already there).\n\t * Preserves existing `.git/gk/config` values as source of truth (won't overwrite).\n\t * Removes migrated keys from regular git config to stop cluttering it.\n\t */\n\t@gate()\n\t@debug()\n\tprivate async migrateGkConfigFromGitConfig(repoPath: string): Promise<void> {\n\t\tif (this._migratedRepos.has(repoPath)) return;\n\n\t\tconst scope = getScopedLogger();\n\n\t\tconst gkConfigPath = await this.getGkConfigPath(repoPath);\n\t\tif (!gkConfigPath) {\n\t\t\tthis._migratedRepos.add(repoPath);\n\t\t\treturn;\n\t\t}\n\n\t\tconst gkConfigFolder = joinPaths(gkConfigPath, '..');\n\n\t\t// If .git/gk/config already exists, consider migration done — it was either\n\t\t// already migrated or values were written there directly via setGkConfig\n\t\ttry {\n\t\t\tawait fs.stat(gkConfigPath);\n\t\t\tthis._migratedRepos.add(repoPath);\n\t\t\treturn;\n\t\t} catch {\n\t\t\t// file doesn't exist, proceed with migration\n\t\t}\n\n\t\t// If .git/gk/config doesn't exist, create an empty file to prevent multiple migration attempts in future sessions\n\t\tif (!(await this.ensureGkConfigFolder(gkConfigFolder, scope))) return;\n\n\t\ttry {\n\t\t\tawait fs.writeFile(gkConfigPath, new Uint8Array());\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, `Failed to create '${gkConfigPath}' file`);\n\t\t}\n\n\t\t// Read legacy gk-* keys from regular git config\n\t\tlet migrateConfig: Map<string, string>;\n\t\ttry {\n\t\t\tmigrateConfig = await this.getConfigRegexCore(repoPath, '^branch\\\\..*\\\\.gk-', { runGitLocally: true });\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, 'Failed to read legacy GK config entries');\n\t\t\tthis._migratedRepos.add(repoPath);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!migrateConfig.size) {\n\t\t\tthis._migratedRepos.add(repoPath);\n\t\t\treturn;\n\t\t}\n\n\t\tscope?.info(`Migrating ${String(migrateConfig.size)} GK config entries from git config to .git/gk/config`);\n\n\t\t// Copy legacy entries to .git/gk/config\n\t\tfor (const [key, value] of [...migrateConfig]) {\n\t\t\ttry {\n\t\t\t\tawait this._gkConfigWrites.run(gkConfigPath, undefined, () =>\n\t\t\t\t\tthis.setConfigCore(repoPath, key, value, { file: gkConfigPath }),\n\t\t\t\t);\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex, `Failed to migrate key '${key}' to GK config`);\n\t\t\t\t// If we failed to migrate, delete it from the list so we won't try to remove it from git config later\n\t\t\t\tmigrateConfig.delete(key);\n\t\t\t}\n\t\t}\n\n\t\t// Remove legacy keys from regular git config (use --unset-all defensively)\n\t\tfor (const [key] of migrateConfig) {\n\t\t\ttry {\n\t\t\t\tawait this.git.run(\n\t\t\t\t\t{ cwd: repoPath, errors: 'ignore', runLocally: true },\n\t\t\t\t\t'config',\n\t\t\t\t\t'--local',\n\t\t\t\t\t'--unset-all',\n\t\t\t\t\tkey,\n\t\t\t\t);\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex, `Failed to remove migrated key '${key}' from git config`);\n\t\t\t}\n\t\t}\n\n\t\t// Clear caches since we modified both config files\n\t\tthis.cache.clearCaches(repoPath, 'config', 'gkConfig');\n\n\t\tthis._migratedRepos.add(repoPath);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA6BA,MAAM,oBAAoB;AAC1B,MAAM,aAA+B,OAAO,OAAO,CAAC,CAAC;;AAGrD,MAAM,qBAAqB;;;;;;AAO3B,SAAgB,yBAAyB,KAAqB;CAC7D,MAAM,QAAQ,IAAI,QAAQ,GAAG;CAC7B,IAAI,UAAU,IAAI,OAAO,IAAI,YAAY;CAEzC,MAAM,OAAO,IAAI,YAAY,GAAG;CAGhC,IAAI,UAAU,MAAM,OAAO,IAAI,YAAY;CAC3C,OAAO,GAAG,IAAI,MAAM,GAAG,KAAK,CAAC,CAAC,YAAY,IAAI,IAAI,MAAM,OAAO,IAAI,IAAI,IAAI,MAAM,IAAI,CAAC,CAAC,YAAY;AACpG;;;;;;;;;;;;;;;;AAiBA,SAAgB,uBACf,MACA,SACsB;CACtB,MAAM,4BAAY,IAAI,IAAoB;CAC1C,IAAI,CAAC,MAAM,OAAO;CAElB,KAAK,MAAM,QAAQ,KAAK,MAAM,IAAI,GAAG;EACpC,IAAI,CAAC,MAAM;EAEX,MAAM,aAAa,KAAK,QAAQ,GAAG;EACnC,IAAI,eAAe,IAAI;GACtB,IAAI,SAAS,kBACZ,UAAU,IAAI,MAAM,MAAM;GAE3B;EACD;EAEA,UAAU,IAAI,KAAK,UAAU,GAAG,UAAU,GAAG,KAAK,UAAU,aAAa,CAAC,CAAC;CAC5E;CAEA,OAAO;AACR;AAEA,SAAgB,gBAAgB,OAAoC;CACnE,IAAI,SAAS,MAAM,OAAO;CAE1B,MAAM,aAAa,MAAM,YAAY,CAAC,CAAC,KAAK;CAC5C,OAA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mMN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,oBAAA,IAAA;AA+BN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,wBAAA,IAAA;AAaN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,oBAAA,IAAA;AA8ON,WAAA,CAAA,KAAK,GACL,MAAM,CAAA,GAAA,qBAAA,WAAA,gCAAA,IAAA"}
@@ -5,8 +5,8 @@ import { createDisposable } from "../../utils/disposable.js";
5
5
  import { isUncommittedStaged } from "../../git/utils/revision.utils.js";
6
6
  import __decorate from "../../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
7
7
  import { gitConfigsLog } from "../exec/git.js";
8
- import { isUserMatch } from "../../git/utils/user.utils.js";
9
8
  import _usingCtx from "../../_virtual/@oxc-project+runtime/helpers/esm/usingCtx.js";
9
+ import { isUserMatch } from "../../git/utils/user.utils.js";
10
10
  import { getContributorsLogParser } from "../parsers/logParser.js";
11
11
  import { GitContributor } from "../../git/models/contributor.js";
12
12
  import { calculateContributionScore } from "../../git/utils/contributor.utils.js";
@@ -6,12 +6,13 @@ import { debug } from "../../utils/decorators/log.js";
6
6
  import { createDisposable } from "../../utils/disposable.js";
7
7
  import { getBranchId, getBranchNameWithoutRemote, getRemoteNameFromBranchName } from "../../utils/gitRefs.js";
8
8
  import { isUncommitted } from "../../git/utils/revision.utils.js";
9
+ import { splitRemoteBranchName } from "../../git/utils/branch.utils.js";
9
10
  import __decorate from "../../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
10
11
  import { GitSearchError } from "../../git/errors.js";
11
12
  import { classifySearchError, gitConfigsLog } from "../exec/git.js";
13
+ import _usingCtx from "../../_virtual/@oxc-project+runtime/helpers/esm/usingCtx.js";
12
14
  import { fnv1aHash64 } from "../../utils/hash.js";
13
15
  import { isUserMatch } from "../../git/utils/user.utils.js";
14
- import _usingCtx from "../../_virtual/@oxc-project+runtime/helpers/esm/usingCtx.js";
15
16
  import { getSearchQueryComparisonKey, parseSearchQueryGitCommand } from "../../git/utils/search.utils.js";
16
17
  import { getGraphParser, getShaAndDatesLogParser, getShaAndDatesWithFilesLogParser, getShaAndStatsLogParser, getShaLogParser } from "../parsers/logParser.js";
17
18
  import { convertStashesToStdin } from "./stash.js";
@@ -239,8 +240,11 @@ var GraphGitSubProvider = class {
239
240
  const headBranch = branches?.find((b) => b.current);
240
241
  const headRefUpstreamName = headBranch?.upstream?.name;
241
242
  const [worktrees, worktreesByBranch] = getSettledValue(worktreesResult) ?? [[], /* @__PURE__ */ new Map()];
243
+ const remotes = getSettledValue(remotesResult);
244
+ const remoteMap = remotes != null ? new Map(remotes.map((r) => [r.name, r])) : /* @__PURE__ */ new Map();
245
+ const slashRemoteNames = [...remoteMap.keys()].filter((n) => n.includes("/"));
242
246
  const defaultBranchName = getSettledValue(defaultBranchResult);
243
- const defaultLocalName = defaultBranchName != null ? getBranchNameWithoutRemote(defaultBranchName) : void 0;
247
+ const defaultLocalName = defaultBranchName != null ? (slashRemoteNames.length ? splitRemoteBranchName(defaultBranchName, slashRemoteNames)?.[1] : void 0) ?? getBranchNameWithoutRemote(defaultBranchName) : void 0;
244
248
  let branchIdOfMainWorktree;
245
249
  let mainWorktree;
246
250
  if (worktreesByBranch != null) {
@@ -251,8 +255,6 @@ var GraphGitSubProvider = class {
251
255
  }
252
256
  }
253
257
  const currentUser = getSettledValue(currentUserResult);
254
- const remotes = getSettledValue(remotesResult);
255
- const remoteMap = remotes != null ? new Map(remotes.map((r) => [r.name, r])) : /* @__PURE__ */ new Map();
256
258
  const decorationFingerprint = computeDecorationFingerprint(repoPath, defaultBranchName, defaultLocalName, headRefUpstreamName, branches, remotes, worktrees, currentUser);
257
259
  const shas = getSettledValue(shaResult)?.stdout;
258
260
  const selectSha = shas != null ? first(shaParser.parse(shas)) : void 0;
@@ -361,11 +363,12 @@ var GraphGitSubProvider = class {
361
363
  sawHead = true;
362
364
  if (tip !== "HEAD") tip = tip.substring(8);
363
365
  }
364
- const remoteName = getRemoteNameFromBranchName(tip);
366
+ const slashRemote = slashRemoteNames.length ? splitRemoteBranchName(tip, slashRemoteNames) : void 0;
367
+ const remoteName = slashRemote?.[0] ?? getRemoteNameFromBranchName(tip);
365
368
  if (remoteName) {
366
369
  const remote = remoteMap.get(remoteName);
367
370
  if (remote != null) {
368
- const branchName = getBranchNameWithoutRemote(tip);
371
+ const branchName = slashRemote?.[1] ?? getBranchNameWithoutRemote(tip);
369
372
  if (branchName === "HEAD") continue;
370
373
  refRemoteHeads.push({
371
374
  id: getBranchId(repoPath, true, tip),