@gitkraken/core-gitlens 0.37.1 → 0.38.1

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 (116) hide show
  1. package/CHANGELOG.md +69 -1
  2. package/dist/git/cache.d.ts +128 -8
  3. package/dist/git/cache.js +425 -46
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/features.d.ts +1 -1
  6. package/dist/git/features.js +3 -0
  7. package/dist/git/features.js.map +1 -1
  8. package/dist/git/providers/branches.d.ts +42 -1
  9. package/dist/git/providers/diff.d.ts +17 -0
  10. package/dist/git/providers/provider.d.ts +7 -0
  11. package/dist/git/providers/shared/remotes.js +8 -4
  12. package/dist/git/providers/shared/remotes.js.map +1 -1
  13. package/dist/git/remotes/matcher.js +2 -2
  14. package/dist/git/remotes/matcher.js.map +1 -1
  15. package/dist/git/repositoryService.d.ts +16 -1
  16. package/dist/git/repositoryService.js +51 -3
  17. package/dist/git/repositoryService.js.map +1 -1
  18. package/dist/git/run.types.d.ts +1 -0
  19. package/dist/git/service.js +6 -2
  20. package/dist/git/service.js.map +1 -1
  21. package/dist/git/utils/fileStatus.utils.d.ts +5 -0
  22. package/dist/git/utils/fileStatus.utils.js +18 -1
  23. package/dist/git/utils/fileStatus.utils.js.map +1 -1
  24. package/dist/git/watching/changeEvent.d.ts +13 -3
  25. package/dist/git/watching/changeEvent.js +15 -4
  26. package/dist/git/watching/changeEvent.js.map +1 -1
  27. package/dist/git/watching/changeOrdinal.d.ts +9 -0
  28. package/dist/git/watching/changeOrdinal.js +14 -0
  29. package/dist/git/watching/changeOrdinal.js.map +1 -0
  30. package/dist/git/watching/unwatchedCacheValidator.d.ts +38 -5
  31. package/dist/git/watching/unwatchedCacheValidator.js +180 -36
  32. package/dist/git/watching/unwatchedCacheValidator.js.map +1 -1
  33. package/dist/git/watching/watchGroup.d.ts +63 -14
  34. package/dist/git/watching/watchGroup.js +213 -74
  35. package/dist/git/watching/watchGroup.js.map +1 -1
  36. package/dist/git/watching/watchService.js +4 -3
  37. package/dist/git/watching/watchService.js.map +1 -1
  38. package/dist/git/watching/watchSession.d.ts +10 -2
  39. package/dist/git/watching/watchSession.js +18 -4
  40. package/dist/git/watching/watchSession.js.map +1 -1
  41. package/dist/git/watching/watcherPatterns.d.ts +18 -4
  42. package/dist/git/watching/watcherPatterns.js +39 -8
  43. package/dist/git/watching/watcherPatterns.js.map +1 -1
  44. package/dist/git/watching/worktreeSummary.d.ts +23 -12
  45. package/dist/git/watching/worktreeSummary.js +164 -41
  46. package/dist/git/watching/worktreeSummary.js.map +1 -1
  47. package/dist/git-cli/cliGitProvider.d.ts +1 -0
  48. package/dist/git-cli/cliGitProvider.js +11 -2
  49. package/dist/git-cli/cliGitProvider.js.map +1 -1
  50. package/dist/git-cli/exec/git.d.ts +7 -2
  51. package/dist/git-cli/exec/git.js +46 -10
  52. package/dist/git-cli/exec/git.js.map +1 -1
  53. package/dist/git-cli/exec/headState.d.ts +24 -0
  54. package/dist/git-cli/exec/headState.js +46 -6
  55. package/dist/git-cli/exec/headState.js.map +1 -1
  56. package/dist/git-cli/parsers/logParser.js +6 -3
  57. package/dist/git-cli/parsers/logParser.js.map +1 -1
  58. package/dist/git-cli/providers/branches.d.ts +135 -10
  59. package/dist/git-cli/providers/branches.js +622 -80
  60. package/dist/git-cli/providers/branches.js.map +1 -1
  61. package/dist/git-cli/providers/commits.d.ts +16 -0
  62. package/dist/git-cli/providers/commits.js +80 -28
  63. package/dist/git-cli/providers/commits.js.map +1 -1
  64. package/dist/git-cli/providers/config.d.ts +10 -0
  65. package/dist/git-cli/providers/config.js +50 -12
  66. package/dist/git-cli/providers/config.js.map +1 -1
  67. package/dist/git-cli/providers/contributors.js +11 -7
  68. package/dist/git-cli/providers/contributors.js.map +1 -1
  69. package/dist/git-cli/providers/diff.d.ts +12 -0
  70. package/dist/git-cli/providers/diff.js +107 -15
  71. package/dist/git-cli/providers/diff.js.map +1 -1
  72. package/dist/git-cli/providers/graph.js +32 -25
  73. package/dist/git-cli/providers/graph.js.map +1 -1
  74. package/dist/git-cli/providers/operations.d.ts +37 -3
  75. package/dist/git-cli/providers/operations.js +124 -46
  76. package/dist/git-cli/providers/operations.js.map +1 -1
  77. package/dist/git-cli/providers/patch.js +1 -1
  78. package/dist/git-cli/providers/patch.js.map +1 -1
  79. package/dist/git-cli/providers/refs.d.ts +1 -1
  80. package/dist/git-cli/providers/refs.js +10 -11
  81. package/dist/git-cli/providers/refs.js.map +1 -1
  82. package/dist/git-cli/providers/status.d.ts +4 -5
  83. package/dist/git-cli/providers/status.js +36 -33
  84. package/dist/git-cli/providers/status.js.map +1 -1
  85. package/dist/git-cli/providers/tags.d.ts +8 -0
  86. package/dist/git-cli/providers/tags.js +53 -34
  87. package/dist/git-cli/providers/tags.js.map +1 -1
  88. package/dist/git-cli/service.d.ts +15 -0
  89. package/dist/git-cli/service.js +19 -1
  90. package/dist/git-cli/service.js.map +1 -1
  91. package/dist/plus/git-github/providers/github/diff.d.ts +1 -0
  92. package/dist/plus/git-github/providers/github/diff.js +6 -1
  93. package/dist/plus/git-github/providers/github/diff.js.map +1 -1
  94. package/dist/plus/integrations/integrationService.js +9 -0
  95. package/dist/plus/integrations/integrationService.js.map +1 -1
  96. package/dist/plus/integrations/providers/jira-server.js +1 -1
  97. package/dist/plus/integrations/providers/jira-server.js.map +1 -1
  98. package/dist/plus/integrations/providers/jira.d.ts +20 -9
  99. package/dist/plus/integrations/providers/jira.js +114 -99
  100. package/dist/plus/integrations/providers/jira.js.map +1 -1
  101. package/dist/plus/integrations/providers/linear.d.ts +11 -4
  102. package/dist/plus/integrations/providers/linear.js +75 -32
  103. package/dist/plus/integrations/providers/linear.js.map +1 -1
  104. package/dist/plus/integrations/providers/utils/discoveryCache.d.ts +35 -4
  105. package/dist/plus/integrations/providers/utils/discoveryCache.js +45 -11
  106. package/dist/plus/integrations/providers/utils/discoveryCache.js.map +1 -1
  107. package/dist/utils/env/node/exec.d.ts +8 -4
  108. package/dist/utils/env/node/exec.js +115 -9
  109. package/dist/utils/env/node/exec.js.map +1 -1
  110. package/dist/utils/holdOffMap.d.ts +23 -0
  111. package/dist/utils/holdOffMap.js +43 -0
  112. package/dist/utils/holdOffMap.js.map +1 -0
  113. package/dist/utils/promiseCache.d.ts +15 -2
  114. package/dist/utils/promiseCache.js +34 -4
  115. package/dist/utils/promiseCache.js.map +1 -1
  116. package/package.json +1 -1
@@ -25,6 +25,21 @@ const validationWindowMs = 250;
25
25
  const unresolvableRetryMs = 3e4;
26
26
  /** Targets kept per kind; one dropped just takes a new baseline */
27
27
  const maxTargets = 512;
28
+ /**
29
+ * Other worktrees' first baselines one validation takes with its own. Their stats run one at a time per repository
30
+ * inside the read that triggered them, so the batch is kept small enough that a slow file system doesn't push that read
31
+ * past its timeout; the worktrees left out batch the rest at their own first validation. Never more than fit under
32
+ * {@link maxTargets}, as a target dropped for them would clear the shared entries again
33
+ */
34
+ const maxSiblingBaselines = 64;
35
+ /**
36
+ * Linked worktrees' first baselines one validation clears only their own entries for, when the common git dir vouches
37
+ * for each one's HEAD; past it, they clear the shared entries too, once. Clearing the shared entries costs a ref listing,
38
+ * a default branch read and the reader's current branch, and that listing seeds every worktree's current branch again;
39
+ * clearing a worktree's own entries costs it a read of its own current branch. So past a few worktrees, one clear of the
40
+ * shared entries is the cheaper
41
+ */
42
+ const maxOwnBaselines = 3;
28
43
  /** Polls one validation runs to take the baselines of the directories it finds; the next validation resumes from there */
29
44
  const maxDiscoveryPolls = 16;
30
45
  /**
@@ -110,7 +125,8 @@ const commonGatedProbes = commonProbes.filter((p) => commonGatedPaths.has(p.path
110
125
  * files a watcher would have reported (see {@link UnwatchedCacheValidatorOptions.stat}) and applies what moved to the
111
126
  * cache as a watcher event would have. Both a worktree's own git dir and the common one are validated while that
112
127
  * worktree is unwatched; while another worktree's watcher covers the common one, what moved there clears only the
113
- * unwatched worktrees' own entries. A repository whose git dir nothing resolved yet is validated once
128
+ * unwatched worktrees' own entries, but for a linked worktree's HEAD moving, which is applied as that worktree's own
129
+ * report would be (see {@link apply}). A repository whose git dir nothing resolved yet is validated once
114
130
  * {@link UnwatchedCacheValidatorOptions.resolveGitDir} resolves one; a repository whose files can't show it is looked at
115
131
  * again rarely, and one whose resolution failed within the validation window. A read waits at most
116
132
  * {@link UnwatchedCacheValidatorOptions.timeoutMs} for a validation (and a resolution before it); one that outlasts it
@@ -144,7 +160,10 @@ var UnwatchedCacheValidator = class {
144
160
  resolutions = /* @__PURE__ */ new Map();
145
161
  /** The validation {@link onWatched} ran as a watcher attached, by repo path, which reads wait for while it runs */
146
162
  handoffs = /* @__PURE__ */ new Map();
147
- /** By the repo path of a watched worktree, what moved in its common git dir that its watcher was left to clear */
163
+ /**
164
+ * By the repo path of a watched worktree, what moved in its common git dir that its watcher was left to clear, and
165
+ * whether its own HEAD's move, which the common git dir saw, was left to it to report (see {@link applyMovedHeads})
166
+ */
148
167
  deferred = /* @__PURE__ */ new Map();
