Repository: microsoft/vscode
File: extensions/git/src/repository.ts (TypeScript)

Code before:
			gitIgnoredFiles.delete(uri.fsPath);
		}

		return gitIgnoredFiles;
	}

	private async _copyWorktreeIncludeFiles(worktreePath: string): Promise<void> {
		const ignoredFiles = await this._getWorktreeIncludeFiles();
		if (ignoredFiles.size === 0) {
			return;
		}

		try {
			// Copy files
			let copiedFiles = 0;
			const results = await window.withProgress({
				location: ProgressLocation.Notification,
				title: l10n.t('Copying additional files to the worktree'),
				cancellable: false
			}, async (progress) => {
				const limiter = new Limiter<void>(10);
				const files = Array.from(ignoredFiles);

				return Promise.allSettled(files.map(sourceFile =>
					limiter.queue(async () => {
						const targetFile = path.join(worktreePath, relativePath(this.root, sourceFile));
						await fsPromises.mkdir(path.dirname(targetFile), { recursive: true });
						await fsPromises.cp(sourceFile, targetFile, {
							force: true,
							recursive: false,
							verbatimSymlinks: true
						});

						copiedFiles++;
						progress.report({
							increment: 100 / ignoredFiles.size,
							message: l10n.t('({0}/{1})', copiedFiles, ignoredFiles.size)
						});
					})
				));
			});

			// Log any failed operations
			const failedOperations = results.filter(r => r.status === 'rejected');

			if (failedOperations.length > 0) {
				window.showWarningMessage(l10n.t('Failed to copy {0} files to the worktree.', failedOperations.length));

				this.logger.warn(`[Repository][_copyWorktreeIncludeFiles] Failed to copy ${failedOperations.length} files to worktree.`);
				for (const error of failedOperations) {
					this.logger.warn(`  - ${(error as PromiseRejectedResult).reason}`);

Review comment (performance):
The fact that this is a queue and not recursive for large folders will be a big slowdown. The default should do a simple optimized recursive copy of node modules

Code after:
			gitIgnoredFiles.delete(uri.fsPath);
		}

		return gitIgnoredFiles;
	}

	private async _copyWorktreeIncludeFiles(worktreePath: string): Promise<void> {
		const ignoredFiles = await this._getWorktreeIncludeFiles();
		if (ignoredFiles.size === 0) {
			return;
		}

		try {
			// Copy files
			const startTime = Date.now();
			const limiter = new Limiter<void>(15);
			const files = Array.from(ignoredFiles);

			const results = await Promise.allSettled(files.map(sourceFile =>
				limiter.queue(async () => {
					const targetFile = path.join(worktreePath, relativePath(this.root, sourceFile));
					await fsPromises.mkdir(path.dirname(targetFile), { recursive: true });
					await fsPromises.cp(sourceFile, targetFile, {
						force: true,
						mode: fs.constants.COPYFILE_FICLONE,
						recursive: false,
						verbatimSymlinks: true
					});
				})
			));

			// Log any failed operations
			const failedOperations = results.filter(r => r.status === 'rejected');
			this.logger.info(`[Repository][_copyWorktreeIncludeFiles] Copied ${files.length - failedOperations.length} files to worktree. Failed to copy ${failedOperations.length} files. [${Date.now() - startTime}ms]`);

			if (failedOperations.length > 0) {
				window.showWarningMessage(l10n.t('Failed to copy {0} files to the worktree.', failedOperations.length));

				this.logger.warn(`[Repository][_copyWorktreeIncludeFiles] Failed to copy ${failedOperations.length} files to worktree.`);
				for (const error of failedOperations) {
					this.logger.warn(`  - ${(error as PromiseRejectedResult).reason}`);
				}
			}
		} catch (err) {
			this.logger.warn(`[Repository][_copyWorktreeIncludeFiles] Failed to copy files to worktree: ${err}`);
		}
	}

	async deleteWorktree(path: string, options?: { force?: boolean }): Promise<void> {
		await this.run(Operation.Worktree(false), async () => {
			const worktree = this.repositoryResolver.getRepository(path);