@gitkraken/core-gitlens 0.12.0 → 0.13.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 (177) hide show
  1. package/CHANGELOG.md +57 -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 +4 -0
  7. package/dist/git/features.js.map +1 -1
  8. package/dist/git/models/branch.d.ts +15 -2
  9. package/dist/git/models/branch.js +27 -5
  10. package/dist/git/models/branch.js.map +1 -1
  11. package/dist/git/models/status.js +1 -1
  12. package/dist/git/models/worktree.d.ts +4 -1
  13. package/dist/git/models/worktree.js +4 -2
  14. package/dist/git/models/worktree.js.map +1 -1
  15. package/dist/git/providers/branches.d.ts +73 -8
  16. package/dist/git/providers/pausedOperations.d.ts +6 -0
  17. package/dist/git/providers/provider.d.ts +34 -2
  18. package/dist/git/providers/status.d.ts +8 -2
  19. package/dist/git/remotes/azure-devops.js +61 -53
  20. package/dist/git/remotes/azure-devops.js.map +1 -1
  21. package/dist/git/service.d.ts +8 -5
  22. package/dist/git/service.js +16 -8
  23. package/dist/git/service.js.map +1 -1
  24. package/dist/git/utils/branch.utils.d.ts +8 -1
  25. package/dist/git/utils/branch.utils.js +30 -1
  26. package/dist/git/utils/branch.utils.js.map +1 -1
  27. package/dist/git/watching/changeEvent.d.ts +13 -2
  28. package/dist/git/watching/changeEvent.js +17 -3
  29. package/dist/git/watching/changeEvent.js.map +1 -1
  30. package/dist/git/watching/gitDirPoller.d.ts +111 -0
  31. package/dist/git/watching/gitDirPoller.js +266 -0
  32. package/dist/git/watching/gitDirPoller.js.map +1 -0
  33. package/dist/git/watching/provider.d.ts +16 -0
  34. package/dist/git/watching/watchGroup.d.ts +40 -4
  35. package/dist/git/watching/watchGroup.js +143 -17
  36. package/dist/git/watching/watchGroup.js.map +1 -1
  37. package/dist/git/watching/watchService.d.ts +70 -1
  38. package/dist/git/watching/watchService.js +158 -13
  39. package/dist/git/watching/watchService.js.map +1 -1
  40. package/dist/git/watching/watchSession.d.ts +44 -0
  41. package/dist/git/watching/watchSession.js +91 -6
  42. package/dist/git/watching/watchSession.js.map +1 -1
  43. package/dist/git/watching/watcherPatterns.d.ts +21 -0
  44. package/dist/git/watching/watcherPatterns.js +67 -1
  45. package/dist/git/watching/watcherPatterns.js.map +1 -1
  46. package/dist/git/watching/worktreeSummary.d.ts +34 -7
  47. package/dist/git/watching/worktreeSummary.js +39 -12
  48. package/dist/git/watching/worktreeSummary.js.map +1 -1
  49. package/dist/git-cli/cliGitProvider.d.ts +34 -2
  50. package/dist/git-cli/cliGitProvider.js +119 -17
  51. package/dist/git-cli/cliGitProvider.js.map +1 -1
  52. package/dist/git-cli/exec/commandClassifier.d.ts +15 -0
  53. package/dist/git-cli/exec/commandClassifier.js +48 -2
  54. package/dist/git-cli/exec/commandClassifier.js.map +1 -1
  55. package/dist/git-cli/exec/git.d.ts +15 -3
  56. package/dist/git-cli/exec/git.js +38 -17
  57. package/dist/git-cli/exec/git.js.map +1 -1
  58. package/dist/git-cli/exec/gitQueue.d.ts +2 -0
  59. package/dist/git-cli/exec/gitQueue.js +2 -1
  60. package/dist/git-cli/exec/gitQueue.js.map +1 -1
  61. package/dist/git-cli/exec/indexLock.d.ts +38 -0
  62. package/dist/git-cli/exec/indexLock.js +150 -0
  63. package/dist/git-cli/exec/indexLock.js.map +1 -0
  64. package/dist/git-cli/parsers/worktreeParser.js +42 -2
  65. package/dist/git-cli/parsers/worktreeParser.js.map +1 -1
  66. package/dist/git-cli/providers/branches.d.ts +109 -10
  67. package/dist/git-cli/providers/branches.js +624 -131
  68. package/dist/git-cli/providers/branches.js.map +1 -1
  69. package/dist/git-cli/providers/config.d.ts +9 -5
  70. package/dist/git-cli/providers/config.js +60 -27
  71. package/dist/git-cli/providers/config.js.map +1 -1
  72. package/dist/git-cli/providers/operations.d.ts +17 -0
  73. package/dist/git-cli/providers/operations.js +153 -96
  74. package/dist/git-cli/providers/operations.js.map +1 -1
  75. package/dist/git-cli/providers/pausedOperations.d.ts +8 -0
  76. package/dist/git-cli/providers/pausedOperations.js +60 -40
  77. package/dist/git-cli/providers/pausedOperations.js.map +1 -1
  78. package/dist/git-cli/providers/refs.js +11 -8
  79. package/dist/git-cli/providers/refs.js.map +1 -1
  80. package/dist/git-cli/providers/remotes.js +19 -10
  81. package/dist/git-cli/providers/remotes.js.map +1 -1
  82. package/dist/git-cli/providers/staging.js +40 -15
  83. package/dist/git-cli/providers/staging.js.map +1 -1
  84. package/dist/git-cli/providers/stash.d.ts +2 -0
  85. package/dist/git-cli/providers/stash.js +33 -18
  86. package/dist/git-cli/providers/stash.js.map +1 -1
  87. package/dist/git-cli/providers/status.d.ts +3 -1
  88. package/dist/git-cli/providers/status.js +38 -20
  89. package/dist/git-cli/providers/status.js.map +1 -1
  90. package/dist/git-cli/providers/tags.js +6 -4
  91. package/dist/git-cli/providers/tags.js.map +1 -1
  92. package/dist/git-cli/providers/worktrees.d.ts +1 -0
  93. package/dist/git-cli/providers/worktrees.js +60 -31
  94. package/dist/git-cli/providers/worktrees.js.map +1 -1
  95. package/dist/git-cli/service.d.ts +6 -0
  96. package/dist/git-cli/service.js +5 -2
  97. package/dist/git-cli/service.js.map +1 -1
  98. package/dist/ipc/discovery.js +1 -1
  99. package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
  100. package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
  101. package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
  102. package/dist/plus/git-github/providers/github/status.d.ts +3 -1
  103. package/dist/plus/git-github/providers/github/status.js +1 -1
  104. package/dist/plus/git-github/providers/github/status.js.map +1 -1
  105. package/dist/plus/integrations/collectionMetadata.d.ts +13 -2
  106. package/dist/plus/integrations/collectionMetadata.js +14 -2
  107. package/dist/plus/integrations/collectionMetadata.js.map +1 -1
  108. package/dist/plus/integrations/index.d.ts +2 -2
  109. package/dist/plus/integrations/index.js.map +1 -1
  110. package/dist/plus/integrations/integrationService.d.ts +1 -0
  111. package/dist/plus/integrations/integrationService.js +1 -1
  112. package/dist/plus/integrations/integrationService.js.map +1 -1
  113. package/dist/plus/integrations/manager.d.ts +1 -0
  114. package/dist/plus/integrations/models/gitHostIntegration.d.ts +41 -5
  115. package/dist/plus/integrations/models/gitHostIntegration.js +106 -29
  116. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  117. package/dist/plus/integrations/models/issueReads.d.ts +17 -4
  118. package/dist/plus/integrations/providers/apiClients.d.ts +2 -0
  119. package/dist/plus/integrations/providers/apiClients.js +7 -1
  120. package/dist/plus/integrations/providers/apiClients.js.map +1 -1
  121. package/dist/plus/integrations/providers/azure/azure.d.ts +5 -4
  122. package/dist/plus/integrations/providers/azure/azure.js +37 -77
  123. package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
  124. package/dist/plus/integrations/providers/azure/azure.utils.js +20 -17
  125. package/dist/plus/integrations/providers/azure/azure.utils.js.map +1 -1
  126. package/dist/plus/integrations/providers/azure/models.d.ts +2 -2
  127. package/dist/plus/integrations/providers/azure/models.js +4 -4
  128. package/dist/plus/integrations/providers/azure/models.js.map +1 -1
  129. package/dist/plus/integrations/providers/azure/workItemStateCategories.d.ts +18 -14
  130. package/dist/plus/integrations/providers/azure/workItemStateCategories.js +69 -17
  131. package/dist/plus/integrations/providers/azure/workItemStateCategories.js.map +1 -1
  132. package/dist/plus/integrations/providers/azureDevOps.d.ts +44 -0
  133. package/dist/plus/integrations/providers/azureDevOps.js +108 -17
  134. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  135. package/dist/plus/integrations/providers/azureDevOpsServer.d.ts +45 -1
  136. package/dist/plus/integrations/providers/azureDevOpsServer.js +121 -6
  137. package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
  138. package/dist/plus/integrations/providers/jira-server.js +18 -14
  139. package/dist/plus/integrations/providers/jira-server.js.map +1 -1
  140. package/dist/plus/integrations/providers/jira.js +18 -14
  141. package/dist/plus/integrations/providers/jira.js.map +1 -1
  142. package/dist/plus/integrations/providers/models.d.ts +1 -2
  143. package/dist/plus/integrations/providers/models.js +9 -2
  144. package/dist/plus/integrations/providers/models.js.map +1 -1
  145. package/dist/plus/integrations/providers/providersApi.d.ts +7 -17
  146. package/dist/plus/integrations/providers/providersApi.js +85 -78
  147. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  148. package/dist/plus/integrations/providers/utils/jiraIssueDrains.d.ts +22 -0
  149. package/dist/plus/integrations/providers/utils/jiraIssueDrains.js +69 -9
  150. package/dist/plus/integrations/providers/utils/jiraIssueDrains.js.map +1 -1
  151. package/dist/plus/integrations/providers/utils/providerPaging.js +8 -2
  152. package/dist/plus/integrations/providers/utils/providerPaging.js.map +1 -1
  153. package/dist/plus/integrations/reads/filters.d.ts +3 -3
  154. package/dist/plus/integrations/reads/filters.js.map +1 -1
  155. package/dist/plus/integrations/reads/issueBatch.d.ts +2 -1
  156. package/dist/plus/integrations/reads/issueBatch.js +1 -1
  157. package/dist/plus/integrations/reads/issueBatch.js.map +1 -1
  158. package/dist/plus/integrations/reads/issueTracker.js +23 -14
  159. package/dist/plus/integrations/reads/issueTracker.js.map +1 -1
  160. package/dist/plus/integrations/reads/issues.d.ts +2 -1
  161. package/dist/plus/integrations/reads/issues.js +18 -3
  162. package/dist/plus/integrations/reads/issues.js.map +1 -1
  163. package/dist/plus/integrations/reads/pullRequestBatch.js +1 -1
  164. package/dist/plus/integrations/reads/resolveRepository.js +12 -3
  165. package/dist/plus/integrations/reads/resolveRepository.js.map +1 -1
  166. package/dist/plus/integrations/reads/warnings.d.ts +11 -4
  167. package/dist/plus/integrations/reads/warnings.js +15 -5
  168. package/dist/plus/integrations/reads/warnings.js.map +1 -1
  169. package/dist/plus/integrations/results.d.ts +36 -2
  170. package/dist/plus/integrations/results.js +33 -13
  171. package/dist/plus/integrations/results.js.map +1 -1
  172. package/dist/utils/env/node/exec.js +2 -2
  173. package/dist/utils/promiseCache.d.ts +10 -0
  174. package/dist/utils/promiseCache.js +17 -2
  175. package/dist/utils/promiseCache.js.map +1 -1
  176. package/docs/integrations.md +52 -20
  177. package/package.json +2 -2
@@ -8,8 +8,8 @@ import { joinPaths } from "../../utils/path.js";
8
8
  import __decorate from "../../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
9
9
  import { maxGitCliLength } from "../exec/git.js";
10
10
  import * as l10n from "@vscode/l10n";
11
- import { promises } from "fs";
12
11
  import { tmpdir } from "os";
12
+ import { promises } from "fs";
13
13
  //#region ../git-cli/src/providers/staging.ts
14
14
  var StagingGitSubProvider = class {
15
15
  context;
@@ -71,8 +71,12 @@ var StagingGitSubProvider = class {
71
71
  }
72
72
  }
73
73
  async stageFile(repoPath, pathOrUri) {
74
- await this.git.run({ cwd: repoPath }, "add", "-A", "--", toFsPath(pathOrUri));
75
- this.announceIndexChanged(repoPath);
74
+ const path = toFsPath(pathOrUri);
75
+ try {
76
+ await this.git.run({ cwd: repoPath }, "add", "-A", "--", path);
77
+ } finally {
78
+ this.announceIndexChanged(repoPath);
79
+ }
76
80
  }
77
81
  async stageFiles(repoPath, pathsOrUris, options) {
78
82
  const paths = pathsOrUris.map(toFsPath);
@@ -90,12 +94,20 @@ var StagingGitSubProvider = class {
90
94
  }
91
95
  }
92
96
  async stageDirectory(repoPath, directoryOrUri) {
93
- await this.git.run({ cwd: repoPath }, "add", "-A", "--", toFsPath(directoryOrUri));
94
- this.announceIndexChanged(repoPath);
97
+ const path = toFsPath(directoryOrUri);
98
+ try {
99
+ await this.git.run({ cwd: repoPath }, "add", "-A", "--", path);
100
+ } finally {
101
+ this.announceIndexChanged(repoPath);
102
+ }
95
103
  }
96
104
  async unstageFile(repoPath, pathOrUri) {
97
- await this.git.run({ cwd: repoPath }, "reset", "-q", "--", toFsPath(pathOrUri));
98
- this.announceIndexChanged(repoPath);
105
+ const path = toFsPath(pathOrUri);
106
+ try {
107
+ await this.git.run({ cwd: repoPath }, "reset", "-q", "--", path);
108
+ } finally {
109
+ this.announceIndexChanged(repoPath);
110
+ }
99
111
  }
100
112
  async unstageFiles(repoPath, pathsOrUris) {
101
113
  const paths = pathsOrUris.map(toFsPath);
@@ -110,15 +122,22 @@ var StagingGitSubProvider = class {
110
122
  }
111
123
  }
112
124
  async unstageDirectory(repoPath, directoryOrUri) {
113
- await this.git.run({ cwd: repoPath }, "reset", "-q", "--", toFsPath(directoryOrUri));
114
- this.announceIndexChanged(repoPath);
125
+ const path = toFsPath(directoryOrUri);
126
+ try {
127
+ await this.git.run({ cwd: repoPath }, "reset", "-q", "--", path);
128
+ } finally {
129
+ this.announceIndexChanged(repoPath);
130
+ }
115
131
  }
116
132
  async removeFile(repoPath, pathOrUri, options) {
117
133
  const args = ["rm"];
118
134
  if (options?.force) args.push("-f");
119
135
  args.push("--", toFsPath(pathOrUri));
120
- await this.git.run({ cwd: repoPath }, ...args);
121
- this.announceIndexChanged(repoPath);
136
+ try {
137
+ await this.git.run({ cwd: repoPath }, ...args);
138
+ } finally {
139
+ this.announceIndexChanged(repoPath);
140
+ }
122
141
  }
123
142
  async removeFiles(repoPath, pathsOrUris, options) {
124
143
  const paths = pathsOrUris.map(toFsPath);
@@ -136,12 +155,18 @@ var StagingGitSubProvider = class {
136
155
  }
137
156
  }
138
157
  async stageAll(repoPath) {
139
- await this.git.run({ cwd: repoPath }, "add", "-A");
140
- this.announceIndexChanged(repoPath);
158
+ try {
159
+ await this.git.run({ cwd: repoPath }, "add", "-A");
160
+ } finally {
161
+ this.announceIndexChanged(repoPath);
162
+ }
141
163
  }
142
164
  async unstageAll(repoPath) {
143
- await this.git.run({ cwd: repoPath }, "reset", "-q");
144
- this.announceIndexChanged(repoPath);
165
+ try {
166
+ await this.git.run({ cwd: repoPath }, "reset", "-q");
167
+ } finally {
168
+ this.announceIndexChanged(repoPath);
169
+ }
145
170
  }
146
171
  async clean(repoPath, options, runOptions) {
147
172
  const args = ["clean"];
@@ -1 +1 @@
1
- {"version":3,"file":"staging.js","names":["fs"],"sources":["../../../../git-cli/src/providers/staging.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport { tmpdir } from 'os';\nimport * as l10n from '@vscode/l10n';\nimport type { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport type { GitOperationRunOptions } from '@gitlens/git/providers/operations.js';\nimport type { DisposableTemporaryGitIndex, GitStagingSubProvider } from '@gitlens/git/providers/staging.js';\nimport { countStringLength } from '@gitlens/utils/array.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { mixinAsyncDisposable } from '@gitlens/utils/disposable.js';\nimport { chunk } from '@gitlens/utils/iterable.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { joinPaths } from '@gitlens/utils/path.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { toFsPath } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport type { Git } from '../exec/git.js';\nimport { maxGitCliLength } from '../exec/git.js';\n\nexport class StagingGitSubProvider implements GitStagingSubProvider {\n\tconstructor(\n\t\tprivate readonly context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t) {}\n\n\t@debug()\n\tasync createTemporaryIndex(\n\t\trepoPath: string,\n\t\tfrom: 'empty' | 'current' | 'ref',\n\t\tref?: string,\n\t): Promise<DisposableTemporaryGitIndex> {\n\t\tconst scope = getScopedLogger();\n\n\t\t// Create a temporary index file\n\t\tconst tempDir = await fs.mkdtemp(joinPaths(tmpdir(), 'gl-'));\n\t\tconst tempIndex = joinPaths(tempDir, 'index');\n\n\t\tasync function dispose() {\n\t\t\t// Delete the temporary index file\n\t\t\ttry {\n\t\t\t\tawait fs.rm(tempDir, { recursive: true });\n\t\t\t} catch {\n\t\t\t\t// ignore cleanup errors\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\t// Tell Git to use our soon to be created index file\n\t\t\tconst env = { GIT_INDEX_FILE: tempIndex };\n\n\t\t\tswitch (from) {\n\t\t\t\tcase 'empty':\n\t\t\t\t\t// Leave the temp index empty\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'current': {\n\t\t\t\t\t// Copy the current index to preserve staged state\n\t\t\t\t\tconst gitDir = await this.provider.config.getGitDir?.(repoPath);\n\t\t\t\t\tif (gitDir == null) throw new Error(l10n.t('Unable to determine git directory for {0}', repoPath));\n\n\t\t\t\t\tconst currentIndex = joinPaths(gitDir.uri.fsPath, 'index');\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait fs.copyFile(currentIndex, tempIndex);\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\t// A repo that has never staged anything has no index file yet; git reads a missing\n\t\t\t\t\t\t// `GIT_INDEX_FILE` as an empty index, which is what 'current' means there. Any other\n\t\t\t\t\t\t// failure is real — don't silently hand back an index claiming everything is deleted.\n\t\t\t\t\t\tif ((ex as NodeJS.ErrnoException)?.code !== 'ENOENT') throw ex;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'ref': {\n\t\t\t\t\tif (ref == null) throw new Error(l10n.t(\"ref is required when from is 'ref'\"));\n\n\t\t\t\t\t// Create the temp index file from a base ref/sha\n\t\t\t\t\tconst newIndexResult = await this.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, env: env },\n\t\t\t\t\t\t'ls-tree',\n\t\t\t\t\t\t'-z',\n\t\t\t\t\t\t'-r',\n\t\t\t\t\t\t'--full-name',\n\t\t\t\t\t\tref,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (newIndexResult.stdout.trim()) {\n\t\t\t\t\t\t// Write the tree to our temp index\n\t\t\t\t\t\tawait this.git.run(\n\t\t\t\t\t\t\t{ cwd: repoPath, env: env, stdin: newIndexResult.stdout },\n\t\t\t\t\t\t\t'update-index',\n\t\t\t\t\t\t\t'-z',\n\t\t\t\t\t\t\t'--index-info',\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn mixinAsyncDisposable({ path: tempIndex, env: { GIT_INDEX_FILE: tempIndex } }, dispose);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\n\t\t\tvoid dispose();\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageFile(repoPath: string, pathOrUri: string | Uri): Promise<void> {\n\t\tawait this.git.run({ cwd: repoPath }, 'add', '-A', '--', toFsPath(pathOrUri));\n\t\tthis.announceIndexChanged(repoPath);\n\t}\n\n\t@debug()\n\tasync stageFiles(\n\t\trepoPath: string,\n\t\tpathsOrUris: (string | Uri)[],\n\t\toptions?: { intentToAdd?: boolean; index?: DisposableTemporaryGitIndex },\n\t): Promise<void> {\n\t\tconst paths = pathsOrUris.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process files in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\ttry {\n\t\t\tfor (const batch of batches) {\n\t\t\t\tawait this.git.run(\n\t\t\t\t\t{ cwd: repoPath, env: options?.index?.env },\n\t\t\t\t\t'add',\n\t\t\t\t\toptions?.intentToAdd ? '-N' : '-A',\n\t\t\t\t\t'--',\n\t\t\t\t\t...batch,\n\t\t\t\t);\n\t\t\t}\n\t\t} finally {\n\t\t\t// Announced even when a later batch fails, since the earlier ones already changed the index. A\n\t\t\t// temporary index (used for partial-stage previews / diff building) is not the repository's real\n\t\t\t// index — firing repo-change hooks for it would invalidate status caches for a mutation nothing\n\t\t\t// else can observe.\n\t\t\tif (options?.index == null) {\n\t\t\t\tthis.announceIndexChanged(repoPath);\n\t\t\t}\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageDirectory(repoPath: string, directoryOrUri: string | Uri): Promise<void> {\n\t\tawait this.git.run({ cwd: repoPath }, 'add', '-A', '--', toFsPath(directoryOrUri));\n\t\tthis.announceIndexChanged(repoPath);\n\t}\n\n\t@debug()\n\tasync unstageFile(repoPath: string, pathOrUri: string | Uri): Promise<void> {\n\t\tawait this.git.run({ cwd: repoPath }, 'reset', '-q', '--', toFsPath(pathOrUri));\n\t\tthis.announceIndexChanged(repoPath);\n\t}\n\n\t@debug()\n\tasync unstageFiles(repoPath: string, pathsOrUris: (string | Uri)[]): Promise<void> {\n\t\tconst paths = pathsOrUris.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process files in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\ttry {\n\t\t\tfor (const batch of batches) {\n\t\t\t\tawait this.git.run({ cwd: repoPath }, 'reset', '-q', '--', ...batch);\n\t\t\t}\n\t\t} finally {\n\t\t\t// Even when a later batch fails, the earlier ones already changed the index\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync unstageDirectory(repoPath: string, directoryOrUri: string | Uri): Promise<void> {\n\t\tawait this.git.run({ cwd: repoPath }, 'reset', '-q', '--', toFsPath(directoryOrUri));\n\t\tthis.announceIndexChanged(repoPath);\n\t}\n\n\t@debug()\n\tasync removeFile(repoPath: string, pathOrUri: string | Uri, options?: { force?: boolean }): Promise<void> {\n\t\tconst args = ['rm'];\n\t\tif (options?.force) {\n\t\t\targs.push('-f');\n\t\t}\n\t\targs.push('--', toFsPath(pathOrUri));\n\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\tthis.announceIndexChanged(repoPath);\n\t}\n\n\t@debug()\n\tasync removeFiles(repoPath: string, pathsOrUris: (string | Uri)[], options?: { force?: boolean }): Promise<void> {\n\t\tconst paths = pathsOrUris.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\tconst args: string[] = ['rm'];\n\t\tif (options?.force) {\n\t\t\targs.push('-f');\n\t\t}\n\t\targs.push('--');\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process files in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\ttry {\n\t\t\tfor (const batch of batches) {\n\t\t\t\tawait this.git.run({ cwd: repoPath }, ...args, ...batch);\n\t\t\t}\n\t\t} finally {\n\t\t\t// Even when a later batch fails, the earlier ones already changed the index\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageAll(repoPath: string): Promise<void> {\n\t\tawait this.git.run({ cwd: repoPath }, 'add', '-A');\n\t\tthis.announceIndexChanged(repoPath);\n\t}\n\n\t@debug()\n\tasync unstageAll(repoPath: string): Promise<void> {\n\t\tawait this.git.run({ cwd: repoPath }, 'reset', '-q');\n\t\tthis.announceIndexChanged(repoPath);\n\t}\n\n\t@debug()\n\tasync clean(\n\t\trepoPath: string,\n\t\toptions?: {\n\t\t\tpaths?: (string | Uri)[];\n\t\t\tdirectories?: boolean;\n\t\t\tforce?: boolean;\n\t\t\tignored?: boolean;\n\t\t},\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst args = ['clean'];\n\t\tif (options?.force ?? true) {\n\t\t\targs.push('-f');\n\t\t}\n\t\tif (options?.directories) {\n\t\t\targs.push('-d');\n\t\t}\n\t\tif (options?.ignored) {\n\t\t\targs.push('-x');\n\t\t}\n\n\t\tif (options?.paths == null) {\n\t\t\ttry {\n\t\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...args);\n\t\t\t} finally {\n\t\t\t\t// A clean that failed or was cancelled partway may already have removed files\n\t\t\t\tthis.announceIndexChanged(repoPath);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst paths = options.paths.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process paths in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\ttry {\n\t\t\tfor (const batch of batches) {\n\t\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...args, '--', ...batch);\n\t\t\t}\n\t\t} finally {\n\t\t\t// Even when a later batch fails, the earlier ones already removed files\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t/** What every index or working-tree mutation announces, so cached status is re-read and hosts are told. */\n\tprivate announceIndexChanged(repoPath: string): void {\n\t\t// `diff` and `tracking` too, as a watcher-observed index change clears them: a file's working-vs-index\n\t\t// diff and whether it is tracked both change when it is staged, unstaged or removed\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'status', 'diff', 'tracking');\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['index']);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAmBA,IAAa,wBAAb,MAAoE;CAEjD;CACA;CACA;CACA;CAJlB,YACC,SACA,KACA,OACA,UACC;EAJgB,KAAA,UAAA;EACA,KAAA,MAAA;EACA,KAAA,QAAA;EACA,KAAA,WAAA;CACf;CAEH,MACM,qBACL,UACA,MACA,KACuC;EACvC,MAAM,QAAQ,gBAAgB;EAG9B,MAAM,UAAU,MAAMA,SAAG,QAAQ,UAAU,OAAO,GAAG,KAAK,CAAC;EAC3D,MAAM,YAAY,UAAU,SAAS,OAAO;EAE5C,eAAe,UAAU;GAExB,IAAI;IACH,MAAMA,SAAG,GAAG,SAAS,EAAE,WAAW,KAAK,CAA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,GAAA,sBAAA,WAAA,cAAA,IAAA;AAWN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,eAAA,IAAA;AA2BN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,YAAA,IAAA;AAMN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,cAAA,IAAA;AAMN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,SAAA,IAAA"}
1
+ {"version":3,"file":"staging.js","names":["fs"],"sources":["../../../../git-cli/src/providers/staging.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport { tmpdir } from 'os';\nimport * as l10n from '@vscode/l10n';\nimport type { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport type { GitOperationRunOptions } from '@gitlens/git/providers/operations.js';\nimport type { DisposableTemporaryGitIndex, GitStagingSubProvider } from '@gitlens/git/providers/staging.js';\nimport { countStringLength } from '@gitlens/utils/array.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { mixinAsyncDisposable } from '@gitlens/utils/disposable.js';\nimport { chunk } from '@gitlens/utils/iterable.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { joinPaths } from '@gitlens/utils/path.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { toFsPath } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport type { Git } from '../exec/git.js';\nimport { maxGitCliLength } from '../exec/git.js';\n\nexport class StagingGitSubProvider implements GitStagingSubProvider {\n\tconstructor(\n\t\tprivate readonly context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t) {}\n\n\t@debug()\n\tasync createTemporaryIndex(\n\t\trepoPath: string,\n\t\tfrom: 'empty' | 'current' | 'ref',\n\t\tref?: string,\n\t): Promise<DisposableTemporaryGitIndex> {\n\t\tconst scope = getScopedLogger();\n\n\t\t// Create a temporary index file\n\t\tconst tempDir = await fs.mkdtemp(joinPaths(tmpdir(), 'gl-'));\n\t\tconst tempIndex = joinPaths(tempDir, 'index');\n\n\t\tasync function dispose() {\n\t\t\t// Delete the temporary index file\n\t\t\ttry {\n\t\t\t\tawait fs.rm(tempDir, { recursive: true });\n\t\t\t} catch {\n\t\t\t\t// ignore cleanup errors\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\t// Tell Git to use our soon to be created index file\n\t\t\tconst env = { GIT_INDEX_FILE: tempIndex };\n\n\t\t\tswitch (from) {\n\t\t\t\tcase 'empty':\n\t\t\t\t\t// Leave the temp index empty\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'current': {\n\t\t\t\t\t// Copy the current index to preserve staged state\n\t\t\t\t\tconst gitDir = await this.provider.config.getGitDir?.(repoPath);\n\t\t\t\t\tif (gitDir == null) throw new Error(l10n.t('Unable to determine git directory for {0}', repoPath));\n\n\t\t\t\t\tconst currentIndex = joinPaths(gitDir.uri.fsPath, 'index');\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait fs.copyFile(currentIndex, tempIndex);\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\t// A repo that has never staged anything has no index file yet; git reads a missing\n\t\t\t\t\t\t// `GIT_INDEX_FILE` as an empty index, which is what 'current' means there. Any other\n\t\t\t\t\t\t// failure is real — don't silently hand back an index claiming everything is deleted.\n\t\t\t\t\t\tif ((ex as NodeJS.ErrnoException)?.code !== 'ENOENT') throw ex;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'ref': {\n\t\t\t\t\tif (ref == null) throw new Error(l10n.t(\"ref is required when from is 'ref'\"));\n\n\t\t\t\t\t// Create the temp index file from a base ref/sha\n\t\t\t\t\tconst newIndexResult = await this.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, env: env },\n\t\t\t\t\t\t'ls-tree',\n\t\t\t\t\t\t'-z',\n\t\t\t\t\t\t'-r',\n\t\t\t\t\t\t'--full-name',\n\t\t\t\t\t\tref,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (newIndexResult.stdout.trim()) {\n\t\t\t\t\t\t// Write the tree to our temp index\n\t\t\t\t\t\tawait this.git.run(\n\t\t\t\t\t\t\t{ cwd: repoPath, env: env, stdin: newIndexResult.stdout },\n\t\t\t\t\t\t\t'update-index',\n\t\t\t\t\t\t\t'-z',\n\t\t\t\t\t\t\t'--index-info',\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn mixinAsyncDisposable({ path: tempIndex, env: { GIT_INDEX_FILE: tempIndex } }, dispose);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\n\t\t\tvoid dispose();\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageFile(repoPath: string, pathOrUri: string | Uri): Promise<void> {\n\t\tconst path = toFsPath(pathOrUri);\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'add', '-A', '--', path);\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageFiles(\n\t\trepoPath: string,\n\t\tpathsOrUris: (string | Uri)[],\n\t\toptions?: { intentToAdd?: boolean; index?: DisposableTemporaryGitIndex },\n\t): Promise<void> {\n\t\tconst paths = pathsOrUris.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process files in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\ttry {\n\t\t\tfor (const batch of batches) {\n\t\t\t\tawait this.git.run(\n\t\t\t\t\t{ cwd: repoPath, env: options?.index?.env },\n\t\t\t\t\t'add',\n\t\t\t\t\toptions?.intentToAdd ? '-N' : '-A',\n\t\t\t\t\t'--',\n\t\t\t\t\t...batch,\n\t\t\t\t);\n\t\t\t}\n\t\t} finally {\n\t\t\t// Announced even when a later batch fails, since the earlier ones already changed the index. A\n\t\t\t// temporary index (used for partial-stage previews / diff building) is not the repository's real\n\t\t\t// index — firing repo-change hooks for it would invalidate status caches for a mutation nothing\n\t\t\t// else can observe.\n\t\t\tif (options?.index == null) {\n\t\t\t\tthis.announceIndexChanged(repoPath);\n\t\t\t}\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageDirectory(repoPath: string, directoryOrUri: string | Uri): Promise<void> {\n\t\tconst path = toFsPath(directoryOrUri);\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'add', '-A', '--', path);\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync unstageFile(repoPath: string, pathOrUri: string | Uri): Promise<void> {\n\t\tconst path = toFsPath(pathOrUri);\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'reset', '-q', '--', path);\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync unstageFiles(repoPath: string, pathsOrUris: (string | Uri)[]): Promise<void> {\n\t\tconst paths = pathsOrUris.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process files in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\ttry {\n\t\t\tfor (const batch of batches) {\n\t\t\t\tawait this.git.run({ cwd: repoPath }, 'reset', '-q', '--', ...batch);\n\t\t\t}\n\t\t} finally {\n\t\t\t// Even when a later batch fails, the earlier ones already changed the index\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync unstageDirectory(repoPath: string, directoryOrUri: string | Uri): Promise<void> {\n\t\tconst path = toFsPath(directoryOrUri);\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'reset', '-q', '--', path);\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync removeFile(repoPath: string, pathOrUri: string | Uri, options?: { force?: boolean }): Promise<void> {\n\t\tconst args = ['rm'];\n\t\tif (options?.force) {\n\t\t\targs.push('-f');\n\t\t}\n\t\targs.push('--', toFsPath(pathOrUri));\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync removeFiles(repoPath: string, pathsOrUris: (string | Uri)[], options?: { force?: boolean }): Promise<void> {\n\t\tconst paths = pathsOrUris.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\tconst args: string[] = ['rm'];\n\t\tif (options?.force) {\n\t\t\targs.push('-f');\n\t\t}\n\t\targs.push('--');\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process files in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\ttry {\n\t\t\tfor (const batch of batches) {\n\t\t\t\tawait this.git.run({ cwd: repoPath }, ...args, ...batch);\n\t\t\t}\n\t\t} finally {\n\t\t\t// Even when a later batch fails, the earlier ones already changed the index\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageAll(repoPath: string): Promise<void> {\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'add', '-A');\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync unstageAll(repoPath: string): Promise<void> {\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'reset', '-q');\n\t\t} finally {\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync clean(\n\t\trepoPath: string,\n\t\toptions?: {\n\t\t\tpaths?: (string | Uri)[];\n\t\t\tdirectories?: boolean;\n\t\t\tforce?: boolean;\n\t\t\tignored?: boolean;\n\t\t},\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst args = ['clean'];\n\t\tif (options?.force ?? true) {\n\t\t\targs.push('-f');\n\t\t}\n\t\tif (options?.directories) {\n\t\t\targs.push('-d');\n\t\t}\n\t\tif (options?.ignored) {\n\t\t\targs.push('-x');\n\t\t}\n\n\t\tif (options?.paths == null) {\n\t\t\ttry {\n\t\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...args);\n\t\t\t} finally {\n\t\t\t\t// A clean that failed or was cancelled partway may already have removed files\n\t\t\t\tthis.announceIndexChanged(repoPath);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst paths = options.paths.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process paths in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\ttry {\n\t\t\tfor (const batch of batches) {\n\t\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...args, '--', ...batch);\n\t\t\t}\n\t\t} finally {\n\t\t\t// Even when a later batch fails, the earlier ones already removed files\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t/** What every index or working-tree mutation announces, so cached status is re-read and hosts are told. */\n\tprivate announceIndexChanged(repoPath: string): void {\n\t\t// `diff` and `tracking` too, as a watcher-observed index change clears them: a file's working-vs-index\n\t\t// diff and whether it is tracked both change when it is staged, unstaged or removed\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'status', 'diff', 'tracking');\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['index']);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAmBA,IAAa,wBAAb,MAAoE;CAEjD;CACA;CACA;CACA;CAJlB,YACC,SACA,KACA,OACA,UACC;EAJgB,KAAA,UAAA;EACA,KAAA,MAAA;EACA,KAAA,QAAA;EACA,KAAA,WAAA;CACf;CAEH,MACM,qBACL,UACA,MACA,KACuC;EACvC,MAAM,QAAQ,gBAAgB;EAG9B,MAAM,UAAU,MAAMA,SAAG,QAAQ,UAAU,OAAO,GAAG,KAAK,CAAC;EAC3D,MAAM,YAAY,UAAU,SAAS,OAAO;EAE5C,eAAe,UAAU;GAExB,IAAI;IACH,MAAMA,SAAG,GAAG,SAAS,EAAE,WAAW,KAAK,CAAC;GACzC,QAAQ,CAER;EACD;EAEA,IAAI;GAEH,MAAM,MAAM,EAAE,gBAAgB,UAAU;GAExC,QAAQ,MAAR;IACC,KAAK,SAEJ;IACD,KAAK,WAAW;KAEf,MAAM,SAAS,MAAM,KAAK,SAAS,OAAO,YAAY,QAAQ;KAC9D,IAAI,UAAU,MAAM,MAAM,IAAI,MAAM,KAAK,EAAE,6CAA6C,QAAQ,CAAC;KAEjG,MAAM,eAAe,UAAU,OAAO,IAAI,QAAQ,OAAO;KACzD,IAAI;MACH,MAAMA,SAAG,SAAS,cAAc,SAAS;KAC1C,SAAS,IAAI;MAIZ,IAAK,IAA8B,SAAS,UAAU,MAAM;KAC7D;KACA;IACD;IACA,KAAK,OAAO;KACX,IAAI,OAAO,MAAM,MAAM,IAAI,MAAM,KAAK,EAAE,oCAAoC,CAAC;KAG7E,MAAM,iBAAiB,MAAM,KAAK,IAAI,IACrC;MAAE,KAAK;MAAe;KAAI,GAC1B,WACA,MACA,MACA,eACA,GACD;KAEA,IAAI,eAAe,OAAO,KAAK,GAE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M,OAAO,SAAS;EACtC,IAAI;GACH,KAAK,MAAM,SAAS,SACnB,MAAM,KAAK,IAAI,IAAI;IAAE,KAAK;IAAU,QAAQ;IAAS,GAAG;GAAW,GAAG,GAAG,MAAM,MAAM,GAAG,KAAK;EAE/F,UAAU;GAET,KAAK,qBAAqB,QAAQ;EACnC;CACD;;CAGA,qBAA6B,UAAwB;EAGpD,KAAK,QAAQ,OAAO,OAAO,UAAU,UAAU,UAAU,QAAQ,UAAU;EAC3E,KAAK,QAAQ,OAAO,YAAY,YAAY,UAAU,CAAC,OAAO,CAAC;CAChE;AACD;AAvSE,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,wBAAA,IAAA;AAiFN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,aAAA,IAAA;AAUN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,cAAA,IAAA;AAoCN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,kBAAA,IAAA;AAUN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,eAAA,IAAA;AAUN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,gBAAA,IAAA;AAqBN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,oBAAA,IAAA;AAUN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,cAAA,IAAA;AAcN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,eAAA,IAAA;AA2BN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,YAAA,IAAA;AASN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,cAAA,IAAA;AASN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,SAAA,IAAA"}
@@ -32,6 +32,7 @@ export declare class StashGitSubProvider implements GitStashSubProvider {
32
32
  private getStashCommitFilesCore;
33
33
  deleteStash(repoPath: string, stashName: string, sha?: string): Promise<void>;
34
34
  private deleteStashCore;
35
+ private verifyStashSha;
35
36
  renameStash(repoPath: string, stashName: string, sha: string, message: string, stashOnRef?: string): Promise<void>;
36
37
  saveStash(repoPath: string, message?: string, pathsOrUris?: (string | Uri)[], options?: {
37
38
  includeUntracked?: boolean;
@@ -40,6 +41,7 @@ export declare class StashGitSubProvider implements GitStashSubProvider {
40
41
  }, runOptions?: GitOperationRunOptions): Promise<void>;
41
42
  private stashPushCore;
42
43
  saveSnapshot(repoPath: string, message?: string): Promise<void>;
44
+ private announceStashChanged;
43
45
  }
44
46
  export declare function convertStashesToStdin(stashOrStashes: GitStash | ReadonlyMap<string, GitStashCommit> | undefined): {
45
47
  readonly stdin: string | undefined;
@@ -142,28 +142,37 @@ var StashGitSubProvider = class {
142
142
  } : void 0, void 0, void 0, f.mode)) ?? [];
143
143
  }
144
144
  async deleteStash(repoPath, stashName, sha) {
145
- await this.deleteStashCore(repoPath, stashName, sha);
146
- this.context.hooks?.repository?.onChanged?.(repoPath, ["stash"]);
147
- this.context.hooks?.cache?.onReset?.(repoPath, "stashes");
145
+ await this.deleteStashCore(repoPath, stashName, sha, { announce: true });
148
146
  }
149
- async deleteStashCore(repoPath, stashName, sha) {
147
+ async deleteStashCore(repoPath, stashName, sha, options) {
150
148
  if (!stashName) return void 0;
149
+ if (!options.verified) await this.verifyStashSha(repoPath, stashName, sha);
151
150
  let result;
152
- if (sha) {
153
- result = await this.git.run({
154
- cwd: repoPath,
155
- errors: "ignore"
156
- }, "show", "--format=%H", "--no-patch", stashName);
157
- if (result.stdout.trim() !== sha) throw new Error(l10n.t("Unable to delete stash; mismatch with stash number"));
151
+ try {
152
+ result = await this.git.run({ cwd: repoPath }, "stash", "drop", stashName);
153
+ } finally {
154
+ if (options.announce) this.announceStashChanged(repoPath);
158
155
  }
159
- result = await this.git.run({ cwd: repoPath }, "stash", "drop", stashName);
160
156
  return result.stdout;
161
157
  }
158
+ async verifyStashSha(repoPath, stashName, sha) {
159
+ if (!sha) return;
160
+ if ((await this.git.run({
161
+ cwd: repoPath,
162
+ errors: "ignore"
163
+ }, "show", "--format=%H", "--no-patch", stashName)).stdout.trim() !== sha) throw new Error(l10n.t("Unable to delete stash; mismatch with stash number"));
164
+ }
162
165
  async renameStash(repoPath, stashName, sha, message, stashOnRef) {
163
- await this.deleteStashCore(repoPath, stashName, sha);
164
- await this.git.run({ cwd: repoPath }, "stash", "store", "-m", stashOnRef ? `On ${stashOnRef}: ${message}` : message, sha);
165
- this.context.hooks?.repository?.onChanged?.(repoPath, ["stash"]);
166
- this.context.hooks?.cache?.onReset?.(repoPath, "stashes");
166
+ if (stashName) await this.verifyStashSha(repoPath, stashName, sha);
167
+ try {
168
+ await this.deleteStashCore(repoPath, stashName, sha, {
169
+ announce: false,
170
+ verified: true
171
+ });
172
+ await this.git.run({ cwd: repoPath }, "stash", "store", "-m", stashOnRef ? `On ${stashOnRef}: ${message}` : message, sha);
173
+ } finally {
174
+ this.announceStashChanged(repoPath);
175
+ }
167
176
  }
168
177
  async saveStash(repoPath, message, pathsOrUris, options, runOptions) {
169
178
  const paths = pathsOrUris?.map(toFsPath);
@@ -236,9 +245,15 @@ var StashGitSubProvider = class {
236
245
  if (id == null) return;
237
246
  const args = [];
238
247
  if (message) args.push("-m", message);
239
- await this.git.run({ cwd: repoPath }, "stash", "store", ...args, id);
240
- this.context.hooks?.repository?.onChanged?.(repoPath, ["stash"]);
248
+ try {
249
+ await this.git.run({ cwd: repoPath }, "stash", "store", ...args, id);
250
+ } finally {
251
+ this.announceStashChanged(repoPath);
252
+ }
253
+ }
254
+ announceStashChanged(repoPath) {
241
255
  this.context.hooks?.cache?.onReset?.(repoPath, "stashes");
256
+ this.context.hooks?.repository?.onChanged?.(repoPath, ["stash"]);
242
257
  }
243
258
  };
244
259
  __decorate([gate(), debug()], StashGitSubProvider.prototype, "applyStash", null);
@@ -246,7 +261,7 @@ __decorate([debug()], StashGitSubProvider.prototype, "createStash", null);
246
261
  __decorate([debug()], StashGitSubProvider.prototype, "getStash", null);
247
262
  __decorate([debug()], StashGitSubProvider.prototype, "getStashCommitFiles", null);
248
263
  __decorate([debug()], StashGitSubProvider.prototype, "deleteStash", null);
249
- __decorate([gate()], StashGitSubProvider.prototype, "deleteStashCore", null);
264
+ __decorate([gate((rp, name, sha) => `${rp}\0${name}\0${sha ?? ""}`)], StashGitSubProvider.prototype, "deleteStashCore", null);
250
265
  __decorate([debug()], StashGitSubProvider.prototype, "renameStash", null);
251
266
  __decorate([debug({ args: (repoPath, message, paths) => ({
252
267
  repoPath,
@@ -1 +1 @@
1
- {"version":3,"file":"stash.js","names":[],"sources":["../../../../git-cli/src/providers/stash.ts"],"sourcesContent":["import * as l10n from '@vscode/l10n';\nimport type { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport { StashApplyError, StashPushError } from '@gitlens/git/errors.js';\nimport type { GitStashCommit } from '@gitlens/git/models/commit.js';\nimport { GitCommit, GitCommitIdentity } from '@gitlens/git/models/commit.js';\nimport { GitFileChange } from '@gitlens/git/models/fileChange.js';\nimport type { GitFileStatus } from '@gitlens/git/models/fileStatus.js';\nimport { GitFileWorkingTreeStatus } from '@gitlens/git/models/fileStatus.js';\nimport type { GitStash } from '@gitlens/git/models/stash.js';\nimport type { GitUser } from '@gitlens/git/models/user.js';\nimport type { GitOperationRunOptions } from '@gitlens/git/providers/operations.js';\nimport type { GitStashSubProvider, StashApplyResult } from '@gitlens/git/providers/stash.js';\nimport { countStringLength } from '@gitlens/utils/array.js';\nimport { isCancellationError } from '@gitlens/utils/cancellation.js';\nimport { gate } from '@gitlens/utils/decorators/gate.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { skip } from '@gitlens/utils/iterable.js';\nimport { normalizePath, splitPath } from '@gitlens/utils/path.js';\nimport { getSettledValue } from '@gitlens/utils/promise.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { fileUri, joinUriPath, toFsPath } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport { gitFeaturesByVersion } from '../exec/features.js';\nimport type { Git } from '../exec/git.js';\nimport { getGitCommandError, GitError, GitErrors, maxGitCliLength } from '../exec/git.js';\nimport type { ParsedStash, ParsedStashWithFiles } from '../parsers/logParser.js';\nimport { getStashFilesOnlyLogParser, getStashLogParser } from '../parsers/logParser.js';\nimport { createCommitFileset } from './commitFilesetUtils.js';\n\nexport class StashGitSubProvider implements GitStashSubProvider {\n\tconstructor(\n\t\tprivate readonly context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t) {}\n\n\t@gate()\n\t@debug()\n\tasync applyStash(\n\t\trepoPath: string,\n\t\tstashNameOrSha: string,\n\t\toptions?: { deleteAfter?: boolean; index?: boolean },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<StashApplyResult> {\n\t\tif (!stashNameOrSha) return { conflicted: false };\n\n\t\tconst args = ['stash', options?.deleteAfter ? 'pop' : 'apply'];\n\t\tif (options?.index) {\n\t\t\targs.push('--index');\n\t\t}\n\t\targs.push(stashNameOrSha);\n\t\treturn this.applyStashCore(repoPath, args, options?.deleteAfter ? 'stash-pop' : 'stash-apply', runOptions);\n\t}\n\n\tprivate async applyStashCore(\n\t\trepoPath: string,\n\t\targs: string[],\n\t\tconflictCommand: 'stash-apply' | 'stash-pop',\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<StashApplyResult> {\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, ...runOptions }, ...args);\n\t\t\treturn { conflicted: false };\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\tif (ex instanceof Error) {\n\t\t\t\tconst msg: string = ex.message ?? '';\n\t\t\t\tif (\n\t\t\t\t\t(msg.includes('Auto-merging') && msg.includes('CONFLICT')) ||\n\t\t\t\t\t(ex instanceof GitError &&\n\t\t\t\t\t\t((ex.stdout?.includes('Auto-merging') && ex.stdout.includes('CONFLICT')) ||\n\t\t\t\t\t\t\tex.stdout?.includes('needs merge')))\n\t\t\t\t) {\n\t\t\t\t\tthis.context.hooks?.operations?.onConflicted?.(conflictCommand);\n\t\t\t\t\treturn { conflicted: true };\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'stash-apply',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew StashApplyError(\n\t\t\t\t\t\t{ reason: reason ?? 'other', gitCommand: { repoPath: repoPath, args: args } },\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t} finally {\n\t\t\t// A conflicted, failed or cancelled apply may already have changed the stash list or working tree\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'stashes', 'status');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['stash']);\n\t\t}\n\t}\n\n\t@debug()\n\tasync createStash(repoPath: string, message?: string): Promise<string | undefined> {\n\t\tconst args = ['stash', 'create'];\n\t\tif (message) {\n\t\t\targs.push(message);\n\t\t}\n\n\t\tconst result = await this.git.run({ cwd: repoPath }, ...args);\n\t\treturn result.stdout.trim() || undefined;\n\t}\n\n\t@debug()\n\tasync getStash(\n\t\trepoPath: string,\n\t\toptions?: {\n\t\t\tincludeFiles?: boolean;\n\t\t\treachableFrom?: string;\n\t\t\tsimilarityThreshold?: number | null;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitStash | undefined> {\n\t\tif (repoPath == null) return undefined;\n\n\t\t// Resolve options against config up front so the cache key reflects the actual values used\n\t\t// to produce the cached payload — undefined inputs aren't conflated across config changes.\n\t\tconst cfg = this.context.config;\n\t\tconst includeFiles = options?.includeFiles ?? cfg?.commits.includeFileDetails?.(repoPath) ?? true;\n\t\tconst similarityThreshold = includeFiles\n\t\t\t? (options?.similarityThreshold ?? cfg?.commits.similarityThreshold ?? null)\n\t\t\t: null;\n\t\tconst reachableFrom = options?.reachableFrom;\n\n\t\t// Cache only the unfiltered stash list; reachability projection runs below by testing each\n\t\t// distinct stash parent against `reachableFrom` directly, so re-projecting is cheap\n\t\tconst cacheKey = `f${includeFiles ? 1 : 0}|s${similarityThreshold ?? ''}`;\n\n\t\tconst stash = await this.cache.getStash(\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tasync (commonPath, _cacheable, signal) => {\n\t\t\t\t// Prefer the aggregate signal from the cache; fall back to the caller's cancellation.\n\t\t\t\tsignal ??= cancellation;\n\t\t\t\tconst parser = getStashLogParser(includeFiles);\n\t\t\t\tconst args = [...parser.arguments];\n\n\t\t\t\tif (includeFiles) {\n\t\t\t\t\targs.push(`-M${similarityThreshold == null ? '' : `${similarityThreshold}%`}`);\n\t\t\t\t}\n\n\t\t\t\tconst result = await this.git.run({ cwd: repoPath, cancellation: signal }, 'stash', 'list', ...args);\n\n\t\t\t\tconst currentUser = await this.provider.config.getCurrentUser(repoPath);\n\n\t\t\t\tconst stashes = new Map<string, GitStashCommit>();\n\t\t\t\tfor (const s of parser.parse(result.stdout)) {\n\t\t\t\t\tstashes.set(s.sha, createStash(s, commonPath, currentUser));\n\t\t\t\t}\n\n\t\t\t\treturn { repoPath: commonPath, stashes: stashes };\n\t\t\t},\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\n\t\tif (stash == null || !reachableFrom || !stash.stashes.size) return stash;\n\n\t\t// Copy because the cached `stash.stashes` map is shared and must not be mutated.\n\t\tconst stashes = new Map(stash.stashes);\n\n\t\tconst reachableStashes = new Set<string>();\n\n\t\t// Metadata pass: a stash belongs on `reachableFrom` iff git's auto-prepended\n\t\t// `On <branch>: …` (or `WIP on <branch>: …`) prefix in the stash commit subject names\n\t\t// this branch. `stashOnRef` is parsed from %s in createStash, so this covers autostashes\n\t\t// and custom-reflog stashes too.\n\t\tfor (const [sha, s] of stash.stashes) {\n\t\t\tif (s.stashOnRef === reachableFrom) {\n\t\t\t\treachableStashes.add(sha);\n\t\t\t}\n\t\t}\n\n\t\t// Transitive pass for the rare detached-HEAD-on-stash chain (stash B created while HEAD\n\t\t// pointed at stash A). Such stashes have no `stashOnRef`, but if their parent is a stash\n\t\t// already marked reachable they should follow.\n\t\tlet changed;\n\t\tdo {\n\t\t\tchanged = false;\n\t\t\tfor (const [sha, s] of stash.stashes) {\n\t\t\t\tif (!reachableStashes.has(sha) && s.parents.some(p => reachableStashes.has(p))) {\n\t\t\t\t\treachableStashes.add(sha);\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t}\n\t\t} while (changed);\n\n\t\tfor (const [sha] of stash.stashes) {\n\t\t\tif (!reachableStashes.has(sha)) {\n\t\t\t\tstashes.delete(sha);\n\t\t\t}\n\t\t}\n\n\t\treturn { ...stash, stashes: stashes };\n\t}\n\n\t@debug()\n\tasync getStashCommitFiles(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: { similarityThreshold?: number | null },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitFileChange[]> {\n\t\tconst [stashFilesResult, stashUntrackedFilesResult] = await Promise.allSettled([\n\t\t\t// Don't include untracked files here, because we won't be able to tell them apart from added (and we need the untracked status)\n\t\t\tthis.getStashCommitFilesCore(repoPath, ref, { untracked: false, ...options }, cancellation),\n\t\t\t// Check for any untracked files -- since git doesn't return them via `git stash list` :(\n\t\t\t// See https://stackoverflow.com/questions/12681529/\n\t\t\tthis.getStashCommitFilesCore(repoPath, ref, { untracked: 'only', ...options }, cancellation),\n\t\t]);\n\n\t\tlet files = getSettledValue(stashFilesResult);\n\t\tconst untrackedFiles = getSettledValue(stashUntrackedFilesResult);\n\n\t\tif (files?.length && untrackedFiles?.length) {\n\t\t\tfiles.push(...untrackedFiles);\n\t\t} else {\n\t\t\tfiles = files ?? untrackedFiles;\n\t\t}\n\n\t\treturn files ?? [];\n\t}\n\n\tprivate async getStashCommitFilesCore(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: { similarityThreshold?: number | null; untracked?: boolean | 'only' },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitFileChange[] | undefined> {\n\t\tconst args = [];\n\t\tif (options?.untracked) {\n\t\t\targs.push(options?.untracked === 'only' ? '--only-untracked' : '--include-untracked');\n\t\t}\n\n\t\tconst similarityThreshold = options?.similarityThreshold ?? this.context.config?.commits.similarityThreshold;\n\t\tif (similarityThreshold != null) {\n\t\t\targs.push(`-M${similarityThreshold}%`);\n\t\t}\n\n\t\tconst parser = getStashFilesOnlyLogParser();\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath, cancellation: cancellation },\n\t\t\t'stash',\n\t\t\t'show',\n\t\t\t...args,\n\t\t\t...parser.arguments,\n\t\t\tref,\n\t\t);\n\n\t\tconst repoUri = fileUri(normalizePath(repoPath));\n\t\tfor (const s of parser.parse(result.stdout)) {\n\t\t\treturn (\n\t\t\t\ts.files?.map(\n\t\t\t\t\tf =>\n\t\t\t\t\t\tnew GitFileChange(\n\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\tf.path,\n\t\t\t\t\t\t\t(options?.untracked === 'only'\n\t\t\t\t\t\t\t\t? GitFileWorkingTreeStatus.Untracked\n\t\t\t\t\t\t\t\t: f.status) as GitFileStatus,\n\t\t\t\t\t\t\tjoinUriPath(repoUri, normalizePath(f.path)),\n\t\t\t\t\t\t\tf.originalPath,\n\t\t\t\t\t\t\tf.originalPath != null ? joinUriPath(repoUri, normalizePath(f.originalPath)) : undefined,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tf.additions || f.deletions\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\tadditions: f.additions ?? 0,\n\t\t\t\t\t\t\t\t\t\tdeletions: f.deletions ?? 0,\n\t\t\t\t\t\t\t\t\t\tchanges: 0,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tf.mode,\n\t\t\t\t\t\t),\n\t\t\t\t) ?? []\n\t\t\t);\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t@debug()\n\tasync deleteStash(repoPath: string, stashName: string, sha?: string): Promise<void> {\n\t\tawait this.deleteStashCore(repoPath, stashName, sha);\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['stash']);\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'stashes');\n\t}\n\n\t@gate()\n\tprivate async deleteStashCore(repoPath: string, stashName: string, sha?: string): Promise<string | undefined> {\n\t\tif (!stashName) return undefined;\n\n\t\tlet result;\n\t\tif (sha) {\n\t\t\tresult = await this.git.run(\n\t\t\t\t{ cwd: repoPath, errors: 'ignore' },\n\t\t\t\t'show',\n\t\t\t\t'--format=%H',\n\t\t\t\t'--no-patch',\n\t\t\t\tstashName,\n\t\t\t);\n\t\t\tif (result.stdout.trim() !== sha) {\n\t\t\t\tthrow new Error(l10n.t('Unable to delete stash; mismatch with stash number'));\n\t\t\t}\n\t\t}\n\n\t\tresult = await this.git.run({ cwd: repoPath }, 'stash', 'drop', stashName);\n\t\treturn result.stdout;\n\t}\n\n\t@debug()\n\tasync renameStash(\n\t\trepoPath: string,\n\t\tstashName: string,\n\t\tsha: string,\n\t\tmessage: string,\n\t\tstashOnRef?: string,\n\t): Promise<void> {\n\t\tawait this.deleteStashCore(repoPath, stashName, sha);\n\t\tawait this.git.run(\n\t\t\t{ cwd: repoPath },\n\t\t\t'stash',\n\t\t\t'store',\n\t\t\t'-m',\n\t\t\tstashOnRef ? `On ${stashOnRef}: ${message}` : message,\n\t\t\tsha,\n\t\t);\n\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['stash']);\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'stashes');\n\t}\n\n\t@debug({ args: (repoPath, message, paths) => ({ repoPath: repoPath, message: message, paths: paths?.length }) })\n\tasync saveStash(\n\t\trepoPath: string,\n\t\tmessage?: string,\n\t\tpathsOrUris?: (string | Uri)[],\n\t\toptions?: { includeUntracked?: boolean; keepIndex?: boolean; onlyStaged?: boolean },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst paths = pathsOrUris?.map(toFsPath);\n\t\tif (!paths?.length) {\n\t\t\tawait this.stashPushCore(repoPath, message, options, runOptions);\n\t\t\treturn;\n\t\t}\n\n\t\tawait this.git.ensureSupports('git:stash:push:pathspecs', (requiredVersion, installedVersion) =>\n\t\t\tl10n.t(\n\t\t\t\t'Stashing individual files requires a newer version of Git (>= {0}) than is currently installed ({1}). Please retry by stashing everything or install a more recent version of Git and try again.',\n\t\t\t\trequiredVersion,\n\t\t\t\tinstalledVersion,\n\t\t\t),\n\t\t);\n\n\t\tconst pathspecs = paths.map(p => `./${splitPath(p, repoPath)[0]}`);\n\n\t\tlet stdin = await this.git.supports('git:stash:push:stdin');\n\t\tif (stdin && options?.onlyStaged && paths.length) {\n\t\t\t// Since Git doesn't support --staged with --pathspec-from-file try to pass them in directly\n\t\t\tstdin = false;\n\t\t}\n\n\t\t// If we don't support stdin, then error out if we are over the maximum allowed git cli length\n\t\tif (!stdin && countStringLength(pathspecs) > maxGitCliLength) {\n\t\t\tawait this.git.ensureSupports('git:stash:push:stdin', (requiredVersion, installedVersion) =>\n\t\t\t\tl10n.t(\n\t\t\t\t\t'Stashing so many files ({0}) at once requires a newer version of Git (>= {1}) than is currently installed ({2}). Please retry by stashing fewer files or install a more recent version of Git and try again.',\n\t\t\t\t\tpathspecs.length,\n\t\t\t\t\trequiredVersion,\n\t\t\t\t\tinstalledVersion,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tawait this.stashPushCore(\n\t\t\trepoPath,\n\t\t\tmessage,\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\tpathspecs: pathspecs,\n\t\t\t\tstdin: stdin,\n\t\t\t},\n\t\t\trunOptions,\n\t\t);\n\t}\n\n\tprivate async stashPushCore(\n\t\trepoPath: string,\n\t\tmessage?: string,\n\t\toptions?: {\n\t\t\tincludeUntracked?: boolean;\n\t\t\tkeepIndex?: boolean;\n\t\t\tonlyStaged?: boolean;\n\t\t\tpathspecs?: string[];\n\t\t\tstdin?: boolean;\n\t\t},\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst params = ['stash', 'push'];\n\n\t\tif ((options?.includeUntracked || options?.pathspecs?.length) && !options?.onlyStaged) {\n\t\t\tparams.push('--include-untracked');\n\t\t}\n\n\t\t// `git stash push --keep-index --include-untracked -- <pathspec>` hits a bug in git when the\n\t\t// pathspec names an untracked file: the restoring checkout can't match an untracked path in the\n\t\t// index tree, so it fails and the staged changes are lost.\n\t\t//\n\t\t// $ mkdir stash-test && cd stash-test && git init\n\t\t// $ echo a > a.txt\n\t\t// $ git add a.txt\n\t\t// $ git commit -m init\n\t\t// $ echo b > b.txt\n\t\t// $ git stash push --keep-index --include-untracked -- b.txt\n\t\t// Saved working directory and index state WIP on main: 8a280fe init\n\t\t// error: pathspec ':(prefix:0)b.txt' did not match any file(s) known to git\n\t\t//\n\t\t// Only suppress --keep-index for that case — when the selection actually includes untracked\n\t\t// files (`includeUntracked`) AND we're stashing by pathspec. Keying off `includeUntracked` (the\n\t\t// caller's intent) rather than the `--include-untracked` flag is deliberate: we add\n\t\t// `--include-untracked` to every pathspec push above as a safety net, but a tracked-only\n\t\t// selection can — and must — still keep the index intact.\n\t\tif (options?.keepIndex && !(options?.includeUntracked && options?.pathspecs?.length)) {\n\t\t\tparams.push('--keep-index');\n\t\t}\n\n\t\tif (options?.onlyStaged) {\n\t\t\tif (await this.git.supports('git:stash:push:staged')) {\n\t\t\t\tparams.push('--staged');\n\t\t\t} else {\n\t\t\t\tthrow new Error(\n\t\t\t\t\tl10n.t(\n\t\t\t\t\t\t'Git version {0} or higher is required for --staged',\n\t\t\t\t\t\tString(gitFeaturesByVersion.get('git:stash:push:staged')),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (message) {\n\t\t\tparams.push('-m', message);\n\t\t}\n\n\t\tlet stdin;\n\t\tif (options?.pathspecs?.length) {\n\t\t\tif (options.stdin) {\n\t\t\t\tstdin = options.pathspecs.join('\\0');\n\t\t\t\tparams.push('--pathspec-from-file=-', '--pathspec-file-nul', '--');\n\t\t\t} else {\n\t\t\t\tparams.push('--', ...options.pathspecs);\n\t\t\t}\n\t\t} else {\n\t\t\tparams.push('--');\n\t\t}\n\n\t\tlet nothingToSave = false;\n\t\ttry {\n\t\t\tconst result = await this.git.run({ cwd: repoPath, ...runOptions, stdin: stdin }, ...params);\n\t\t\tif (GitErrors.stashNothingToSave.test(result.stdout)) {\n\t\t\t\tnothingToSave = true;\n\t\t\t\tthrow new StashPushError({\n\t\t\t\t\treason: 'nothingToSave',\n\t\t\t\t\tgitCommand: { repoPath: repoPath, args: params },\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof StashPushError || isCancellationError(ex)) throw ex;\n\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'stash-push',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew StashPushError(\n\t\t\t\t\t\t{ reason: reason ?? 'other', gitCommand: { repoPath: repoPath, args: params } },\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t} finally {\n\t\t\t// A failed or cancelled push may already have stashed, and reset the working tree; one with nothing to\n\t\t\t// save changed nothing\n\t\t\tif (!nothingToSave) {\n\t\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'stashes', 'status');\n\t\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['stash']);\n\t\t\t}\n\t\t}\n\t}\n\n\t@debug()\n\tasync saveSnapshot(repoPath: string, message?: string): Promise<void> {\n\t\tconst result = await this.git.run({ cwd: repoPath }, 'stash', 'create');\n\t\tconst id = result.stdout.trim() || undefined;\n\t\tif (id == null) return;\n\n\t\tconst args = [];\n\t\tif (message) {\n\t\t\targs.push('-m', message);\n\t\t}\n\t\tawait this.git.run({ cwd: repoPath }, 'stash', 'store', ...args, id);\n\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['stash']);\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'stashes');\n\t}\n}\n\nexport function convertStashesToStdin(stashOrStashes: GitStash | ReadonlyMap<string, GitStashCommit> | undefined): {\n\treadonly stdin: string | undefined;\n\treadonly stashes: Map<string, GitStashCommit>;\n\treadonly remappedIds: Map<string, string>;\n} {\n\tconst remappedIds = new Map<string, string>();\n\tif (stashOrStashes == null) return { stdin: undefined, stashes: new Map(), remappedIds: remappedIds };\n\n\tlet stdin: string | undefined;\n\tconst original = 'stashes' in stashOrStashes ? stashOrStashes.stashes : stashOrStashes;\n\tconst stashes = new Map<string, GitStashCommit>(original);\n\n\tif (original.size) {\n\t\tstdin = '';\n\t\tfor (const stash of original.values()) {\n\t\t\tstdin += `${stash.sha.substring(0, 9)}\\n`;\n\t\t\t// Include the stash's 2nd (index files) and 3rd (untracked files) parents (if they aren't already in the map)\n\t\t\tfor (const p of skip(stash.parents, 1)) {\n\t\t\t\tremappedIds.set(p, stash.sha);\n\n\t\t\t\tif (!stashes.has(p)) {\n\t\t\t\t\tstashes.set(p, stash);\n\t\t\t\t\tstdin += `${p.substring(0, 9)}\\n`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { stdin: stdin || undefined, stashes: stashes, remappedIds: remappedIds };\n}\n\nconst stashSummaryRegex =\n\t// oxlint-disable-next-line no-control-regex\n\t/(?:(?:(?<wip>WIP) on|On) (?<onref>[^/](?!.*\\/\\.)(?!.*\\.\\.)(?!.*\\/\\/)(?!.*@\\{)[^\\x00-\\x1F\\x7F ~^:?*[\\\\]+[^./]):\\s*)?(?<summary>.*)$/s;\n\nfunction createStash(\n\ts: ParsedStash | ParsedStashWithFiles,\n\trepoPath: string,\n\tcurrentUser: GitUser | undefined,\n): GitStashCommit {\n\t// `onRef` comes from the commit subject (%s), which git always prefixes with `On <branch>: …`\n\t// or `WIP on <branch>: …`. This holds even when the reflog message was customized\n\t// (autostash, `git stash store -m \"…\"`), so it's a reliable source\n\tlet onRef: string | undefined;\n\tconst subjectMatch = stashSummaryRegex.exec((s.commitSubject ?? '').trim());\n\tif (subjectMatch?.groups?.onref) {\n\t\tonRef = subjectMatch.groups.onref;\n\t}\n\n\t// The user-visible display message is derived from the reflog subject (%gs) so that short\n\t// custom messages like \"wip\", \"q\", or \"show args\" stay as the user wrote them instead of\n\t// being replaced by the verbose git-auto subject\n\tlet message = s.summary.trim();\n\tconst reflogMatch = stashSummaryRegex.exec(message);\n\tif (reflogMatch?.groups != null) {\n\t\tconst summary = reflogMatch.groups.summary.trim();\n\t\tif (summary.length === 0) {\n\t\t\tmessage = 'WIP';\n\t\t} else if (reflogMatch.groups.wip) {\n\t\t\tmessage = `WIP: ${summary}`;\n\t\t} else {\n\t\t\tmessage = summary;\n\t\t}\n\t}\n\n\tconst index = message.indexOf('\\n');\n\n\treturn new GitCommit(\n\t\trepoPath,\n\t\ts.sha,\n\t\tnew GitCommitIdentity(\n\t\t\tcurrentUser?.name ?? '',\n\t\t\tcurrentUser?.email,\n\t\t\tnew Date(Number(s.authorDate) * 1000),\n\t\t\tundefined,\n\t\t\ttrue,\n\t\t),\n\t\tnew GitCommitIdentity(\n\t\t\tcurrentUser?.name ?? '',\n\t\t\tcurrentUser?.email,\n\t\t\tnew Date(Number(s.committedDate) * 1000),\n\t\t\tundefined,\n\t\t\ttrue,\n\t\t),\n\t\tindex !== -1 ? message.substring(0, index) : message,\n\t\ts.parents.split(' ') ?? [],\n\t\tmessage,\n\t\tcreateCommitFileset(s, repoPath, undefined),\n\t\ts.stats,\n\t\tundefined,\n\t\tundefined,\n\t\ts.stashName,\n\t\tonRef,\n\t) as GitStashCommit;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8BA,IAAa,sBAAb,MAAgE;CAE7C;CACA;CACA;CACA;CAJlB,YACC,SACA,KACA,OACA,UACC;EAJg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AE,OACF,KAAA,GACA,KAAA,GACA,EAAE,WACF,KACD;AACD"}
1
+ {"version":3,"file":"stash.js","names":[],"sources":["../../../../git-cli/src/providers/stash.ts"],"sourcesContent":["import * as l10n from '@vscode/l10n';\nimport type { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport { StashApplyError, StashPushError } from '@gitlens/git/errors.js';\nimport type { GitStashCommit } from '@gitlens/git/models/commit.js';\nimport { GitCommit, GitCommitIdentity } from '@gitlens/git/models/commit.js';\nimport { GitFileChange } from '@gitlens/git/models/fileChange.js';\nimport type { GitFileStatus } from '@gitlens/git/models/fileStatus.js';\nimport { GitFileWorkingTreeStatus } from '@gitlens/git/models/fileStatus.js';\nimport type { GitStash } from '@gitlens/git/models/stash.js';\nimport type { GitUser } from '@gitlens/git/models/user.js';\nimport type { GitOperationRunOptions } from '@gitlens/git/providers/operations.js';\nimport type { GitStashSubProvider, StashApplyResult } from '@gitlens/git/providers/stash.js';\nimport { countStringLength } from '@gitlens/utils/array.js';\nimport { isCancellationError } from '@gitlens/utils/cancellation.js';\nimport { gate } from '@gitlens/utils/decorators/gate.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { skip } from '@gitlens/utils/iterable.js';\nimport { normalizePath, splitPath } from '@gitlens/utils/path.js';\nimport { getSettledValue } from '@gitlens/utils/promise.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { fileUri, joinUriPath, toFsPath } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport { gitFeaturesByVersion } from '../exec/features.js';\nimport type { Git } from '../exec/git.js';\nimport { getGitCommandError, GitError, GitErrors, maxGitCliLength } from '../exec/git.js';\nimport type { ParsedStash, ParsedStashWithFiles } from '../parsers/logParser.js';\nimport { getStashFilesOnlyLogParser, getStashLogParser } from '../parsers/logParser.js';\nimport { createCommitFileset } from './commitFilesetUtils.js';\n\nexport class StashGitSubProvider implements GitStashSubProvider {\n\tconstructor(\n\t\tprivate readonly context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t) {}\n\n\t@gate()\n\t@debug()\n\tasync applyStash(\n\t\trepoPath: string,\n\t\tstashNameOrSha: string,\n\t\toptions?: { deleteAfter?: boolean; index?: boolean },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<StashApplyResult> {\n\t\tif (!stashNameOrSha) return { conflicted: false };\n\n\t\tconst args = ['stash', options?.deleteAfter ? 'pop' : 'apply'];\n\t\tif (options?.index) {\n\t\t\targs.push('--index');\n\t\t}\n\t\targs.push(stashNameOrSha);\n\t\treturn this.applyStashCore(repoPath, args, options?.deleteAfter ? 'stash-pop' : 'stash-apply', runOptions);\n\t}\n\n\tprivate async applyStashCore(\n\t\trepoPath: string,\n\t\targs: string[],\n\t\tconflictCommand: 'stash-apply' | 'stash-pop',\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<StashApplyResult> {\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, ...runOptions }, ...args);\n\t\t\treturn { conflicted: false };\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex)) throw ex;\n\n\t\t\tif (ex instanceof Error) {\n\t\t\t\tconst msg: string = ex.message ?? '';\n\t\t\t\tif (\n\t\t\t\t\t(msg.includes('Auto-merging') && msg.includes('CONFLICT')) ||\n\t\t\t\t\t(ex instanceof GitError &&\n\t\t\t\t\t\t((ex.stdout?.includes('Auto-merging') && ex.stdout.includes('CONFLICT')) ||\n\t\t\t\t\t\t\tex.stdout?.includes('needs merge')))\n\t\t\t\t) {\n\t\t\t\t\tthis.context.hooks?.operations?.onConflicted?.(conflictCommand);\n\t\t\t\t\treturn { conflicted: true };\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'stash-apply',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew StashApplyError(\n\t\t\t\t\t\t{ reason: reason ?? 'other', gitCommand: { repoPath: repoPath, args: args } },\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t} finally {\n\t\t\t// A conflicted, failed or cancelled apply may already have changed the stash list or working tree\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'stashes', 'status');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['stash']);\n\t\t}\n\t}\n\n\t@debug()\n\tasync createStash(repoPath: string, message?: string): Promise<string | undefined> {\n\t\tconst args = ['stash', 'create'];\n\t\tif (message) {\n\t\t\targs.push(message);\n\t\t}\n\n\t\tconst result = await this.git.run({ cwd: repoPath }, ...args);\n\t\treturn result.stdout.trim() || undefined;\n\t}\n\n\t@debug()\n\tasync getStash(\n\t\trepoPath: string,\n\t\toptions?: {\n\t\t\tincludeFiles?: boolean;\n\t\t\treachableFrom?: string;\n\t\t\tsimilarityThreshold?: number | null;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitStash | undefined> {\n\t\tif (repoPath == null) return undefined;\n\n\t\t// Resolve options against config up front so the cache key reflects the actual values used\n\t\t// to produce the cached payload — undefined inputs aren't conflated across config changes.\n\t\tconst cfg = this.context.config;\n\t\tconst includeFiles = options?.includeFiles ?? cfg?.commits.includeFileDetails?.(repoPath) ?? true;\n\t\tconst similarityThreshold = includeFiles\n\t\t\t? (options?.similarityThreshold ?? cfg?.commits.similarityThreshold ?? null)\n\t\t\t: null;\n\t\tconst reachableFrom = options?.reachableFrom;\n\n\t\t// Cache only the unfiltered stash list; reachability projection runs below by testing each\n\t\t// distinct stash parent against `reachableFrom` directly, so re-projecting is cheap\n\t\tconst cacheKey = `f${includeFiles ? 1 : 0}|s${similarityThreshold ?? ''}`;\n\n\t\tconst stash = await this.cache.getStash(\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tasync (commonPath, _cacheable, signal) => {\n\t\t\t\t// Prefer the aggregate signal from the cache; fall back to the caller's cancellation.\n\t\t\t\tsignal ??= cancellation;\n\t\t\t\tconst parser = getStashLogParser(includeFiles);\n\t\t\t\tconst args = [...parser.arguments];\n\n\t\t\t\tif (includeFiles) {\n\t\t\t\t\targs.push(`-M${similarityThreshold == null ? '' : `${similarityThreshold}%`}`);\n\t\t\t\t}\n\n\t\t\t\tconst result = await this.git.run({ cwd: repoPath, cancellation: signal }, 'stash', 'list', ...args);\n\n\t\t\t\tconst currentUser = await this.provider.config.getCurrentUser(repoPath);\n\n\t\t\t\tconst stashes = new Map<string, GitStashCommit>();\n\t\t\t\tfor (const s of parser.parse(result.stdout)) {\n\t\t\t\t\tstashes.set(s.sha, createStash(s, commonPath, currentUser));\n\t\t\t\t}\n\n\t\t\t\treturn { repoPath: commonPath, stashes: stashes };\n\t\t\t},\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\n\t\tif (stash == null || !reachableFrom || !stash.stashes.size) return stash;\n\n\t\t// Copy because the cached `stash.stashes` map is shared and must not be mutated.\n\t\tconst stashes = new Map(stash.stashes);\n\n\t\tconst reachableStashes = new Set<string>();\n\n\t\t// Metadata pass: a stash belongs on `reachableFrom` iff git's auto-prepended\n\t\t// `On <branch>: …` (or `WIP on <branch>: …`) prefix in the stash commit subject names\n\t\t// this branch. `stashOnRef` is parsed from %s in createStash, so this covers autostashes\n\t\t// and custom-reflog stashes too.\n\t\tfor (const [sha, s] of stash.stashes) {\n\t\t\tif (s.stashOnRef === reachableFrom) {\n\t\t\t\treachableStashes.add(sha);\n\t\t\t}\n\t\t}\n\n\t\t// Transitive pass for the rare detached-HEAD-on-stash chain (stash B created while HEAD\n\t\t// pointed at stash A). Such stashes have no `stashOnRef`, but if their parent is a stash\n\t\t// already marked reachable they should follow.\n\t\tlet changed;\n\t\tdo {\n\t\t\tchanged = false;\n\t\t\tfor (const [sha, s] of stash.stashes) {\n\t\t\t\tif (!reachableStashes.has(sha) && s.parents.some(p => reachableStashes.has(p))) {\n\t\t\t\t\treachableStashes.add(sha);\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t}\n\t\t} while (changed);\n\n\t\tfor (const [sha] of stash.stashes) {\n\t\t\tif (!reachableStashes.has(sha)) {\n\t\t\t\tstashes.delete(sha);\n\t\t\t}\n\t\t}\n\n\t\treturn { ...stash, stashes: stashes };\n\t}\n\n\t@debug()\n\tasync getStashCommitFiles(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: { similarityThreshold?: number | null },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitFileChange[]> {\n\t\tconst [stashFilesResult, stashUntrackedFilesResult] = await Promise.allSettled([\n\t\t\t// Don't include untracked files here, because we won't be able to tell them apart from added (and we need the untracked status)\n\t\t\tthis.getStashCommitFilesCore(repoPath, ref, { untracked: false, ...options }, cancellation),\n\t\t\t// Check for any untracked files -- since git doesn't return them via `git stash list` :(\n\t\t\t// See https://stackoverflow.com/questions/12681529/\n\t\t\tthis.getStashCommitFilesCore(repoPath, ref, { untracked: 'only', ...options }, cancellation),\n\t\t]);\n\n\t\tlet files = getSettledValue(stashFilesResult);\n\t\tconst untrackedFiles = getSettledValue(stashUntrackedFilesResult);\n\n\t\tif (files?.length && untrackedFiles?.length) {\n\t\t\tfiles.push(...untrackedFiles);\n\t\t} else {\n\t\t\tfiles = files ?? untrackedFiles;\n\t\t}\n\n\t\treturn files ?? [];\n\t}\n\n\tprivate async getStashCommitFilesCore(\n\t\trepoPath: string,\n\t\tref: string,\n\t\toptions?: { similarityThreshold?: number | null; untracked?: boolean | 'only' },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitFileChange[] | undefined> {\n\t\tconst args = [];\n\t\tif (options?.untracked) {\n\t\t\targs.push(options?.untracked === 'only' ? '--only-untracked' : '--include-untracked');\n\t\t}\n\n\t\tconst similarityThreshold = options?.similarityThreshold ?? this.context.config?.commits.similarityThreshold;\n\t\tif (similarityThreshold != null) {\n\t\t\targs.push(`-M${similarityThreshold}%`);\n\t\t}\n\n\t\tconst parser = getStashFilesOnlyLogParser();\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath, cancellation: cancellation },\n\t\t\t'stash',\n\t\t\t'show',\n\t\t\t...args,\n\t\t\t...parser.arguments,\n\t\t\tref,\n\t\t);\n\n\t\tconst repoUri = fileUri(normalizePath(repoPath));\n\t\tfor (const s of parser.parse(result.stdout)) {\n\t\t\treturn (\n\t\t\t\ts.files?.map(\n\t\t\t\t\tf =>\n\t\t\t\t\t\tnew GitFileChange(\n\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\tf.path,\n\t\t\t\t\t\t\t(options?.untracked === 'only'\n\t\t\t\t\t\t\t\t? GitFileWorkingTreeStatus.Untracked\n\t\t\t\t\t\t\t\t: f.status) as GitFileStatus,\n\t\t\t\t\t\t\tjoinUriPath(repoUri, normalizePath(f.path)),\n\t\t\t\t\t\t\tf.originalPath,\n\t\t\t\t\t\t\tf.originalPath != null ? joinUriPath(repoUri, normalizePath(f.originalPath)) : undefined,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tf.additions || f.deletions\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\tadditions: f.additions ?? 0,\n\t\t\t\t\t\t\t\t\t\tdeletions: f.deletions ?? 0,\n\t\t\t\t\t\t\t\t\t\tchanges: 0,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tf.mode,\n\t\t\t\t\t\t),\n\t\t\t\t) ?? []\n\t\t\t);\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t@debug()\n\tasync deleteStash(repoPath: string, stashName: string, sha?: string): Promise<void> {\n\t\tawait this.deleteStashCore(repoPath, stashName, sha, { announce: true });\n\t}\n\n\t// Keyed without `options`, so a delete and a rename of the same stash share one drop: a second drop would take\n\t// the stash that moved up into its place\n\t@gate((rp, name, sha) => `${rp}\\0${name}\\0${sha ?? ''}`)\n\tprivate async deleteStashCore(\n\t\trepoPath: string,\n\t\tstashName: string,\n\t\tsha: string | undefined,\n\t\toptions: { announce: boolean; verified?: boolean },\n\t): Promise<string | undefined> {\n\t\tif (!stashName) return undefined;\n\n\t\tif (!options.verified) {\n\t\t\tawait this.verifyStashSha(repoPath, stashName, sha);\n\t\t}\n\n\t\tlet result;\n\t\ttry {\n\t\t\tresult = await this.git.run({ cwd: repoPath }, 'stash', 'drop', stashName);\n\t\t} finally {\n\t\t\tif (options.announce) {\n\t\t\t\tthis.announceStashChanged(repoPath);\n\t\t\t}\n\t\t}\n\t\treturn result.stdout;\n\t}\n\n\tprivate async verifyStashSha(repoPath: string, stashName: string, sha: string | undefined): Promise<void> {\n\t\tif (!sha) return;\n\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath, errors: 'ignore' },\n\t\t\t'show',\n\t\t\t'--format=%H',\n\t\t\t'--no-patch',\n\t\t\tstashName,\n\t\t);\n\t\tif (result.stdout.trim() !== sha) {\n\t\t\tthrow new Error(l10n.t('Unable to delete stash; mismatch with stash number'));\n\t\t}\n\t}\n\n\t@debug()\n\tasync renameStash(\n\t\trepoPath: string,\n\t\tstashName: string,\n\t\tsha: string,\n\t\tmessage: string,\n\t\tstashOnRef?: string,\n\t): Promise<void> {\n\t\tif (stashName) {\n\t\t\tawait this.verifyStashSha(repoPath, stashName, sha);\n\t\t}\n\n\t\t// The drop and the store announce once, after both ran, even if the store fails\n\t\ttry {\n\t\t\tawait this.deleteStashCore(repoPath, stashName, sha, { announce: false, verified: true });\n\t\t\tawait this.git.run(\n\t\t\t\t{ cwd: repoPath },\n\t\t\t\t'stash',\n\t\t\t\t'store',\n\t\t\t\t'-m',\n\t\t\t\tstashOnRef ? `On ${stashOnRef}: ${message}` : message,\n\t\t\t\tsha,\n\t\t\t);\n\t\t} finally {\n\t\t\tthis.announceStashChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug({ args: (repoPath, message, paths) => ({ repoPath: repoPath, message: message, paths: paths?.length }) })\n\tasync saveStash(\n\t\trepoPath: string,\n\t\tmessage?: string,\n\t\tpathsOrUris?: (string | Uri)[],\n\t\toptions?: { includeUntracked?: boolean; keepIndex?: boolean; onlyStaged?: boolean },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst paths = pathsOrUris?.map(toFsPath);\n\t\tif (!paths?.length) {\n\t\t\tawait this.stashPushCore(repoPath, message, options, runOptions);\n\t\t\treturn;\n\t\t}\n\n\t\tawait this.git.ensureSupports('git:stash:push:pathspecs', (requiredVersion, installedVersion) =>\n\t\t\tl10n.t(\n\t\t\t\t'Stashing individual files requires a newer version of Git (>= {0}) than is currently installed ({1}). Please retry by stashing everything or install a more recent version of Git and try again.',\n\t\t\t\trequiredVersion,\n\t\t\t\tinstalledVersion,\n\t\t\t),\n\t\t);\n\n\t\tconst pathspecs = paths.map(p => `./${splitPath(p, repoPath)[0]}`);\n\n\t\tlet stdin = await this.git.supports('git:stash:push:stdin');\n\t\tif (stdin && options?.onlyStaged && paths.length) {\n\t\t\t// Since Git doesn't support --staged with --pathspec-from-file try to pass them in directly\n\t\t\tstdin = false;\n\t\t}\n\n\t\t// If we don't support stdin, then error out if we are over the maximum allowed git cli length\n\t\tif (!stdin && countStringLength(pathspecs) > maxGitCliLength) {\n\t\t\tawait this.git.ensureSupports('git:stash:push:stdin', (requiredVersion, installedVersion) =>\n\t\t\t\tl10n.t(\n\t\t\t\t\t'Stashing so many files ({0}) at once requires a newer version of Git (>= {1}) than is currently installed ({2}). Please retry by stashing fewer files or install a more recent version of Git and try again.',\n\t\t\t\t\tpathspecs.length,\n\t\t\t\t\trequiredVersion,\n\t\t\t\t\tinstalledVersion,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tawait this.stashPushCore(\n\t\t\trepoPath,\n\t\t\tmessage,\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\tpathspecs: pathspecs,\n\t\t\t\tstdin: stdin,\n\t\t\t},\n\t\t\trunOptions,\n\t\t);\n\t}\n\n\tprivate async stashPushCore(\n\t\trepoPath: string,\n\t\tmessage?: string,\n\t\toptions?: {\n\t\t\tincludeUntracked?: boolean;\n\t\t\tkeepIndex?: boolean;\n\t\t\tonlyStaged?: boolean;\n\t\t\tpathspecs?: string[];\n\t\t\tstdin?: boolean;\n\t\t},\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst params = ['stash', 'push'];\n\n\t\tif ((options?.includeUntracked || options?.pathspecs?.length) && !options?.onlyStaged) {\n\t\t\tparams.push('--include-untracked');\n\t\t}\n\n\t\t// `git stash push --keep-index --include-untracked -- <pathspec>` hits a bug in git when the\n\t\t// pathspec names an untracked file: the restoring checkout can't match an untracked path in the\n\t\t// index tree, so it fails and the staged changes are lost.\n\t\t//\n\t\t// $ mkdir stash-test && cd stash-test && git init\n\t\t// $ echo a > a.txt\n\t\t// $ git add a.txt\n\t\t// $ git commit -m init\n\t\t// $ echo b > b.txt\n\t\t// $ git stash push --keep-index --include-untracked -- b.txt\n\t\t// Saved working directory and index state WIP on main: 8a280fe init\n\t\t// error: pathspec ':(prefix:0)b.txt' did not match any file(s) known to git\n\t\t//\n\t\t// Only suppress --keep-index for that case — when the selection actually includes untracked\n\t\t// files (`includeUntracked`) AND we're stashing by pathspec. Keying off `includeUntracked` (the\n\t\t// caller's intent) rather than the `--include-untracked` flag is deliberate: we add\n\t\t// `--include-untracked` to every pathspec push above as a safety net, but a tracked-only\n\t\t// selection can — and must — still keep the index intact.\n\t\tif (options?.keepIndex && !(options?.includeUntracked && options?.pathspecs?.length)) {\n\t\t\tparams.push('--keep-index');\n\t\t}\n\n\t\tif (options?.onlyStaged) {\n\t\t\tif (await this.git.supports('git:stash:push:staged')) {\n\t\t\t\tparams.push('--staged');\n\t\t\t} else {\n\t\t\t\tthrow new Error(\n\t\t\t\t\tl10n.t(\n\t\t\t\t\t\t'Git version {0} or higher is required for --staged',\n\t\t\t\t\t\tString(gitFeaturesByVersion.get('git:stash:push:staged')),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (message) {\n\t\t\tparams.push('-m', message);\n\t\t}\n\n\t\tlet stdin;\n\t\tif (options?.pathspecs?.length) {\n\t\t\tif (options.stdin) {\n\t\t\t\tstdin = options.pathspecs.join('\\0');\n\t\t\t\tparams.push('--pathspec-from-file=-', '--pathspec-file-nul', '--');\n\t\t\t} else {\n\t\t\t\tparams.push('--', ...options.pathspecs);\n\t\t\t}\n\t\t} else {\n\t\t\tparams.push('--');\n\t\t}\n\n\t\tlet nothingToSave = false;\n\t\ttry {\n\t\t\tconst result = await this.git.run({ cwd: repoPath, ...runOptions, stdin: stdin }, ...params);\n\t\t\tif (GitErrors.stashNothingToSave.test(result.stdout)) {\n\t\t\t\tnothingToSave = true;\n\t\t\t\tthrow new StashPushError({\n\t\t\t\t\treason: 'nothingToSave',\n\t\t\t\t\tgitCommand: { repoPath: repoPath, args: params },\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof StashPushError || isCancellationError(ex)) throw ex;\n\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'stash-push',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew StashPushError(\n\t\t\t\t\t\t{ reason: reason ?? 'other', gitCommand: { repoPath: repoPath, args: params } },\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t} finally {\n\t\t\t// A failed or cancelled push may already have stashed, and reset the working tree; one with nothing to\n\t\t\t// save changed nothing\n\t\t\tif (!nothingToSave) {\n\t\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'stashes', 'status');\n\t\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['stash']);\n\t\t\t}\n\t\t}\n\t}\n\n\t@debug()\n\tasync saveSnapshot(repoPath: string, message?: string): Promise<void> {\n\t\tconst result = await this.git.run({ cwd: repoPath }, 'stash', 'create');\n\t\tconst id = result.stdout.trim() || undefined;\n\t\tif (id == null) return;\n\n\t\tconst args = [];\n\t\tif (message) {\n\t\t\targs.push('-m', message);\n\t\t}\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'stash', 'store', ...args, id);\n\t\t} finally {\n\t\t\tthis.announceStashChanged(repoPath);\n\t\t}\n\t}\n\n\tprivate announceStashChanged(repoPath: string): void {\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'stashes');\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['stash']);\n\t}\n}\n\nexport function convertStashesToStdin(stashOrStashes: GitStash | ReadonlyMap<string, GitStashCommit> | undefined): {\n\treadonly stdin: string | undefined;\n\treadonly stashes: Map<string, GitStashCommit>;\n\treadonly remappedIds: Map<string, string>;\n} {\n\tconst remappedIds = new Map<string, string>();\n\tif (stashOrStashes == null) return { stdin: undefined, stashes: new Map(), remappedIds: remappedIds };\n\n\tlet stdin: string | undefined;\n\tconst original = 'stashes' in stashOrStashes ? stashOrStashes.stashes : stashOrStashes;\n\tconst stashes = new Map<string, GitStashCommit>(original);\n\n\tif (original.size) {\n\t\tstdin = '';\n\t\tfor (const stash of original.values()) {\n\t\t\tstdin += `${stash.sha.substring(0, 9)}\\n`;\n\t\t\t// Include the stash's 2nd (index files) and 3rd (untracked files) parents (if they aren't already in the map)\n\t\t\tfor (const p of skip(stash.parents, 1)) {\n\t\t\t\tremappedIds.set(p, stash.sha);\n\n\t\t\t\tif (!stashes.has(p)) {\n\t\t\t\t\tstashes.set(p, stash);\n\t\t\t\t\tstdin += `${p.substring(0, 9)}\\n`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { stdin: stdin || undefined, stashes: stashes, remappedIds: remappedIds };\n}\n\nconst stashSummaryRegex =\n\t// oxlint-disable-next-line no-control-regex\n\t/(?:(?:(?<wip>WIP) on|On) (?<onref>[^/](?!.*\\/\\.)(?!.*\\.\\.)(?!.*\\/\\/)(?!.*@\\{)[^\\x00-\\x1F\\x7F ~^:?*[\\\\]+[^./]):\\s*)?(?<summary>.*)$/s;\n\nfunction createStash(\n\ts: ParsedStash | ParsedStashWithFiles,\n\trepoPath: string,\n\tcurrentUser: GitUser | undefined,\n): GitStashCommit {\n\t// `onRef` comes from the commit subject (%s), which git always prefixes with `On <branch>: …`\n\t// or `WIP on <branch>: …`. This holds even when the reflog message was customized\n\t// (autostash, `git stash store -m \"…\"`), so it's a reliable source\n\tlet onRef: string | undefined;\n\tconst subjectMatch = stashSummaryRegex.exec((s.commitSubject ?? '').trim());\n\tif (subjectMatch?.groups?.onref) {\n\t\tonRef = subjectMatch.groups.onref;\n\t}\n\n\t// The user-visible display message is derived from the reflog subject (%gs) so that short\n\t// custom messages like \"wip\", \"q\", or \"show args\" stay as the user wrote them instead of\n\t// being replaced by the verbose git-auto subject\n\tlet message = s.summary.trim();\n\tconst reflogMatch = stashSummaryRegex.exec(message);\n\tif (reflogMatch?.groups != null) {\n\t\tconst summary = reflogMatch.groups.summary.trim();\n\t\tif (summary.length === 0) {\n\t\t\tmessage = 'WIP';\n\t\t} else if (reflogMatch.groups.wip) {\n\t\t\tmessage = `WIP: ${summary}`;\n\t\t} else {\n\t\t\tmessage = summary;\n\t\t}\n\t}\n\n\tconst index = message.indexOf('\\n');\n\n\treturn new GitCommit(\n\t\trepoPath,\n\t\ts.sha,\n\t\tnew GitCommitIdentity(\n\t\t\tcurrentUser?.name ?? '',\n\t\t\tcurrentUser?.email,\n\t\t\tnew Date(Number(s.authorDate) * 1000),\n\t\t\tundefined,\n\t\t\ttrue,\n\t\t),\n\t\tnew GitCommitIdentity(\n\t\t\tcurrentUser?.name ?? '',\n\t\t\tcurrentUser?.email,\n\t\t\tnew Date(Number(s.committedDate) * 1000),\n\t\t\tundefined,\n\t\t\ttrue,\n\t\t),\n\t\tindex !== -1 ? message.substring(0, index) : message,\n\t\ts.parents.split(' ') ?? [],\n\t\tmessage,\n\t\tcreateCommitFileset(s, repoPath, undefined),\n\t\ts.stats,\n\t\t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;CAEZ;CAEA,MAAM,QAAQ,QAAQ,QAAQ,IAAI;CAElC,OAAO,IAAI,UACV,UACA,EAAE,KACF,IAAI,kBACH,aAAa,QAAQ,IACrB,aAAa,uBACb,IAAI,KAAK,OAAO,EAAE,UAAU,IAAI,GAAI,GACpC,KAAA,GACA,IACD,GACA,IAAI,kBACH,aAAa,QAAQ,IACrB,aAAa,uBACb,IAAI,KAAK,OAAO,EAAE,aAAa,IAAI,GAAI,GACvC,KAAA,GACA,IACD,GACA,UAAU,KAAK,QAAQ,UAAU,GAAG,KAAK,IAAI,SAC7C,EAAE,QAAQ,MAAM,GAAG,KAAK,CAAC,GACzB,SACA,oBAAoB,GAAG,UAAU,KAAA,CAAS,GAC1C,EAAE,OACF,KAAA,GACA,KAAA,GACA,EAAE,WACF,KACD;AACD"}
@@ -67,7 +67,9 @@ export declare class StatusGitSubProvider implements GitStatusSubProvider {
67
67
  hasConflictingFiles(repoPath: string, cancellation?: AbortSignal): Promise<boolean>;
68
68
  getConflictingFiles(repoPath: string, cancellation?: AbortSignal): Promise<GitConflictFile[]>;
69
69
  private hasUntrackedFiles;
70
- getUntrackedFiles(repoPath: string, cancellation?: AbortSignal): Promise<GitFile[]>;
70
+ getUntrackedFiles(repoPath: string, options?: {
71
+ paths?: readonly string[];
72
+ }, cancellation?: AbortSignal): Promise<GitFile[]>;
71
73
  }
72
74
  //#endregion
73
75
  //# sourceMappingURL=status.d.ts.map
@@ -1,3 +1,4 @@
1
+ import { chunkByStringLength } from "../../utils/iterable.js";
1
2
  import { raceWithTimeout } from "../../utils/cancellation.js";
2
3
  import { iterateByDelimiter } from "../../utils/string.js";
3
4
  import { getScopedLogger } from "../../utils/logger.scoped.js";
@@ -8,7 +9,7 @@ import { toFsPath } from "../../utils/uri.js";
8
9
  import { normalizePath, splitPath, stripFolderGlob } from "../../utils/path.js";
9
10
  import { PromiseMap } from "../../utils/promiseCache.js";
10
11
  import __decorate from "../../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
11
- import { GitErrors, defaultExceptionHandler, gitConfigsStatus } from "../exec/git.js";
12
+ import { GitErrors, defaultExceptionHandler, gitConfigsStatus, maxGitCliLength } from "../exec/git.js";
12
13
  import { GitFileWorkingTreeStatus } from "../../git/models/fileStatus.js";
13
14
  import _usingCtx from "../../_virtual/@oxc-project+runtime/helpers/esm/usingCtx.js";
14
15
  import { parseGitConflictFiles } from "../parsers/indexParser.js";
@@ -289,29 +290,46 @@ var StatusGitSubProvider = class {
289
290
  _usingCtx3.d();
290
291
  }
291
292
  }
292
- getUntrackedFiles(repoPath, cancellation) {
293
+ getUntrackedFiles(repoPath, options, cancellation) {
293
294
  const scope = getScopedLogger();
294
- return this.dedupeByStatusGeneration(repoPath, "getUntrackedFiles", async (correlationKey, signal) => {
295
- const result = await this.git.run({
296
- cwd: repoPath,
297
- cancellation: signal,
298
- errors: "throw",
299
- correlationKey
300
- }, "ls-files", "-z", "--others", "--exclude-standard");
301
- if (!result.stdout) {
302
- scope?.addExitInfo("no untracked files");
303
- return [];
295
+ const paths = options?.paths;
296
+ if (paths != null && !paths.length) return Promise.resolve([]);
297
+ const pathspecs = paths?.map((p) => `:(literal)${p}`);
298
+ const read = pathspecs != null ? `getUntrackedFiles\0${pathspecs.join("\0")}` : "getUntrackedFiles";
299
+ return this.dedupeByStatusGeneration(repoPath, read, async (correlationKey, signal) => {
300
+ const prefix = [
301
+ "ls-files",
302
+ "-z",
303
+ "--others",
304
+ "--exclude-standard"
305
+ ];
306
+ let batches = [[]];
307
+ if (pathspecs != null) {
308
+ const perArgOverhead = 3;
309
+ const prefixLength = [...prefix, "--"].reduce((sum, arg) => sum + arg.length + perArgOverhead, 0);
310
+ batches = chunkByStringLength(pathspecs, maxGitCliLength - prefixLength, perArgOverhead);
304
311
  }
312
+ const seen = /* @__PURE__ */ new Set();
305
313
  const files = [];
306
- for (const line of iterateByDelimiter(result.stdout, "\0")) {
307
- if (!line.length) continue;
308
- files.push({
309
- path: line,
310
- repoPath,
311
- status: GitFileWorkingTreeStatus.Untracked
312
- });
314
+ for (const batch of batches) {
315
+ const result = await this.git.run({
316
+ cwd: repoPath,
317
+ cancellation: signal,
318
+ errors: "throw",
319
+ correlationKey
320
+ }, ...prefix, ...pathspecs != null ? ["--", ...batch] : []);
321
+ if (!result.stdout) continue;
322
+ for (const line of iterateByDelimiter(result.stdout, "\0")) {
323
+ if (!line.length || seen.has(line)) continue;
324
+ seen.add(line);
325
+ files.push({
326
+ path: line,
327
+ repoPath,
328
+ status: GitFileWorkingTreeStatus.Untracked
329
+ });
330
+ }
313
331
  }
314
- scope?.addExitInfo(`${String(files.length)} untracked file(s)`);
332
+ scope?.addExitInfo(files.length ? `${String(files.length)} untracked file(s)` : "no untracked files");
315
333
  return files;
316
334
  }, cancellation);
317
335
  }