Open nicerobot opened 5 years ago
The problem appears to be:
In this linked worktree example, the ObjectStorage
and ReferenceStorage
should be based on the contents of the go-git/.git/worktrees/go-git-linked/gitdir
file.
It looks like this would be solved by parsing commondir
in the worktree folder (i.e. .git/worktrees/<worktree>/commondir
) which points back to the main .git
folder. While #1098 parses this, it hasn't been touched in almost a year.
When a linked worktree's HEAD ref is a tracking-branch, this code will attempt to open the ref using the path in the
.git/worktree
which is not where the refs are stored.https://github.com/src-d/go-git/blob/0d1a009cbb604db18be960db5f1525b99a55d727/storage/filesystem/dotgit/dotgit.go#L927-L931
Example
Demo
This example doesn't technically
git gc
the worktree but the scenario is the same.Output
Call-stack
Additionally
There is also a scenario for linked worktrees when the worktree's
.git/ref/heads
file can be garbage collected (git gc
in the worktree, because it is the same as aref/remotes
?) so the above will always fail.