@gitkraken/core-gitlens 0.37.1 → 0.38.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 (118) hide show
  1. package/CHANGELOG.md +60 -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/issueSorts.d.ts +1 -0
  97. package/dist/plus/integrations/providers/jira-server.js +1 -1
  98. package/dist/plus/integrations/providers/jira-server.js.map +1 -1
  99. package/dist/plus/integrations/providers/jira.d.ts +38 -6
  100. package/dist/plus/integrations/providers/jira.js +111 -69
  101. package/dist/plus/integrations/providers/jira.js.map +1 -1
  102. package/dist/plus/integrations/providers/linear.d.ts +31 -3
  103. package/dist/plus/integrations/providers/linear.js +77 -18
  104. package/dist/plus/integrations/providers/linear.js.map +1 -1
  105. package/dist/plus/integrations/providers/utils/discoveryCache.d.ts +41 -4
  106. package/dist/plus/integrations/providers/utils/discoveryCache.js +50 -11
  107. package/dist/plus/integrations/providers/utils/discoveryCache.js.map +1 -1
  108. package/dist/plus/integrations/reads/drains.d.ts +1 -0
  109. package/dist/utils/env/node/exec.d.ts +5 -4
  110. package/dist/utils/env/node/exec.js +52 -9
  111. package/dist/utils/env/node/exec.js.map +1 -1
  112. package/dist/utils/holdOffMap.d.ts +23 -0
  113. package/dist/utils/holdOffMap.js +43 -0
  114. package/dist/utils/holdOffMap.js.map +1 -0
  115. package/dist/utils/promiseCache.d.ts +15 -2
  116. package/dist/utils/promiseCache.js +34 -4
  117. package/dist/utils/promiseCache.js.map +1 -1
  118. package/package.json +1 -1
@@ -55,7 +55,8 @@ export declare class OperationsGitSubProvider implements GitOperationsSubProvide
55
55
  * Writes the missing `refs/remotes/<remote>/HEAD` (the default branch the base reads) of each remote a fetch just
56
56
  * read with its configured refspecs, once per remote, on git < 2.48 — newer git's fetch creates it itself. A bare
57
57
  * fetch/pull reads every remote when `fetch.all` is set (git 2.44+), else its default remote. Right after the
58
- * fetch, so the credentials it used are still cached. Never awaited; never rejects, failures not retried.
58
+ * fetch, so the credentials it used are still cached. Never awaited; never rejects. A write that fails is not
59
+ * retried, but a config read that fails marks nothing, so a later fetch tries again.
59
60
  */
60
61
  private followRemoteHeads;
61
62
  /**
@@ -69,7 +70,8 @@ export declare class OperationsGitSubProvider implements GitOperationsSubProvide
69
70
  * explicit refspecs still updates opportunistically, and which may store into local branches, as a mirror's do),
70
71
  * and tags. A `remote` with no refspecs of its own may be a remote group (`remotes.<group>`), which fetches each of
71
72
  * its remotes, so every remote's destinations stand for it. When the configuration can't be read, all local and
72
- * remote-tracking branches stand for the configured destinations.
73
+ * remote-tracking branches stand for the configured destinations. `alsoMoves` are the refs the write may move
74
+ * besides what its fetch stores (a pull's merge or rebase moves local branches).
73
75
  */
74
76
  private getFetchSnapshotPatterns;
75
77
  /**
@@ -80,10 +82,17 @@ export declare class OperationsGitSubProvider implements GitOperationsSubProvide
80
82
  * announcement can name (`refs/notes/*`), the kinds it did see, together with `fallback()`'s, unnamed.
81
83
  */
82
84
  private announceFetch;
