Skip to content

Commit f094212

Browse files
authored
Fixes #3090 - Treats .git/gitdir as toplevel on "empty" bare clones (#3092)
There are cases for having bare clones with multiple worktrees in the same folder to manage various versions in a workspace Currently, however, the only supported way to do this is to have the .git/ files such as HEAD, branches/, refs/, worktrees/, etc in the same folder as your actual worktrees. This makes your workspace very cluttered and is counterproductive to the structured way of multiple worktrees What many of us prefer is to have an "empty" bare clone with the normal bare clone files within the .git/ folder or another folder labeled .bare and use a .git file with a gitdir reference This fix will allow for the worktrees view to function the same way it would show on a `git worktree list` command
1 parent 2789e6e commit f094212

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1111
- Fixes [#3650](https://github.com/gitkraken/vscode-gitlens/issues/3650) - "Create & Switch to Local Branch" from remote branch no longer prefills local branch name to match remote branch name
1212
- Fixes [#3651](https://github.com/gitkraken/vscode-gitlens/issues/3651) - "Open on Remote (Web)" does not use tracked branch name
1313
- Fixes [#3657](https://github.com/gitkraken/vscode-gitlens/issues/3657) - Creating a worktree from within a worktree chooses the wrong path
14+
- Fixes [#3090](https://github.com/gitkraken/vscode-gitlens/issues/3090) - Manually created empty bare clone repositories in a trusted directory crash worktree view since LocalGitProvider.findRepositoryUri returns just ".git" — thanks to [PR #3092](https://github.com/gitkraken/vscode-gitlens/pull/3092) by Dawn Hwang ([@hwangh95](https://github.com/hwangh95))
1415

1516
## [15.6.0] - 2024-10-07
1617

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ A big thanks to the people that have contributed to this project 🙏❤️:
450450
- bm-w ([@bm-w](https://github.com/bm-w)) — [contributions](https://github.com/gitkraken/vscode-gitlens/commits?author=bm-w)
451451
- Tyler Johnson ([@TJohnsonSE](https://github.com/TJohnsonSE)) — [contributions](https://github.com/gitkraken/vscode-gitlens/commits?author=TJohnsonSE)
452452
- Jean Pierre ([@jeanp413](https://github.com/jeanp413)) — [contributions](https://github.com/gitkraken/vscode-gitlens/commits?author=jeanp413)
453+
- Dawn Hwang ([@hwangh95](https://github.com/hwangh95)) — [contributions](https://github.com/gitkraken/vscode-gitlens/commits?author=hwangh95)
453454

454455
Also special thanks to the people that have provided support, testing, brainstorming, etc:
455456

src/env/node/git/git.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,16 +1813,9 @@ export class Git {
18131813
'--is-bare-repository',
18141814
);
18151815
if (data.trim() === 'true') {
1816-
// If we are in a bare clone, then the common dir is the git dir
1817-
data = await this.git<string>(
1818-
{ cwd: cwd, errors: GitErrorHandling.Ignore },
1819-
'rev-parse',
1820-
'--git-common-dir',
1821-
);
1822-
data = data.trim();
1823-
if (data.length) {
1824-
return [true, normalizePath((data === '.' ? cwd : data).trimStart().replace(/[\r|\n]+$/, ''))];
1825-
}
1816+
const result = await this.rev_parse__git_dir(cwd);
1817+
const repoPath = result?.commonPath ?? result?.path;
1818+
if (repoPath?.length) return [true, repoPath];
18261819
}
18271820
}
18281821

0 commit comments

Comments
 (0)