Git - fix regression related to worktree detection (#256265)

This commit is contained in:
Ladislau Szomoru
2025-07-16 15:10:22 +00:00
committed by GitHub
parent b9ca682b28
commit c0ceb8ca95

View File

@@ -2755,10 +2755,22 @@ export class Repository {
}
private async getWorktreesFS(): Promise<Worktree[]> {
const worktreesPath = path.join(this.repositoryRoot, '.git', 'worktrees');
const config = workspace.getConfiguration('git', Uri.file(this.repositoryRoot));
const shouldDetectWorktrees = config.get<boolean>('detectWorktrees') === true;
if (!shouldDetectWorktrees) {
this.logger.info('[Git][getWorktreesFS] Worktree detection is disabled, skipping worktree detection');
return [];
}
if (this.kind !== 'repository') {
this.logger.info('[Git][getWorktreesFS] Either a submodule or a worktree, skipping worktree detection');
return [];
}
try {
// List all worktree folder names
const worktreesPath = path.join(this.repositoryRoot, '.git', 'worktrees');
const dirents = await fs.readdir(worktreesPath, { withFileTypes: true });
const result: Worktree[] = [];
@@ -2786,7 +2798,7 @@ export class Repository {
return result;
}
catch (err) {
if (/ENOENT/.test(err.message)) {
if (/ENOTDIR/.test(err.message)) {
return [];
}