85
+ /**
86
+ * What moved since `snapshot` was taken, read again now, or `undefined` when either read is missing, so any ref it
87
+ * covers may have moved. Never rejects.
88
+ */
89
+ private getMovedRefsSince;
83
90
  /**
84
91
  * Each ref under `patterns` (for-each-ref patterns) with its object and, for a symbolic ref, its target (a remote's
85
92
  * `HEAD` can move to another branch at the same commit), or `undefined` when git couldn't answer. A read, so it
86
- * announces nothing.
93
+ * announces nothing. `correlationKey` keeps it from joining an identical listing already in flight.
94
+ * `cancellation` is for a read before a write, which a cancelled caller no longer waits for; the one after it is
95
+ * never cancelled, since the write still announces.
87
96
  */
88
97
  private snapshotRefs;
89
98
  /** `remotes`, plus `heads`/`tags` for any local branch or tag the fetch writes — a `pull` fetch writes `<upstream>:<branch>` */
@@ -102,6 +111,31 @@ export declare class OperationsGitSubProvider implements GitOperationsSubProvide
102
111
  tags?: boolean;
103
112
  source?: unknown;
104
113
  }, runOptions?: GitOperationRunOptions): Promise<void>;
114
+ /**
115
+ * A snapshot of every ref a `git pull` run in `repoPath` may move: what its fetch may store, from whichever remote a
116
+ * bare fetch reads (see {@link getFetchSnapshotPatterns}), every local branch, as its merge or rebase moves HEAD's
117
+ * branch, and a rebase that updates refs (`rebase.updateRefs`) moves others, and the stash, which keeps the
118
+ * autostashed changes when restoring them conflicts. Taken together with `repoPath`'s HEAD, which a pull may detach
119
+ * or rewrite (see {@link getPullMoved}), the two reads concurrently.
120
+ */
121
+ private snapshotPullState;
122
+ /**
123
+ * What a pull run in `repoPath` moved, and how it left HEAD, read again now: its refs against `snapshot`, its HEAD
124
+ * against `headBefore` (see {@link getHeadWrite}). Never rejects.
125
+ */
126
+ private getPullMoved;
127
+ /**
128
+ * Announces a pull's HEAD and index, and the refs it moved (see {@link getMovedRefsSince}): each ref kind only when a
129
+ * ref of it moved, named, so a sibling worktree that follows none of them skips its refresh. When `moved` is
130
+ * missing, or holds a ref no announcement can name, local and remote-tracking branches are announced unnamed, as if
131
+ * any of them may have moved, with tags and the stash beside them when one moved. `detached` says the pull left
132
+ * `repoPath`'s HEAD off the branch it was on (a rebase stopped partway), which every worktree's list of where each
133
+ * branch is checked out shows, so `worktrees` and `worktreeHead` are announced with it, as for a checkout. `rewrote`
134
+ * says the pull rewrote the HEAD file and put it back on its branch (a rebase that replayed commits detaches it,
135
+ * then points it back), which every other worktree's watcher reports as `worktreeHead`, so the kinds are announced
136
+ * for them to take the report for the pull's own. The list's placement of the branch is unchanged, so it is not
137
+ * reset.
138
+ */
105
139
  private announcePull;
106
140
  private pullCore;
