Support for git worktree creation from a thunk using local git repo #49
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I use git worktrees a lot and have always wanted the nix-thunk to support it.
So last few days I spent some time and implemented it.
The following are some notes for the worktree support.
Usage
Like this
Benefits of using worktree; as opposed to doing unpack and create a new git repo.
and having the unpacked thunk(s) linked to the main git repository (as a worktree) has many advantages
It helps avoids the situation where you could forget, after a few months, where a worktree was being used from.
Problems with using worktree
Repos containing sub-modules don't work properly with git worktree.
If the local repo already contains a branch of the same name as the thunk, then the new worktree cannot be created with that branch name.
The local branch may be pointing to a different revision, and I think it's better to not modify the existing branches in the git repo.
In this situation, user has two options.
(Fixing the branch naming before pushing to remote, or updating the existing branch to track the remote will have to be done manually by the user.)
Packing worktrees
When doing packing of worktree thunks there are fewer number of concerns than the usual. Namely these two
Performance
Here are the unpack vs worktree creation time I noted on my machine