gitkraken / vscode-gitlens

Supercharge Git inside VS Code and unlock untapped knowledge within each repository — Visualize code authorship at a glance via Git blame annotations and CodeLens, seamlessly navigate and explore Git repositories, gain valuable insights via rich visualizations and powerful comparison commands, and so much more

Home Page:http://gitkraken.com/gitlens

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GitLens erroneously thinks certain branches are worktrees under some conditions

aminomancer opened this issue · comments

Description

I mainly work with feature branches. I'll start from the main branch, pull from remote, make some changes, create a branch, then push to phabricator or submit a pull request. Then I'll switch back to the main branch (using the arrow icon in its row in the Branches view) and start over, or sometimes I'll switch directly to another branch that needs updating, etc. Pretty basic workflow. I never use worktrees.

When you click the arrow icon, a dropdown menu appears, with two options: "Switch to branch" and "Create worktree from branch." But this past couple weeks or so, I've noticed that when I click the arrow icon for certain branches, instead of showing this normal menu, it only shows "Switch to worktree" and other worktree related options. This is weird because if I go to the full branches menu (clicking the branch name in the lower left of the status bar), I can switch to the branch without issue. But for some reason when I switch between certain branches, it only gives me these workspace options.

This is quite strange because none of these branches were set up as worktrees, and indeed, my Worktrees view is completely empty, and git worktree list never returns any more results than the current branch, whichever branch I'm on. I have never used worktrees, for any repo or workspace. I had this problem just moments ago when trying to switch from my main branch to a topic branch. When I switched through the regular branches menu (as mentioned above), it worked, but it didn't stop the problem from recurring. In order to prevent it from recurring, I had to rename the branch.

Switching back to the original branch name causes the problem to come back. It seems that branch name is permanently off limits now. This gives me the impression that GitLens has a map of branch names to worktrees somewhere, which does not correspond to actual worktrees, and this map is not exposed in the UI or in settings.

I thought maybe this was caused by switching from branch A to branch B, where branch A is ahead of branch B. But I'm pretty sure I was able to reproduce the bug even when neither was ahead of the other.

What I'd really like is to be able to just disable worktrees entirely so these options are not shown at all. But it does feel like there's an underlying bug here which is making it impossible to switch via GitLens to some branches from some branches.

GitLens Version

2024.5.605 (pre-release)

VS Code Version

Version: 1.89.0 (user setup)
Commit: b58957e67ee1e712cebf466b995adf4c5307b2bd
Date: 2024-05-01T02:09:22.859Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Windows_NT x64 10.0.19045

Git Version

git version 2.43.0.windows.1

Logs, Screenshots, Screen Captures, etc

It doesn't generate any output when clicking the arrow icon. But it seems switching to a branch when GitLens thinks that branch is a worktree causes some potentially relevant output from GitLens (Git):

[2024-05-06 21:08:49.773] [    146ms] [c:\mozilla-git\mozilla-unified-2\.git] git rev-parse --show-toplevel • FAILED

Error: Command failed: C:\Program Files\Git\bin\git.exe -c core.longpaths=true -c core.quotepath=false -c color.ui=false rev-parse --show-toplevel
fatal: this operation must be run in a work tree

Thanks! 💖

Thanks for the report and sorry for the issue!

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.