-
Notifications
You must be signed in to change notification settings - Fork 277
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
FR: workspaces should also be collocated in --colocate mode #4436
Comments
We'll also need to track Git Lines 275 to 278 in 8314046
|
Ok, done. PR soon. |
Well, a few questions, what do we call the new heads? If you have two workspaces "default" and "hotfix", should they be called |
Good question. Because the current syntax is Maybe we can instead map |
If the parser could handle it, I think maybe I have started making HEAD@git use the current workspace id. It seems right. |
Is your feature request related to a problem? Please describe.
From #4424 (reply in thread)
Currently if you create a workspace in a collocated repo, the new workspace is not recognisable as a Git repository by any git tools. It does not have a .git directory.
The most painful tool, as usual, is Nix flakes, which silently drops back to "no git repo" mode and stops looking at your .gitignore file, and then just repeatedly copies your enormous build artifacts folder into the nix store. I actually only discovered this issue because Nix caused my computer to run out of space. (As usual this Nix's fault!)
Describe the solution you'd like
I think we should be able to create a corresponding git worktree for each workspace. (We might consider supporting importing worktrees you created with git, but not a priority really.)
Git worktrees are pretty simple and really just involve a couple of files and a ref. So I don't think it'll be that hard.
Unfortunately I don't think you can use libgit2 for this because there are no APIs that don't also do a full checkout into a newly created worktree directory. There are no options that prevent checkout. Nor does gitoxide help, it has some worktree code but not useful either (search docs.rs for gix-worktree).
So I recommend just copying roughly these bits of libgit2's
git_worktree_add
function (unless you think that much would violate GPL, in which case just read https://git-scm.com/docs/git-worktree sections Refs, and Details):https://github.com/libgit2/libgit2/blob/main/src/libgit2/worktree.c#L355-L366
https://github.com/libgit2/libgit2/blob/main/src/libgit2/worktree.c#L389-L409
All it really needs to do is write a couple of files in the .git directory in the main workspace and in the newly created worktree, and then set an appropriate HEAD on the new worktree. It may be easier to add this in gitoxide, but this is a pretty niche use case.
Describe alternatives you've considered
None, but see the linked discussion
The text was updated successfully, but these errors were encountered: