27 Patch
(require libgit2/include/patch) | package: libgit2 |
procedure
(git_patch_free patch) → void?
patch : patch?
procedure
(git_patch_from_blob_and_buffer old_blob old_as_path buffer buffer_len buffer_as_path opts) → (or/c patch? #f) old_blob : (or/c blob? #f) old_as_path : (or/c string? #f) buffer : (or/c bytes? #f) buffer_len : integer? buffer_as_path : (or/c bytes? #f) opts : (or/c git_diff_options? #f)
This is just like git_diff_blob_to_buffer() except it generates a patch object for the difference instead of directly making callbacks. You can use the standard git_patch accessor functions to read the patch data, and you must call git_patch_free() on the patch when done.
procedure
(git_patch_from_blobs old_blob old_as_path new_blob new_as_path opts) → patch? old_blob : (or/c blob? #f) old_as_path : (or/c string? #f) new_blob : (or/c blob? #f) new_as_path : (or/c string? #f) opts : (or/c git_diff_options? #f)
This is just like git_diff_blobs() except it generates a patch object for the difference instead of directly making callbacks. You can use the standard git_patch accessor functions to read the patch data, and you must call git_patch_free() on the patch when done.
procedure
(git_patch_from_buffers old_buffer old_len old_as_path new_buffer new_len new_as_path opts) → patch? old_buffer : (or/c bytes? #f) old_len : integer? old_as_path : (or/c string? #f) new_buffer : (or/c bytes? #f) new_len : integer? new_as_path : (or/c string? #f) opts : (or/c git_diff_options? #f)
This is just like git_diff_buffers() except it generates a patch object for the difference instead of directly making callbacks. You can use the standard git_patch accessor functions to read the patch data, and you must call git_patch_free() on the patch when done.
procedure
diff : diff? idx : integer?
The git_patch is a newly created object contains the text diffs for the delta. You have to call git_patch_free() when you are done with it. You can use the patch object to loop over all the hunks and lines in the diff of the one delta.
For an unchanged file or a binary file, no git_patch will be created, the output will be set to NULL, and the binary flag will be set true in the git_diff_delta structure.
It is okay to pass NULL for either of the output parameters; if you pass NULL for the git_patch, then the text diff will not be calculated.
procedure
(git_patch_get_hunk patch hunk_idx) → any
patch : patch? hunk_idx : size_t
Given a patch and a hunk index into the patch, this returns detailed information about that hunk. Any of the output pointers can be passed as NULL if you don’t care about that particular piece of information.
Returns (values (out : git_diff_hunk?) (lines : integer?)). See Multiple Values
procedure
(git_patch_get_line_in_hunk patch hunk_idx line_of_hunk) → git_diff_line? patch : patch? hunk_idx : integer? line_of_hunk : integer?
Given a patch, a hunk index, and a line index in the hunk, this will return a lot of details about that line. If you pass a hunk index larger than the number of hunks or a line index larger than the number of lines in the hunk, this will return -1.
procedure
(git_patch_line_stats patch) → any
patch : patch?
This helps imitate a diff –numstat type of output. For that purpose, you only need the total_additions and total_deletions values, but we include the total_context line count in case you want the total number of lines of diff output that will be generated.
All outputs are optional. Pass NULL if you don’t need a particular count.
Returns (values (context : integer?) (additions : integer?) (deletions : integer?)). See Multiple Values
procedure
(git_patch_num_hunks patch) → integer?
patch : patch?
procedure
(git_patch_print patch print_cb payload) → integer?
patch : patch? print_cb : git_diff_line_cb payload : bytes?
Returning a non-zero value from the callback will terminate the iteration and return that value to the caller.
procedure
(git_patch_size patch include_context include_hunk_headers include_file_headers) → integer? patch : patch? include_context : boolean? include_hunk_headers : boolean? include_file_headers : boolean?
This returns the raw size of the patch data. This only includes the actual data from the lines of the diff, not the file or hunk headers.
If you pass include_context as true (non-zero), this will be the size of all of the diff output; if you pass it as false (zero), this will only include the actual changed lines (as if context_lines was 0).
procedure
(git_patch_to_buf out patch) → integer?
out : buf? patch : patch?