Add git note support #166
Loading…
Reference in New Issue
No description provided.
Delete Branch "master"
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?
Adds support for the
git_note_*
functions.Hi @benburkert 👋
Nice PR! 🎊
@carlosmn I fixed the typo in the comment.
The receivers for the methods are values rather than objects (e.g.
func (n Note) Id() *Oid {
). AFAICT this will create a copy of the originalNote
object.This could then create a race condition between this copy for use in these methods and the original object being garbage-collected, which would call the finalizer and free the underlying C object, making the C function call use a dangling pointer.
All this to say that as I understand it, we need to have pointer receivers instead of value receivers.
I switched the methods definitions to pointer receivers. I tend to define methods on values for non mutating functions of small structs (as a way of marking it as "const"), but it looks like the convention in this package is to define methods on pointers.
Although I haven't found anything to back this up definitively, I don't think the finalizer is copied when a struct is placed on the stack. Assuming that's the case, then dangling pointers should not be an issue from inside these methods because the previous stack frame would always hold a reference to the value on the heap and prevent GC from calling the finalizer.
Using the structs as values works well if we do everything with the garbage collector, but we can't increase a refcount on copy.
The finalizer applies to a particular object rather than the class/type, so it would not be copied. While it's unlikely that the garbage run would decide to free the original object, this is not something we should assume. I've seen situations where a variable is freed mid-function after the last usage, which could be an issue here.