Git - fix bug causing multiple resource trust dialogs when worktrees are present (#290707)

This commit is contained in:
Ladislau Szomoru
2026-01-27 09:32:18 +01:00
committed by GitHub
parent e7a06c8eab
commit 4ac2f00e07

View File

@@ -643,10 +643,13 @@ export class Model implements IRepositoryResolver, IBranchProtectionProviderRegi
return;
}
// Repository trust check
// Get .git path and real path
const [dotGit, repositoryRootRealPath] = await Promise.all([this.git.getRepositoryDotGit(repositoryRoot), this.getRepositoryRootRealPath(repositoryRoot)]);
// Check that the location of the .git folder is trusted
const result = await workspace.requestResourceTrust({
message: l10n.t('You are opening a repository from a location that is not trusted. Do you trust the authors of the files in the repository you are opening?'),
uri: Uri.file(repoPath),
uri: Uri.file(dotGit.commonPath ?? dotGit.path),
} satisfies ResourceTrustRequestOptions);
if (!result) {
@@ -655,7 +658,6 @@ export class Model implements IRepositoryResolver, IBranchProtectionProviderRegi
}
// Open repository
const [dotGit, repositoryRootRealPath] = await Promise.all([this.git.getRepositoryDotGit(repositoryRoot), this.getRepositoryRootRealPath(repositoryRoot)]);
const gitRepository = this.git.open(repositoryRoot, repositoryRootRealPath, dotGit, this.logger);
const repository = new Repository(gitRepository, this, this, this, this, this, this, this.globalState, this.logger, this.telemetryReporter, this._repositoryCache);