ODB/RefDB interface needs refactoring #314
Labels
No Label
bug
duplicate
enhancement
invalid
question
up for grabs
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: jcarr/git2go#314
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
After some experimentation, I found that the interface to the ODB and RefDB parts of libgit2 do not work as expected due to the way cgo handles scoping.
Since it is not possible for other packages to pass in C types, functions like
NewOdbBackendFromC
can be removed and the related functionality refactored. It seems to me like the only way to properly do this would be to enhance theOdbBackend
type by all the functions included in its C counterpart,git_odb_backend
.Let me know if you think this is a desirable feature, I'll gladly try to implement it.
Actually this can be solved easily by having both functions accept a unsafe.Pointer type rather than the actual classes, then cast internally. This way NewOdbBackendFromC and NewRefdbBackendFromC both works and the difference in scope of C (which is weird, by the way) is not a problem.
I've merged the PR due to the scoping issues, but it doesn't have to be either-or. As @MagicalTux mentions, passing the pointer around is still possibly, and for the use-case you mention in SO, it's still the right thing to do, a the backend is implemented in C (although that's just a detail) and what you have is a pointer to a backend.
Being able to implement a backend in Go is valuable regardless of wishing to pass in pointers from third-party backends.
Sounds good, thanks for the enhancement!