149
168
  constructor(options) {
150
169
  this.cache = options.cache;
@@ -219,15 +238,22 @@ var UnwatchedCacheValidator = class {
219
238
  }
220
239
  /**
221
240
  * A watcher left `repoPath`, dropping what it held back unreported. What moved in its common git dir that an
222
- * unwatched sibling's validation left to it is applied now, since that validation took the shared baseline past it;
223
- * whatever else it dropped is still ahead of its own baselines.
241
+ * unwatched sibling's validation left to it is applied now, since that validation took the shared baseline past it,
242
+ * and so is its own HEAD's move that the common git dir saw, as its watcher would have reported it; whatever else it
243
+ * dropped is still ahead of its own baselines.
224
244
  */
225
245
  onUnwatched(repoPath) {
226
246
  const deferred = this.deferred.get(repoPath);
227
247
  if (deferred == null) return;
228
248
  this.deferred.delete(repoPath);
229
- this.cache.onRepositoryChanged(deferred.commonPath, deferred.changes);
230
- if (repoPath !== deferred.commonPath && this.cache.isRegistered(repoPath)) this.cache.applyRepositoryChanges(repoPath, deferred.changes, "share", { worktreeOnly: true });
249
+ if (deferred.changes.size) {
250
+ this.cache.onRepositoryChanged(deferred.commonPath, deferred.changes);
251
+ if (repoPath !== deferred.commonPath && this.cache.isRegistered(repoPath)) this.cache.applyRepositoryChanges(repoPath, deferred.changes, "share", { worktreeOnly: true });
252
+ }
253
+ if (deferred.headMoved) {
254
+ const registered = this.cache.getCommonPath(repoPath) === deferred.commonPath;
255
+ this.cache.onRepositoryChanged(registered ? repoPath : deferred.commonPath, ["head", "heads"]);
256
+ }
231
257
  }
232
258
  run(repoPath, force) {
233
259
  if (!force && this.isWatched(repoPath)) return void 0;
@@ -243,6 +269,7 @@ var UnwatchedCacheValidator = class {
243
269
  for (const [path, deferred] of this.deferred) if (deferred.commonPath === commonPath && !this.isWatched(path)) this.onUnwatched(path);
244
270
  const commonGitDir = (gitDir.commonUri ?? gitDir.uri).fsPath;
245
271
  const root = this.getTarget(this.roots, repoPath, "root", gitDir.uri.fsPath, commonPath, commonGitDir);
272
+ const siblings = root.runs === 0 ? this.getSiblingTargets(repoPath, commonPath, commonGitDir) : [];
246
273
  const common = this.getTarget(this.commons, commonPath, "common", commonGitDir, commonPath, commonGitDir);
247
274
  const waits = [];
248
275
  const previous = [];
@@ -263,10 +290,15 @@ var UnwatchedCacheValidator = class {
263
290
  const startedRoot = start(root);
264
291
  const startedCommon = start(common);
265
292
  if (startedRoot != null || startedCommon != null) {
266
- const job = this.runTargets(repoPath, commonPath, startedRoot, startedCommon, previous);
293
+ const job = this.runTargets(repoPath, commonPath, startedRoot, startedCommon, common, siblings, previous);
267
294
  if (startedRoot != null) startedRoot.running = job;
268
295
  if (startedCommon != null) startedCommon.running = job;
269
- for (const state of [startedRoot, startedCommon]) if (state != null) waits.push([state, job]);
296
+ for (const [, state] of siblings) state.running = job;
297
+ for (const state of [
298
+ startedRoot,
299
+ startedCommon,
300
+ ...siblings.map(([, s]) => s)
301
+ ]) if (state != null) waits.push([state, job]);
270
302
  }
271
303
  return waits;
272
304
  }
@@ -371,18 +403,46 @@ var UnwatchedCacheValidator = class {
371
403
  }
372
404
  return state;
373
405
  }
374
- async runTargets(repoPath, commonPath, root, common, previous) {
406
+ /**
407
+ * The root targets, new, of `repoPath`'s registered sibling worktrees that never had one: unwatched (a watcher covers
408
+ * its own git dir, and validates it as it attaches), with a git dir the cache resolved in the same common git dir
409
+ */
410
+ getSiblingTargets(repoPath, commonPath, commonGitDir) {
411
+ const siblings = [];
412
+ const room = Math.min(maxSiblingBaselines, maxTargets - this.roots.size);
413
+ for (const path of this.cache.getWorktreePaths(commonPath)) {
414
+ if (siblings.length >= room) break;
415
+ if (path === repoPath || this.roots.has(path) || this.isWatched(path)) continue;
416
+ if (this.cache.getCommonPath(path) !== commonPath) continue;
417
+ const gitDir = this.cache.gitDir.get(path);
418
+ if (gitDir == null || (gitDir.commonUri ?? gitDir.uri).fsPath !== commonGitDir) continue;
419
+ siblings.push([path, this.getTarget(this.roots, path, "root", gitDir.uri.fsPath, commonPath, commonGitDir)]);
420
+ }
421
+ return siblings;
422
+ }
423
+ async runTargets(repoPath, commonPath, root, common, commonTarget, siblings, previous) {
375
424
  const rootRun = root != null ? ++root.runs : 0;
376
425
  const commonRun = common != null ? ++common.runs : 0;
426
+ const siblingRuns = siblings.map(([, state]) => ++state.runs);
377
427
  const watchedAtStart = new Set(this.getCommonWatchers(repoPath, commonPath));
378
428
  try {
379
429
  if (previous.length) await Promise.all(previous);
380
430
  const memo = /* @__PURE__ */ new Map();
381
- const [rootResult, commonResult] = await Promise.all([root?.dir.validate(memo, repoPath), common?.dir.validate(memo, repoPath)]);
431
+ const [rootResult, commonResult, siblingResults] = await Promise.all([
432
+ root?.dir.validate(memo, repoPath),
433
+ common?.dir.validate(memo, repoPath),
434
+ Promise.all(siblings.map(([path, state]) => state.dir.validate(memo, path)))
435
+ ]);
382
436
  this.counts.validations++;
383
437
  if (rootResult?.changes.size || commonResult?.changes.size) this.counts.validationsApplied++;
384
- this.apply(repoPath, commonPath, rootResult, commonResult, watchedAtStart);
385
- } catch {} finally {
438
+ this.apply(repoPath, commonPath, rootResult, commonResult, commonTarget.dir, siblings.map(([path, state], i) => [
439
+ path,
440
+ state,
441
+ siblingResults[i]
442
+ ]), watchedAtStart);
443
+ } catch {
444
+ for (const [, state] of siblings) state.dir.reset();
445
+ } finally {
386
446
  const settledAt = this.now();
387
447
  if (root != null) {
388
448
  root.settledAt = settledAt;
@@ -392,32 +452,47 @@ var UnwatchedCacheValidator = class {
392
452
  common.settledAt = settledAt;
393
453
  if (common.runs === commonRun) common.running = void 0;
394
454
  }
455
+ for (const [i, [, state]] of siblings.entries()) if (state.runs === siblingRuns[i]) state.running = void 0;
395
456
  }
396
457
  }
397
458
  /**
398
459
  * Applies what moved to `repoPath`, and what moved in the common git dir to its other unwatched registered worktrees
399
460
  * too, as the common watcher would have told each of them. While another worktree's watcher covers the common git
400
461
  * dir, it already cleared the shared entries, so only the worktrees' own are. A watcher covers it only if it watched
401
- * since before the stats began (`watchedAtStart`)
462
+ * since before the stats began (`watchedAtStart`). What each sibling whose first baseline was taken with it reports
463
+ * clears that sibling's own entries, as `repoPath`'s report cleared the shared ones.
464
+ *
465
+ * Once the common git dir (`commonDir`) holds a reading of a linked worktree's HEAD, it reports that HEAD's every
466
+ * move, and a commit on its branch as a ref directory moving. Each such move clears the shared entries, as that
467
+ * worktree's own report would (see {@link applyMovedHeads}), or is left to its watcher, which reports it or has it
468
+ * applied as it leaves. So nothing the shared entries hold of that worktree can go stale unseen: its first report (or
469
+ * its first after a reset) clears only its own entries, for up to {@link maxOwnBaselines} of them
402
470
  */
403
- apply(repoPath, commonPath, root, common, watchedAtStart) {
471
+ apply(repoPath, commonPath, root, common, commonDir, siblings, watchedAtStart) {
404
472
  const watchers = this.getCommonWatchers(repoPath, commonPath).filter((p) => watchedAtStart.has(p));
405
473
  const commonWatched = watchers.length !== 0;
406
- const changes = new Set(root?.changes);
474
+ const own = this.getVouchedBaselines(repoPath, commonPath, root, commonDir, siblings);
475
+ if (common?.noBaseline || own.size > maxOwnBaselines) own.clear();
476
+ const changes = new Set(own.has(repoPath) ? void 0 : root?.changes);
407
477
  if (!commonWatched) for (const change of common?.changes ?? []) changes.add(change);
478
+ if (root != null && own.has(repoPath)) this.cache.applyLinkedWorktreeChanges(repoPath, root.changes, "share");
408
479
  if (changes.size) this.cache.onRepositoryChanged(repoPath, changes, { movedWorktrees: changes.has("worktreeHead") ? common?.movedWorktrees : void 0 });
480
+ this.applyMovedHeads(repoPath, commonPath, common, watchers, changes.has("head"));
481
+ const shared = this.cache.getCommonPath(repoPath) === commonPath;
482
+ for (const [path, state, result] of siblings) {
483
+ if (!this.cache.isRegistered(path) || this.cache.getCommonPath(path) !== commonPath) {
484
+ state.dir.reset();
485
+ continue;
486
+ }
487
+ if (own.has(path)) this.cache.applyLinkedWorktreeChanges(path, result.changes, "share");
488
+ else if (shared && [...result.changes].every((c) => changes.has(c))) this.cache.applyRepositoryChanges(path, result.changes, "share", { worktreeOnly: true });
489
+ else this.cache.onRepositoryChanged(path, result.changes);
490
+ }
409
491
  if (!common?.changes.size) return;
410
492
  if (commonWatched) {
411
493
  this.cache.applyRepositoryChanges(repoPath, common.changes, "share", { worktreeOnly: true });
412
494
  for (const path of watchers) {
413
- let deferred = this.deferred.get(path);
414
- if (deferred?.commonPath !== commonPath) {
415
- deferred = {
416
- commonPath,
417
- changes: /* @__PURE__ */ new Set()
418
- };
419
- this.deferred.set(path, deferred);
420
- }
495
+ const deferred = this.getDeferred(path, commonPath);
421
496
  for (const change of common.changes) deferred.changes.add(change);
422
497
  }
423
498
  }
@@ -426,6 +501,61 @@ var UnwatchedCacheValidator = class {
426
501
  this.cache.applyRepositoryChanges(path, common.changes, "share", { worktreeOnly: true });
427
502
  }
428
503
  }
504
+ /** What is left to the watcher of `path` until it leaves (see {@link onUnwatched}) */
505
+ getDeferred(path, commonPath) {
506
+ let deferred = this.deferred.get(path);
507
+ if (deferred?.commonPath !== commonPath) {
508
+ deferred = {
509
+ commonPath,
510
+ changes: /* @__PURE__ */ new Set(),
511
+ headMoved: false
512
+ };
513
+ this.deferred.set(path, deferred);
514
+ }
515
+ return deferred;
516
+ }
517
+ /**
518
+ * The worktrees, of `repoPath` and the `siblings`, whose report without a baseline the common git dir vouches for as
519
+ * of now: each a linked worktree registered under `commonPath` whose HEAD `commonDir` holds a reading of
520
+ */
521
+ getVouchedBaselines(repoPath, commonPath, root, commonDir, siblings) {
522
+ const vouched = (path) => {
523
+ if (this.cache.getCommonPath(path) !== commonPath) return false;
524
+ const id = this.cache.getLinkedWorktreeId(path);
525
+ return id != null && commonDir.holdsWorktreeHead(id);
526
+ };
527
+ const paths = /* @__PURE__ */ new Set();
528
+ if (root?.noBaseline && vouched(repoPath)) paths.add(repoPath);
529
+ for (const [path, , result] of siblings) if (result.noBaseline && vouched(path)) paths.add(path);
530
+ return paths;
531
+ }
532
+ /**
533
+ * Applies the common git dir's sighting of linked worktrees' HEADs moving as each worktree's own report would be:
534
+ * the shared entries hold each one's HEAD too (where the branch list places its branch, what a checkout's reflog
535
+ * says a branch was based on), which a `'worktreeHead'` clears nothing of. One whose own watcher covered the common
536
+ * git dir reports it itself, or, should that watcher leave first, has it applied as it leaves. A move not attributed to a registered worktree is applied to `repoPath`, as is a report
537
+ * without a baseline (whose shared entries a watcher of the common git dir cleared, if not `repoPath`'s report),
538
+ * unless what `repoPath`'s report applied in full saw its own HEAD move (`appliedHead`)
539
+ */
540
+ applyMovedHeads(repoPath, commonPath, common, watchers, appliedHead) {
541
+ if (common == null) return;
542
+ const paths = /* @__PURE__ */ new Set();
543
+ if (common.noBaseline || common.changes.has("worktreeHead") && common.movedWorktrees == null) paths.add(repoPath);
544
+ else if (common.changes.has("worktreeHead")) {
545
+ const pathsById = /* @__PURE__ */ new Map();
546
+ for (const path of this.cache.getWorktreePaths(commonPath)) {
547
+ const id = this.cache.getLinkedWorktreeId(path);
548
+ if (id != null) pathsById.set(id, path);
549
+ }
550
+ for (const id of common.movedWorktrees ?? []) {
551
+ const path = pathsById.get(id) ?? repoPath;
552
+ if (watchers.includes(path)) this.getDeferred(path, commonPath).headMoved = true;
553
+ else paths.add(path);
554
+ }
555
+ }
556
+ if (appliedHead) paths.delete(repoPath);
557
+ for (const path of paths) this.cache.onRepositoryChanged(path, ["head", "heads"]);
558
+ }
429
559
  };
430
560
  /**
431
561
  * Runs file-system calls at most {@link maxFsCalls} at once, and at most {@link maxFsCallsPerRepo} at once for a key;
@@ -594,24 +724,37 @@ var ProbedGitDir = class {
594
724
  this.ignoredRoots = void 0;
595
725
  }
596
726
  if (failed || !this.baselined) {
597
- if (failed) {
598
- this.target = this.createTarget(() => this.getProbes());
599
- this.gated.clear();
600
- this.addGated(gitDirGatePath, this.kind === "root" ? rootGatedProbes : commonGatedProbes);
601
- this.baselined = false;
602
- this.refDirs.clear();
603
- this.worktrees.clear();
604
- this.pendingDirs.clear();
605
- this.pendingEntries.clear();
606
- this.reftable = false;
607
- } else this.baselined = true;
727
+ if (failed) this.reset();
728
+ else this.baselined = true;
608
729
  return {
609
730
  changes: new Set(this.kind === "root" ? rootReportableChanges : allWatchedRepositoryChanges),
610
- movedWorktrees: void 0
731
+ movedWorktrees: void 0,
732
+ noBaseline: true
611
733
  };
612
734
  }
613
735
  return this.classify();
614
736
  }
737
+ /**
738
+ * Whether it holds a reading of the HEAD of the linked worktree with the admin id `id`, so it reports that HEAD's
739
+ * every move from here on: a common git dir with a baseline, probing that worktree's admin entry (not ignored), whose
740
+ * files it read behind it
741
+ */
742
+ holdsWorktreeHead(id) {
743
+ if (this.kind !== "common" || !this.baselined || this.worktrees.get(id)?.ignored !== false) return false;
744
+ return this.gated.get(`worktrees/${id}`)?.read === true;
745
+ }
746
+ /** Drops every reading, so the next validation has no baseline and reports everything it can */
747
+ reset() {
748
+ this.target = this.createTarget(() => this.getProbes());
749
+ this.gated.clear();
750
+ this.addGated(gitDirGatePath, this.kind === "root" ? rootGatedProbes : commonGatedProbes);
751
+ this.baselined = false;
752
+ this.refDirs.clear();
753
+ this.worktrees.clear();
754
+ this.pendingDirs.clear();
755
+ this.pendingEntries.clear();
756
+ this.reftable = false;
757
+ }
615
758
  createTarget(getProbes) {
616
759
  return new GitDirProbeTarget(this.basePath, {
617
760
  stat: (path) => this.stat(path),
@@ -863,7 +1006,8 @@ var ProbedGitDir = class {
863
1006
  }
864
1007
  return {
865
1008
  changes,
866
- movedWorktrees: anyWorktreeMoved ? void 0 : movedWorktrees
1009
+ movedWorktrees: anyWorktreeMoved ? void 0 : movedWorktrees,
1010
+ noBaseline: false
867
1011
  };
868
1012
  }
869
1013
  };