extensions/git/src/model.ts/Model/openRepository
class Model:	async openRepository(repoPath: string): Promise<void> {
		this.logger.trace(`Opening repository: ${repoPath}`);
		if (this.getRepositoryExact(repoPath)) {
			this.logger.trace(`Repository for path ${repoPath} already exists`);
			return;
		}

		const config = workspace.getConfiguration('git', Uri.file(repoPath));
		const enabled = config.get<boolean>('enabled') === true;

		if (!enabled) {
			this.logger.trace('Git is not enabled');
			return;
		}

		if (!workspace.isTrusted) {
			// Check if the folder is a bare repo: if it has a file named HEAD && `rev-parse --show -cdup` is empty
			try {
				fs.accessSync(path.join(repoPath, 'HEAD'), fs.constants.F_OK);
				const result = await this.git.exec(repoPath, ['-C', repoPath, 'rev-parse', '--show-cdup']);
				if (result.stderr.trim() === '' && result.stdout.trim() === '') {
					this.logger.trace(`Bare repository: ${repoPath}`);
					return;
				}
			} catch {
				// If this throw, we should be good to open the repo (e.g. HEAD doesn't exist)
			}
		}

		try {
			const rawRoot = await this.git.getRepositoryRoot(repoPath);

			// This can happen whenever `path` has the wrong case sensitivity in
			// case insensitive file systems
			// https://github.com/microsoft/vscode/issues/33498
			const repositoryRoot = Uri.file(rawRoot).fsPath;
			this.logger.trace(`Repository root: ${repositoryRoot}`);

			if (this.getRepositoryExact(repositoryRoot)) {
				this.logger.trace(`Repository for path ${repositoryRoot} already exists`);
				return;
			}

			if (this.shouldRepositoryBeIgnored(rawRoot)) {
				this.logger.trace(`Repository for path ${repositoryRoot} is ignored`);
				return;
			}

			// On Window, opening a git repository from the root of the HOMEDRIVE poses a security risk.
			// We will only a open git repository from the root of the HOMEDRIVE if the user explicitly
			// opens the HOMEDRIVE as a folder. Only show the warning once during repository discovery.
			if (process.platform === 'win32' && process.env.HOMEDRIVE && pathEquals(`${process.env.HOMEDRIVE}\\`, repositoryRoot)) {
				const isRepoInWorkspaceFolders = (workspace.workspaceFolders ?? []).find(f => pathEquals(f.uri.fsPath, repositoryRoot))!!;

				if (!isRepoInWorkspaceFolders) {
					if (this.showRepoOnHomeDriveRootWarning) {
						window.showWarningMessage(l10n.t('Unable to automatically open the git repository at "{0}". To open that git repository, open it directly as a folder in VS Code.', repositoryRoot));
						this.showRepoOnHomeDriveRootWarning = false;
					}

					this.logger.trace(`Repository for path ${repositoryRoot} is on the root of the HOMEDRIVE`);
					return;
				}
			}

			const dotGit = await this.git.getRepositoryDotGit(repositoryRoot);
			const repository = new Repository(this.git.open(repositoryRoot, dotGit, this.logger), this, this, this, this.globalState, this.logger, this.telemetryReporter);

			this.open(repository);
			repository.status(); // do not await this, we want SCM to know about the repo asap
		} catch (ex) {
			// Handle unsafe repository
			const match = /^fatal: detected dubious ownership in repository at \'([^']+)\'$/m.exec(ex.stderr);
			if (match && match.length === 2) {
				const unsafeRepositoryPath = path.normalize(match[1]);
				this.logger.trace(`Unsafe repository: ${unsafeRepositoryPath}`);

				// Show a notification if the unsafe repository is opened after the initial repository scan
				if (this._state === 'initialized' && !this._unsafeRepositories.has(unsafeRepositoryPath)) {
					this.showUnsafeRepositoryNotification();
				}

				this._unsafeRepositories.add(unsafeRepositoryPath);

				return;
			}

			// noop
			this.logger.trace(`Opening repository for path='${repoPath}' failed; ex=${ex}`);
		}
	}