Skip to content

Conversation

@lszomoru
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings January 13, 2026 08:41
@lszomoru lszomoru enabled auto-merge (squash) January 13, 2026 08:41
@lszomoru lszomoru self-assigned this Jan 13, 2026
@vs-code-engineering vs-code-engineering bot added this to the January 2026 milestone Jan 13, 2026
const filesToCheckResults = await this.checkIgnore(Array.from(filesToCheck));
filesToCheckResults.forEach(ignoredFile => gitIgnoredFiles.add(ignoredFile));
// Get files matching the globs with git ignore files applied
const nonIgnoredFiles = await workspace.findFiles2(filePattern, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this would be a good place to apply the new ignoreGlobCase option, but perhaps internally at the API entry point vs. passing as an argument...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we would have to better understand the use cases to make that choice.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors the Git extension's worktree include files logic to use the new findFiles2() proposed API instead of manual glob expansion with Node.js fsPromises.glob().

Changes:

  • Replaces custom file globbing and git ignore checking logic with two findFiles2() calls to determine git-ignored files
  • Removes manual directory traversal and checkIgnore() calls in favor of built-in ignore file handling
  • Improves error logging in _copyWorktreeIncludeFiles() to show individual error details

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
extensions/git/package.json Adds findFiles2 to the list of enabled proposed APIs
extensions/git/tsconfig.json Includes the TypeScript definitions for the findFiles2 proposed API
extensions/git/src/repository.ts Refactors _getWorktreeIncludeFiles() to use findFiles2() API; simplifies error handling in _copyWorktreeIncludeFiles() by removing directory-specific error filtering and adding detailed error logging

Comment on lines +1899 to +1920
const filePattern = worktreeIncludeFiles
.map(pattern => new RelativePattern(this.root, pattern));

if (isUnderIgnoredDir) {
gitIgnoredFiles.add(fullPath);
} else {
filesToCheck.push(fullPath);
}
}
// Get all files matching the globs (no ignore files applied)
const allFiles = await workspace.findFiles2(filePattern, {
useExcludeSettings: ExcludeSettingOptions.None,
useIgnoreFiles: { local: false, parent: false, global: false }
});

// Check the files that are not under a git ignored directories
const filesToCheckResults = await this.checkIgnore(Array.from(filesToCheck));
filesToCheckResults.forEach(ignoredFile => gitIgnoredFiles.add(ignoredFile));
// Get files matching the globs with git ignore files applied
const nonIgnoredFiles = await workspace.findFiles2(filePattern, {
useExcludeSettings: ExcludeSettingOptions.None,
useIgnoreFiles: { local: true, parent: true, global: true }
});

return gitIgnoredFiles;
} catch (err) {
this.logger.warn(`[Repository][_getWorktreeIncludeFiles] Failed to get worktree include files: ${err}`);
return new Set<string>();
// Files that are git ignored = all files - non-ignored files
const gitIgnoredFiles = new Set(allFiles.map(uri => uri.fsPath));
for (const uri of nonIgnoredFiles) {
gitIgnoredFiles.delete(uri.fsPath);
}

return gitIgnoredFiles;
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The refactored method no longer has error handling that was present in the original implementation. The original code wrapped the glob expansion and git ignore checking in a try-catch block, logging any errors and returning an empty Set on failure. Consider adding similar error handling to ensure robustness, especially since this method is called asynchronously without awaiting in createWorktree.

See below for a potential fix:

		try {
			const filePattern = worktreeIncludeFiles
				.map(pattern => new RelativePattern(this.root, pattern));

			// Get all files matching the globs (no ignore files applied)
			const allFiles = await workspace.findFiles2(filePattern, {
				useExcludeSettings: ExcludeSettingOptions.None,
				useIgnoreFiles: { local: false, parent: false, global: false }
			});

			// Get files matching the globs with git ignore files applied
			const nonIgnoredFiles = await workspace.findFiles2(filePattern, {
				useExcludeSettings: ExcludeSettingOptions.None,
				useIgnoreFiles: { local: true, parent: true, global: true }
			});

			// Files that are git ignored = all files - non-ignored files
			const gitIgnoredFiles = new Set(allFiles.map(uri => uri.fsPath));
			for (const uri of nonIgnoredFiles) {
				gitIgnoredFiles.delete(uri.fsPath);
			}

			return gitIgnoredFiles;
		} catch (err) {
			this.logger.warn(`[Repository][_getWorktreeIncludeFiles] Failed to resolve worktree include files: ${err}`);
			return new Set<string>();
		}

Copilot uses AI. Check for mistakes.
@lszomoru lszomoru merged commit 8f8c559 into main Jan 13, 2026
27 of 28 checks passed
@lszomoru lszomoru deleted the lszomoru/statistical-pig branch January 13, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants