More diff functionality #629
Loading…
Reference in New Issue
No description provided.
Delete Branch "feature-diff-extra"
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?
This PR adds
The test files might be a bit messy but there's quite a lot of stuff to cover.
nice test coverage!
@ -847,3 +848,174 @@ func DiffBlobs(oldBlob *Blob, oldAsPath string, newBlob *Blob, newAsPath string,
the
C.CString()
needs to beC.free()
d. Although it might be better to useC.CBytes()
since the buffer should be able to contain NULL bytes.Is it possible to avoid embedding the callbacks into this struct? otherwise it gives the appearance of there being an 'is-a' relationship between
ApplyOptions
andApplyHunkCallback
.can the
pointerHandles
only store the pointer to theApplyOptions
?other places (like
fc6eaf3638/diff.go (L514)
) use the function initialization rather than the initialization constant to avoid having to create a wrapper:can the
.toC()
call be outlined? all other places use thepattern (except for
Oid
, since those are just cast to unsafe pointers).the version is not needed to be exposed. it's only needed internally by libgit2 to ensure that the size of the struct is what it expects.
@ -850,0 +900,4 @@
if opts.ApplyDeltaCallback == nil {
return 0
}
can this also use the same pattern as the other change?
@ -850,0 +940,4 @@
opts := &C.git_apply_options{
version: C.GIT_APPLY_OPTIONS_VERSION,
flags: C.uint(a.Flags),
}
since there is no interaction with the thread-local storage in libgit2 (e.g.
git_error
-related stuff), this is not required here.@ -850,0 +999,4 @@
// abbreviated object IDs, so the object IDs in a git_diff_delta produced by
// this function will also be abbreviated.
//
// This function will only read patch files created by a git implementation, it
so far, no tests have underscores in their names.
can this use tabs for consistency?
@ -847,3 +848,174 @@ func DiffBlobs(oldBlob *Blob, oldAsPath string, newBlob *Blob, newAsPath string,
I exposed it because it is exposed in some of the other structs (For example, CherrypickOptions, RebaseOptions, etc). Should I just convert this to a non-exported field instead?
@ -847,3 +848,174 @@ func DiffBlobs(oldBlob *Blob, oldAsPath string, newBlob *Blob, newAsPath string,
Fixed
@ -850,0 +999,4 @@
// abbreviated object IDs, so the object IDs in a git_diff_delta produced by
// this function will also be abbreviated.
//
// This function will only read patch files created by a git implementation, it
Fixed
@ -850,0 +940,4 @@
opts := &C.git_apply_options{
version: C.GIT_APPLY_OPTIONS_VERSION,
flags: C.uint(a.Flags),
}
Fixed
Weird, don't know how that happened
@ -847,3 +848,174 @@ func DiffBlobs(oldBlob *Blob, oldAsPath string, newBlob *Blob, newAsPath string,
I didn't realise that, I suppose that's why it passes the size as a separate parameter (so it can do a binary diff?) I'm not sure about the CString, I wasn't able to find out how Go behaves if theres a null byte in the middle of a string so I converted it to a CBytes as recommended
@ -847,3 +848,174 @@ func DiffBlobs(oldBlob *Blob, oldAsPath string, newBlob *Blob, newAsPath string,
Fixed
@ -850,0 +900,4 @@
if opts.ApplyDeltaCallback == nil {
return 0
}
Fixed
@ -847,3 +848,174 @@ func DiffBlobs(oldBlob *Blob, oldAsPath string, newBlob *Blob, newAsPath string,
I thought there was a reason I did it this way but after changing it to call this it works fine 🤔
@ -847,3 +848,174 @@ func DiffBlobs(oldBlob *Blob, oldAsPath string, newBlob *Blob, newAsPath string,
I'd rather remove it altogether since that version number is just there to account for version drift in C, where there is no way to differentiate between different versions of the same struct. As long as there is a layer that accounts for this (e.g. git2go), it's an implementation detail that's best to hide from the end user.
RevertOptions was recently de-Versionified, so we should probably make the other Options follow suit:
4bca045e5a (diff-30188d21ac9afa73021c8dd3ae818448)
I'll probably do that at v31 branch creation time to avoid breaking the interface for older folks.(from the other thread, in case it gets lost)
@ -847,3 +848,174 @@ func DiffBlobs(oldBlob *Blob, oldAsPath string, newBlob *Blob, newAsPath string,
the older name was better for consistency:
in L860-L861, the same name can be used for the field and the type, which is the way to express that something is not to be embedded.
(as mentioned above, this is possible)
@ -850,0 +913,4 @@
return 0
} else {
return 1
}
Can these be returned to their old place? The reason why they are needed is that when
runtime.LockOsThread()
/runtime.UnlockOSThread()
combo is called, it asks Go to guarantee that only this code executes on that thread (since Go is completely free to move stuff around when needed, at any point in time). That's the only way in which it can be guaranteed that ifgit_apply_options_init
happens to place any error information in the Thread-local storage,MakeGitError()
below can still find it.We may need to tweak
script/check-MakeGitError-thread-lock.go
to also complain if these functions don't happen before any cgo calls in the function to make this less error-prone.@ -847,3 +848,174 @@ func DiffBlobs(oldBlob *Blob, oldAsPath string, newBlob *Blob, newAsPath string,
Fixed
@ -847,3 +848,174 @@ func DiffBlobs(oldBlob *Blob, oldAsPath string, newBlob *Blob, newAsPath string,
Removed and hardcoded like the other options
@ -850,0 +913,4 @@
return 0
} else {
return 1
}
Fixed
Thanks a lot for this patch!