Skip to content

Commit 2f09f40

Browse files
authored
Git - honor detectSubmodules and detectWorktrees settings when opening a workspace from a file (microsoft#257813)
1 parent 76ef361 commit 2f09f40

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

extensions/git/src/model.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,19 @@ export class Model implements IRepositoryResolver, IBranchProtectionProviderRegi
647647
// Open repository
648648
const [dotGit, repositoryRootRealPath] = await Promise.all([this.git.getRepositoryDotGit(repositoryRoot), this.getRepositoryRootRealPath(repositoryRoot)]);
649649
const gitRepository = this.git.open(repositoryRoot, repositoryRootRealPath, dotGit, this.logger);
650+
651+
// Check if the repository is a submodule/worktree and if they should be detected
652+
const detectSubmodules = config.get<boolean>('detectSubmodules', true) === true;
653+
const detectWorktrees = config.get<boolean>('detectWorktrees', true) === true;
654+
if ((gitRepository.kind === 'submodule' && !detectSubmodules) ||
655+
(gitRepository.kind === 'worktree' && !detectWorktrees)) {
656+
this.logger.info(`[Model][openRepository] Skip opening repository (path): ${repositoryRoot}`);
657+
this.logger.info(`[Model][openRepository] Skip opening repository (real path): ${repositoryRootRealPath ?? repositoryRoot}`);
658+
this.logger.info(`[Model][openRepository] Skip opening repository (kind): ${gitRepository.kind}`);
659+
660+
return;
661+
}
662+
650663
const repository = new Repository(gitRepository, this, this, this, this, this, this, this.globalState, this.logger, this.telemetryReporter);
651664

652665
this.open(repository);

0 commit comments

Comments
 (0)