Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitLens erroneously thinks certain branches are worktrees under some conditions #3270

Closed
aminomancer opened this issue May 6, 2024 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@aminomancer
Copy link

aminomancer commented May 6, 2024

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
@aminomancer aminomancer added bug Something isn't working triage Needs to be looked at labels May 6, 2024
@eamodio eamodio self-assigned this May 7, 2024
@eamodio eamodio added this to the 14.10 milestone May 7, 2024
@aminomancer
Copy link
Author

Thanks! 💖

@eamodio
Copy link
Member

eamodio commented May 15, 2024

Thanks for the report and sorry for the issue!

@eamodio eamodio removed the triage Needs to be looked at label May 15, 2024
@eamodio eamodio modified the milestones: 15.0, 15.0-patch May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants