You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Repository.Worktrees.Add leaves now worktree empty #2037
Somewhere in the 0.27.0-preview-0182 to 0.27.2 range, LibGit2Sharp broke creation of work trees.
Reproduction steps
Given a Repository object that points to a valid git repo with at least 2 commits in its history,
call Repository.Worktrees.Add("HEAD~1", "myworktree", "../somePath", isLocked: false);
@bording, @AArnott Any updates on this issue? 0.26.2 is the last release that creation of a worktree worked fine. I already tested with 0.30.0 and 0.29.0
I forked LibGit2 repo and I found why the worktree is creating an empty folder (only .git file) and it is because current code does not contain the checkout_strategy is GIT_CHECKOUT_NONE when it was GIT_CHECKOUT_FORCE in version 02.26.2 (latest version that it works fine). This version is from 12/11/2019 and the image below is a diff between commits 5d5b76df (Committed by @ethomson on 24/06/2019 16:00:41) and latest commit 85f5aec1 (Committed by @ethomson on 05/03/2024 10:44:16).
Any reason for this change? There are two options to fix it.
Force it in worktree.c (LibGit2 project) (but it is passing in git_worktree_add_options).
Force it in WorktreeCollection.cs (LibGit2Sharp project)
Activity
Workaround libgit2/libgit2sharp#2037
barry-bvl commentedon May 27, 2024
Is there any update on this issue?
enriqueraso commentedon May 28, 2024
@bording, @AArnott Any updates on this issue? 0.26.2 is the last release that creation of a worktree worked fine. I already tested with 0.30.0 and 0.29.0
enriqueraso commentedon Jun 3, 2024
I forked LibGit2 repo and I found why the worktree is creating an empty folder (only .git file) and it is because current code does not contain the checkout_strategy is GIT_CHECKOUT_NONE when it was GIT_CHECKOUT_FORCE in version 02.26.2 (latest version that it works fine). This version is from 12/11/2019 and the image below is a diff between commits 5d5b76df (Committed by @ethomson on 24/06/2019 16:00:41) and latest commit 85f5aec1 (Committed by @ethomson on 05/03/2024 10:44:16).
Any reason for this change? There are two options to fix it.
Force it in worktree.c (LibGit2 project) (but it is passing in git_worktree_add_options).
Force it in WorktreeCollection.cs (LibGit2Sharp project)
ethomson commentedon Jun 3, 2024
Thanks for the investigation @enriqueraso - this needs a fix in LibGit2Sharp.
ethomson commentedon Jun 3, 2024
(IIUC that is - I think that the default opts structure for worktrees is wrong.)
enriqueraso commentedon Jun 3, 2024
@ethomson ok, I will create a PR for it
enriqueraso commentedon Jun 4, 2024
@ethomson @AArnott @bording, I created this PR #2099 but I cannot assign you as reviewers.
bording commentedon Dec 3, 2024
Fixed by #2099
enriqueraso commentedon Mar 29, 2025
Thank you guys :)