Ggit.Patch¶
Fields¶
None
Methods¶
| class | new_from_blobs (old_blob, old_as_path, new_blob, new_as_path, diff_options) |
| class | new_from_diff (diff, idx) |
get_delta () |
|
get_hunk (idx) |
|
get_line_stats () |
|
get_num_hunks () |
|
get_num_lines_in_hunk (hunk) |
|
ref () |
|
to_stream (stream) |
|
to_string () |
|
unref () |
Details¶
-
class
Ggit.Patch¶ Represents a patch object.
-
classmethod
new_from_blobs(old_blob, old_as_path, new_blob, new_as_path, diff_options)¶ Parameters: - old_blob (
Ggit.BloborNone) – aGgit.Blobto diff from. - old_as_path (
strorNone) – treat old_blob as if it had this filename, orNone, - new_blob (
Ggit.BloborNone) – aGgit.Blobto diff to. - new_as_path (
strorNone) – treat new_blob as if it had this filename, orNone, - diff_options (
Ggit.DiffOptionsorNone) – aGgit.DiffOptions, orNone.
Raises: Returns: a newly created
Ggit.PatchorNone.Return type: Ggit.PatchorNoneDirectly generate a patch from the difference between two blobs.
This is just like
Ggit.Diff.blobs() except it generates a patch object for the difference instead of directly making callbacks. You can use the standard ggit_patch accessor functions to read the patch data, and you must callGgit.Patch.unrefon the patch when done.- old_blob (
-
classmethod
new_from_diff(diff, idx)¶ Parameters: Raises: Returns: a newly created
Ggit.PatchorNone.Return type: Ggit.PatchorNoneThe
Ggit.Patchis a newly created object contains the text diffs for the delta. You have to callGgit.Patch.unref() 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.
-
get_delta()¶ Returns: the Ggit.DiffDeltaof the patch orNone.Return type: Ggit.DiffDeltaorNoneGet the diff delta corresponding to the patch.
-
get_hunk(idx)¶ Parameters: idx ( int) – the hunk index.Raises: GLib.ErrorReturns: a new Ggit.DiffHunkorNoneon error.Return type: Ggit.DiffHunkorNoneGet the idx’th hunk in the patch.
-
get_line_stats()¶ Raises: GLib.ErrorReturns: Trueif successfull,Falseotherwise.total_context: return value for the number of context lines. total_additions: return value for the number of added lines. total_deletions: return value for the number of deleted lines. Return type: ( bool, total_context:int, total_additions:int, total_deletions:int)Get the line statistics of the patch.
-
get_num_lines_in_hunk(hunk)¶ Parameters: hunk ( int) – the hunk index.Returns: the number of lines. Return type: intGet the number of lines in hunk.
-
ref()¶ Returns: a Ggit.PatchorNone.Return type: Ggit.PatchorNoneAtomically increments the reference count of self by one. This function is MT-safe and may be called from any thread.
-
to_stream(stream)¶ Parameters: stream ( Gio.OutputStream) – aGio.OutputStream.Raises: GLib.ErrorReturns: Trueif the patch was written successfully,Falseotherwise.Return type: boolWrite the contents of a patch to the provided stream.
-
to_string()¶ Raises: GLib.ErrorReturns: the content of a patch as a single diff text or None.Return type: strorNoneGets the content of a patch as a single diff text.
-
unref()¶ Atomically decrements the reference count of self by one. If the reference count drops to 0, self is freed.
-
classmethod