summaryrefslogtreecommitdiff
path: root/patch.go
AgeCommit message (Collapse)Author
2021-09-05Make all non-user-creatable structures non-comparable (#802)lhchavez
This change makes all non-user-creatable structures non-comparable. This makes it easier to add changes later that don't introduce breaking changes from the go compatibility guarantees perspective. This, of course, implies that this change _is_ a breaking change, but since these structures are not intended to be created by users (or de-referenced), it should be okay.
2020-12-10More callback refactoring (#713)lhchavez
This change: * Gets rid of the `.toC()` functions for Options objects, since they were redundant with the `populateXxxOptions()`. * Adds support for `errorTarget` to the `RemoteOptions`, since they are used in the same stack for some functions (like `Fetch()`). Now for those cases, the error returned by the callback will be preserved as-is.
2020-12-05Refactor all callbacks (#700)lhchavez
This change is a preparation for another change that makes all callback types return a Go error instead of an error code / an integer. That is going to make make things a lot more idiomatic. The reason this change is split is threefold: a) This change is mostly mechanical and should contain no semantic changes. b) This change is backwards-compatible (in the Go API compatibility sense of the word), and thus can be backported to all other releases. c) It makes the other change a bit smaller and more focused on just one thing. Concretely, this change makes all callbacks populate a Go error when they fail. If the callback is invoked from the same stack as the function to which it was passed (e.g. for `Tree.Walk`), it will preserve the error object directly into a struct that also holds the callback function. Otherwise if the callback is pased to one func and will be invoked when run from another one (e.g. for `Repository.InitRebase`), the error string is saved into the libgit2 thread-local storage and then re-created as a `GitError`.
2020-06-21Fix a potential use-after-free in DiffNotifyCallback (#579)lhchavez
This change makes the DiffNotifyCallback always use an "unowned" *git.Diff that does _not_ run the finalizer. Since the underlying git_diff object is still owned by libgit2, we shouldn't be calling Diff.Free() on it, even by accident, since that would cause a whole lot of undefined behavior. Now instead of storing a reference to a *git.Diff in the intermediate state while the diff operation is being done, create a brand new *git.Diff for every callback invocation, and only create a fully-owned *git.Diff when the diff operation is done and the ownership is transfered to Go.
2018-08-08Remove uses of deprecated git_buf_freeCarlos Martín Nieto
2017-09-29patch: adjust to new function signatureCarlos Martín Nieto
2017-09-03Go back to the v0.26 libgit2 releaseCarlos Martín Nieto
Newer commits have changed the build scripts such that the HTTP parser is not included in the static library. This also reverts commit ecf4f7a137ba69014d414b8de20eb58e115bfd73.
2017-09-03patch: correct a pointer typeCarlos Martín Nieto
2017-07-08Third round of keep-alive aditionsCarlos Martín Nieto
2017-03-23Fix memory leak in Patch.String()Adam Berkovec
Buffer allocated in Patch.String() was never freed Signed-off-by: Can Berk Güder <[email protected]>
2014-12-11Add missing thread-lockingCarlos Martín Nieto
2014-12-06Export PatchFromBuffers function.Jose Alvarez
This change also factor out diffOptionsToC function to remove duplicated code.
2014-12-06Add missing thread lockingCarlos Martín Nieto
2014-03-21don't expose 3 different diff foreach methods. use structures instead of ↵Jesse Ezell
pointers to structures for diff detail. add patch error code handling. trim excess data from diff structures.
2014-03-20set ptr to nil after freeJesse Ezell
2014-03-20refactor and cleanup codeJesse Ezell
2014-03-20cleanup and refactor diff / patchJesse Ezell
2014-02-20Add partial diff/patch functionality.lye
This commit adds barebones capacity to generate diffs from two trees and to emit those as git-style diffs (via `Patch.String`), or to enumerate the files/hunks/lines in the diff to emit the data yourself. The walk functions have been implemented in the same manner as the Odb walking methods. Note that not all of the functionality is implemented for either the `git_diff_*` nor the `git_patch_*` functions, and there are unexposed constants which would likely be useful to add.