107
141
  push(repoPath: string, options?: {
@@ -1,4 +1,5 @@
1
1
  import { chunkByStringLength } from "../../utils/iterable.js";
2
+ import { getScopedCounter } from "../../utils/counter.js";
2
3
  import { Logger as _logger } from "../../utils/logger.js";
3
4
  import { getScopedLogger } from "../../utils/logger.scoped.js";
4
5
  import { debug } from "../../utils/decorators/log.js";
@@ -8,7 +9,7 @@ import __decorate from "../../_virtual/@oxc-project+runtime/helpers/esm/decorate
8
9
  import { CheckoutError, CherryPickError, CommitError, FetchError, MergeError, PullError, PushError, RebaseError, ResetError, RevertError, SigningError } from "../../git/errors.js";
9
10
  import { getRefChangeKind } from "../../git/watching/changeEvent.js";
10
11
  import { mayWriteTracking } from "../exec/commandClassifier.js";
11
- import { getMovedHead, readHeadState } from "../exec/headState.js";
12
+ import { getHeadWrite, getMovedHead, readHeadSnapshot, readHeadState } from "../exec/headState.js";
12
13
  import { GitErrors, classifySigningError, getGitCommandError, gitConfigsPull, inferSigningFormatFromError, isRunHookFailure, maxGitCliLength } from "../exec/git.js";
13
14
  import { refreshIndexAfter } from "../exec/indexRefresh.js";
14
15
  import { resolveBranchRemote } from "./branchRemote.js";
@@ -23,6 +24,19 @@ const fetchRefChangeKinds = [
23
24
  "tags",
24
25
  "stash"
25
26
  ];
27
+ /** The kinds a pull announces, in order: `head` and `index` always, each ref kind when a ref of it may have moved */
28
+ const pullChanges = [
29
+ "head",
30
+ "heads",
31
+ "remotes",
32
+ "tags",
33
+ "stash",
34
+ "index"
35
+ ];
36
+ /** The kinds a write that detaches or rewrites a worktree's HEAD file announces for every other worktree's watcher to take */
37
+ const worktreeHeadChanges = ["worktrees", "worktreeHead"];
38
+ /** Keys each listing taken after a write apart, so it never joins an identical listing started before the write */
39
+ const afterWriteListingCounter = getScopedCounter();
26
40
  /** The destinations a fetch's snapshot covers when the remotes' configured refspecs can't be read */
27
41
  const broadFetchDestinations = ["refs/heads", "refs/remotes"];
28
42
  /**
@@ -233,7 +247,8 @@ var OperationsGitSubProvider = class {
233
247
  * Writes the missing `refs/remotes/<remote>/HEAD` (the default branch the base reads) of each remote a fetch just
234
248
  * read with its configured refspecs, once per remote, on git < 2.48 — newer git's fetch creates it itself. A bare
235
249
  * fetch/pull reads every remote when `fetch.all` is set (git 2.44+), else its default remote. Right after the
236
- * fetch, so the credentials it used are still cached. Never awaited; never rejects, failures not retried.
250
+ * fetch, so the credentials it used are still cached. Never awaited; never rejects. A write that fails is not
251
+ * retried, but a config read that fails marks nothing, so a later fetch tries again.
237
252
  */
238
253
  async followRemoteHeads(repoPath, fetched) {
239
254
  try {
@@ -272,10 +287,11 @@ var OperationsGitSubProvider = class {
272
287
  * explicit refspecs still updates opportunistically, and which may store into local branches, as a mirror's do),
273
288
  * and tags. A `remote` with no refspecs of its own may be a remote group (`remotes.<group>`), which fetches each of
274
289
  * its remotes, so every remote's destinations stand for it. When the configuration can't be read, all local and
275
- * remote-tracking branches stand for the configured destinations.
290
+ * remote-tracking branches stand for the configured destinations. `alsoMoves` are the refs the write may move
291
+ * besides what its fetch stores (a pull's merge or rebase moves local branches).
276
292
  */
277
- async getFetchSnapshotPatterns(repoPath, remote, refspecs) {
278
- const destinations = [];
293
+ async getFetchSnapshotPatterns(repoPath, remote, refspecs, alsoMoves) {
294
+ const destinations = alsoMoves != null ? [...alsoMoves] : [];
279
295
  const add = (refspec) => {
280
296
  const destination = getRefspecDestination(refspec);
281
297
  if (destination != null) destinations.push(destination);
@@ -303,39 +319,53 @@ var OperationsGitSubProvider = class {
303
319
  * announcement can name (`refs/notes/*`), the kinds it did see, together with `fallback()`'s, unnamed.
304
320
  */
305
321
  async announceFetch(repoPath, snapshot, fallback) {
306
- const after = snapshot?.before != null ? await this.snapshotRefs(repoPath, snapshot.patterns) : void 0;
322
+ const moved = await this.getMovedRefsSince(repoPath, snapshot);
323
+ if (moved?.refs?.length === 0) return;
307
324
  let changes;
308
- let moved;
309
- if (snapshot?.before != null && after != null) {
310
- moved = getMovedRefs(snapshot.before, after);
311
- if (!moved.length) return;
312
- const kinds = /* @__PURE__ */ new Set();
313
- let unnameable = false;
314
- for (const ref of moved) {
315
- const kind = ref.startsWith("refs/") ? getRefChangeKind(ref) : void 0;
316
- if (kind != null) kinds.add(kind);
317
- else unnameable = true;
318
- }
319
- if (unnameable) {
320
- for (const kind of fallback()) kinds.add(kind);
321
- moved = void 0;
322
- }
325
+ if (moved != null) {
326
+ const kinds = new Set(moved.kinds);
327
+ if (moved.refs == null) for (const kind of fallback()) kinds.add(kind);
323
328
  changes = fetchRefChangeKinds.filter((k) => kinds.has(k));
324
- }
329
+ } else changes = fallback();
325
330
  this.context.hooks?.cache?.onReset?.(repoPath, "branches", "tags");
326
- if (changes != null && moved != null) this.context.hooks?.repository?.onChanged?.(repoPath, changes, moved);
327
- else this.context.hooks?.repository?.onChanged?.(repoPath, changes ?? fallback());
331
+ if (moved?.refs != null) this.context.hooks?.repository?.onChanged?.(repoPath, changes, moved.refs);
332
+ else this.context.hooks?.repository?.onChanged?.(repoPath, changes);
333
+ }
334
+ /**
335
+ * What moved since `snapshot` was taken, read again now, or `undefined` when either read is missing, so any ref it
336
+ * covers may have moved. Never rejects.
337
+ */
338
+ async getMovedRefsSince(repoPath, snapshot) {
339
+ if (snapshot?.before == null) return void 0;
340
+ const after = await this.snapshotRefs(repoPath, snapshot.patterns, `after-write-${afterWriteListingCounter.next()}`);
341
+ if (after == null) return void 0;
342
+ const moved = getMovedRefs(snapshot.before, after);
343
+ const kinds = /* @__PURE__ */ new Set();
344
+ let unnameable = false;
345
+ for (const ref of moved) {
346
+ const kind = ref.startsWith("refs/") ? getRefChangeKind(ref) : void 0;
347
+ if (kind != null) kinds.add(kind);
348
+ else unnameable = true;
349
+ }
350
+ return {
351
+ kinds,
352
+ refs: unnameable ? void 0 : moved
353
+ };
328
354
  }
329
355
  /**
330
356
  * Each ref under `patterns` (for-each-ref patterns) with its object and, for a symbolic ref, its target (a remote's
331
357
  * `HEAD` can move to another branch at the same commit), or `undefined` when git couldn't answer. A read, so it
332
- * announces nothing.
358
+ * announces nothing. `correlationKey` keeps it from joining an identical listing already in flight.
359
+ * `cancellation` is for a read before a write, which a cancelled caller no longer waits for; the one after it is
360
+ * never cancelled, since the write still announces.
333
361
  */
334
- async snapshotRefs(repoPath, patterns) {
362
+ async snapshotRefs(repoPath, patterns, correlationKey, cancellation) {
335
363
  try {
336
364
  const result = await this.git.run({
337
365
  cwd: repoPath,
338
- errors: "ignore"
366
+ errors: "ignore",
367
+ correlationKey,
368
+ cancellation
339
369
  }, "for-each-ref", "--format=%(refname)%00%(objectname)%00%(symref)", ...patterns);
340
370
  if (result.completion.status !== "exited" || result.exitCode !== 0) return void 0;
341
371
  const refs = /* @__PURE__ */ new Map();
@@ -439,9 +469,16 @@ var OperationsGitSubProvider = class {
439
469
  const worktree = await this.provider.worktrees?.getWorktree(repoPath, (wt) => wt.branchName === branch.name);
440
470
  if (worktree != null) {
441
471
  const worktreePath = normalizePath(worktree.uri.fsPath);
442
- announce = () => {
443
- this.announcePull(repoPath);
444
- if (worktreePath !== normalizePath(repoPath)) this.announcePull(worktreePath);
472
+ const [snapshot, headBefore] = await this.snapshotPullState(worktreePath, runOptions);
473
+ announce = async () => {
474
+ const [moved, headWrite] = await this.getPullMoved(worktreePath, snapshot, headBefore);
475
+ if (worktreePath !== normalizePath(repoPath)) {
476
+ this.announcePull(repoPath, moved, {
477
+ detached: false,
478
+ rewrote: false
479
+ });
480
+ this.announcePull(worktreePath, moved, headWrite);
481
+ } else this.announcePull(repoPath, moved, headWrite);
445
482
  };
446
483
  this.context.hooks?.operations?.onRebaseCapableOperation?.(worktreePath, "pull", "started");
447
484
  try {
@@ -471,10 +508,12 @@ var OperationsGitSubProvider = class {
471
508
  ]
472
509
  }
473
510
  });
474
- announce = () => {
475
- this.context.hooks?.cache?.onReset?.(repoPath, "branches", "tags");
476
- this.context.hooks?.repository?.onChanged?.(repoPath, ["heads", "remotes"]);
511
+ const patterns = await this.getFetchSnapshotPatterns(repoPath, remoteName, [`${upstream}:${branchName}`]);
512
+ const snapshot = {
513
+ patterns,
514
+ before: await this.snapshotRefs(repoPath, patterns)
477
515
  };
516
+ announce = () => this.announceFetch(repoPath, snapshot, () => ["heads", "remotes"]);
478
517
  try {
479
518
  await this.fetchCore(repoPath, {
480
519
  branch: branchName,
@@ -493,7 +532,11 @@ var OperationsGitSubProvider = class {
493
532
  } else await this.fetch(repoPath, { branch }, runOptions);
494
533
  return;
495
534
  }
496
- announce = () => this.announcePull(repoPath);
535
+ const [snapshot, headBefore] = await this.snapshotPullState(repoPath, runOptions);
536
+ announce = async () => {
537
+ const [moved, headWrite] = await this.getPullMoved(repoPath, snapshot, headBefore);
538
+ this.announcePull(repoPath, moved, headWrite);
539
+ };
497
540
  this.context.hooks?.operations?.onRebaseCapableOperation?.(repoPath, "pull", "started");
498
541
  try {
499
542
  await this.pullCore(repoPath, {
@@ -513,18 +556,54 @@ var OperationsGitSubProvider = class {
513
556
  scope?.error(ex);
514
557
  throw ex;
515
558
  } finally {
516
- announce?.();
559
+ await announce?.();
517
560
  if (fetched != null) this.followRemoteHeads(fetched.repoPath, fetched.remotes);
518
561
  }
519
562
  }
520
- announcePull(repoPath) {
521
- this.context.hooks?.cache?.onReset?.(repoPath, "branches", "status", "tags");
522
- this.context.hooks?.repository?.onChanged?.(repoPath, [
523
- "head",
524
- "heads",
525
- "remotes",
526
- "index"
527
- ]);
563
+ /**
564
+ * A snapshot of every ref a `git pull` run in `repoPath` may move: what its fetch may store, from whichever remote a
565
+ * bare fetch reads (see {@link getFetchSnapshotPatterns}), every local branch, as its merge or rebase moves HEAD's
566
+ * branch, and a rebase that updates refs (`rebase.updateRefs`) moves others, and the stash, which keeps the
567
+ * autostashed changes when restoring them conflicts. Taken together with `repoPath`'s HEAD, which a pull may detach
568
+ * or rewrite (see {@link getPullMoved}), the two reads concurrently.
569
+ */
570
+ async snapshotPullState(repoPath, runOptions) {
571
+ return Promise.all([(async () => {
572
+ const patterns = await this.getFetchSnapshotPatterns(repoPath, void 0, void 0, ["refs/heads", "refs/stash"]);
573
+ return {
574
+ patterns,
575
+ before: await this.snapshotRefs(repoPath, patterns, void 0, runOptions?.cancellation)
576
+ };
577
+ })(), readHeadSnapshot(repoPath, this.context.fs, this.cache)]);
578
+ }
579
+ /**
580
+ * What a pull run in `repoPath` moved, and how it left HEAD, read again now: its refs against `snapshot`, its HEAD
581
+ * against `headBefore` (see {@link getHeadWrite}). Never rejects.
582
+ */
583
+ async getPullMoved(repoPath, snapshot, headBefore) {
584
+ const [moved, headAfter] = await Promise.all([this.getMovedRefsSince(repoPath, snapshot), readHeadSnapshot(repoPath, this.context.fs, this.cache)]);
585
+ return [moved, getHeadWrite(headBefore, headAfter)];
586
+ }
587
+ /**
588
+ * Announces a pull's HEAD and index, and the refs it moved (see {@link getMovedRefsSince}): each ref kind only when a
589
+ * ref of it moved, named, so a sibling worktree that follows none of them skips its refresh. When `moved` is
590
+ * missing, or holds a ref no announcement can name, local and remote-tracking branches are announced unnamed, as if
591
+ * any of them may have moved, with tags and the stash beside them when one moved. `detached` says the pull left
592
+ * `repoPath`'s HEAD off the branch it was on (a rebase stopped partway), which every worktree's list of where each
593
+ * branch is checked out shows, so `worktrees` and `worktreeHead` are announced with it, as for a checkout. `rewrote`
594
+ * says the pull rewrote the HEAD file and put it back on its branch (a rebase that replayed commits detaches it,
595
+ * then points it back), which every other worktree's watcher reports as `worktreeHead`, so the kinds are announced
596
+ * for them to take the report for the pull's own. The list's placement of the branch is unchanged, so it is not
597
+ * reset.
598
+ */
599
+ announcePull(repoPath, moved, { detached, rewrote }) {
600
+ if (detached) this.context.hooks?.cache?.onReset?.(repoPath, "branches", "status", "tags", "worktrees");
601
+ else this.context.hooks?.cache?.onReset?.(repoPath, "branches", "status", "tags");
602
+ const refs = moved?.refs;
603
+ const changes = pullChanges.filter((k) => k === "head" || k === "index" || moved?.kinds.has(k) === true || refs == null && (k === "heads" || k === "remotes"));
604
+ if (detached || rewrote) changes.push(...worktreeHeadChanges);
605
+ if (refs?.length) this.context.hooks?.repository?.onChanged?.(repoPath, changes, refs);
606
+ else this.context.hooks?.repository?.onChanged?.(repoPath, changes);
528
607
  }
529
608
  async pullCore(repoPath, options, runOptions) {
530
609
  const params = ["pull"];
@@ -910,8 +989,7 @@ var OperationsGitSubProvider = class {
910
989
  this.context.hooks?.repository?.onChanged?.(repoPath, [
911
990
  "head",
912
991
  "index",
913
- "worktrees",
914
- "worktreeHead"
992
+ ...worktreeHeadChanges
915
993
  ]);
916
994
  return;
917
995
  }
@@ -926,7 +1004,7 @@ var OperationsGitSubProvider = class {
926
1004
  "heads",
927
1005
  "index"
928
1006
  ];
929
- if (rewroteHead) changes.push("worktrees", "worktreeHead");
1007
+ if (rewroteHead) changes.push(...worktreeHeadChanges);
930
1008
  if (moved == null) this.context.hooks?.repository?.onChanged?.(repoPath, changes);
931
1009
  else if (wroteTracking) this.context.hooks?.repository?.onChanged?.(repoPath, changes, [moved.branch], { configConfinedToRefs: true });
932
1010
  else this.context.hooks?.repository?.onChanged?.(repoPath, changes, [moved.branch]);