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

properly handle detachted git worktrees #5097

Merged
merged 1 commit into from
Dec 11, 2022

Conversation

pascalkuthe
Copy link
Member

@pascalkuthe pascalkuthe commented Dec 9, 2022

Right now we check if .git exists and is a directory to detect a git repo root.
This does not work well for git repos with multiple/detached work-tree where .git
is a file which contains the location of the folder that contains files that would normally be located in .git.

This PR changes all checks for .git to use .exists() instead of .is_dir(), so it also works for files.
Since the git cli uses the same detection mechanism (try tough .git && git status in an empty directory)
this seems more inline with the intended behavior.

Furthermore, workflows with multiple worktrees become much nicer with this (I use one for each branch to quickly context switch)
as the file picker now stops at the correct location.
Fixing this will also be important for getting repo caching to work correctly in the future.

This change is technically a breaking for repos that contain random .git files but as this messes with
the git cli as well, so I think those cases can be ignored and I did not mark it as a breaking change.

@pascalkuthe pascalkuthe added A-core Area: Helix core improvements S-waiting-on-review Status: Awaiting review from a maintainer. A-vcs Area: Version control system interaction labels Dec 9, 2022
@pascalkuthe
Copy link
Member Author

This should also indirectly fix #983 I believe. This does not remove the limit as requested there or make the picker streaming/async but this should cover the specific usecase of detecting git worktrees as described in that issue.

@archseer archseer merged commit 70d7812 into helix-editor:master Dec 11, 2022
@pascalkuthe pascalkuthe deleted the better_git_detection branch December 11, 2022 11:26
@wezm
Copy link

wezm commented Dec 13, 2022

Thanks, this does fix #983 for me.

freqmod pushed a commit to freqmod/helix that referenced this pull request Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Helix core improvements A-vcs Area: Version control system interaction S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants