Skip to content

Commit 1886056

Browse files
committed
Hides auto repo open if file is in a .git folder
- Avoids showing the root repo in worktrees during certain operations (e.g. rebase) and vice-versa
1 parent cad2076 commit 1886056

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/git/gitProviderService.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2318,9 +2318,14 @@ export class GitProviderService implements Disposable {
23182318

23192319
const autoRepositoryDetection = configuration.getCore('git.autoRepositoryDetection') ?? true;
23202320

2321-
const closed =
2321+
let closed =
23222322
options?.closeOnOpen ??
23232323
(autoRepositoryDetection !== true && autoRepositoryDetection !== 'openEditors');
2324+
// If we are trying to open a file inside the .git folder, then treat the repository as closed, unless explicitly requested it to be open
2325+
// This avoids showing the root repo in worktrees during certain operations (e.g. rebase) and vice-versa
2326+
if (!closed && options?.closeOnOpen !== false && !isDirectory && uri.path.includes('/.git/')) {
2327+
closed = true;
2328+
}
23242329

23252330
Logger.log(scope, `Repository found in '${repoUri.toString(true)}'`);
23262331
const repositories = provider.openRepository(root?.folder, repoUri, false, undefined, closed);

0 commit comments

Comments
 (0)