[libgit2-glib] Bind more GgitDiffPatch API



commit cc9d2e903004232959dc9d64c3978f5badf40f2b
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Mon Jul 8 13:46:30 2013 +0200

    Bind more GgitDiffPatch API

 libgit2-glib/ggit-diff-patch.c |   90 ++++++++++++++++++++++++++++++++++++++++
 libgit2-glib/ggit-diff-patch.h |   12 +++++
 2 files changed, 102 insertions(+), 0 deletions(-)
---
diff --git a/libgit2-glib/ggit-diff-patch.c b/libgit2-glib/ggit-diff-patch.c
index d52d5de..d9fa752 100644
--- a/libgit2-glib/ggit-diff-patch.c
+++ b/libgit2-glib/ggit-diff-patch.c
@@ -206,4 +206,94 @@ ggit_diff_patch_to_stream (GgitDiffPatch  *diff_patch,
        return TRUE;
 }
 
+/**
+ * ggit_diff_patch_get_line_stats:
+ * @diff_patch: a #GgitDiffPatch.
+ * @total_context: (allow-none) (out): return value for the number of context lines.
+ * @total_additions: (allow-none) (out): return value for the number of added lines.
+ * @total_deletions: (allow-none) (out): return value for the number of deleted lines.
+ * @error: a #GError.
+ *
+ * Get the line statistics of the patch.
+ *
+ * Returns: %TRUE if successfull, %FALSE otherwise.
+ *
+ **/
+gboolean
+ggit_diff_patch_get_line_stats (GgitDiffPatch  *diff_patch,
+                                gsize          *total_context,
+                                gsize          *total_additions,
+                                gsize          *total_deletions,
+                                GError        **error)
+{
+       size_t tc;
+       size_t ta;
+       size_t td;
+       gint ret;
+
+       g_return_val_if_fail (diff_patch != NULL, FALSE);
+       g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+       ret = git_diff_patch_line_stats (&tc, &ta, &td, diff_patch->diff_patch);
+
+       if (ret != GIT_OK)
+       {
+               _ggit_error_set (error, ret);
+               return FALSE;
+       }
+
+       if (total_context)
+       {
+               *total_context = tc;
+       }
+
+       if (total_additions)
+       {
+               *total_additions = ta;
+       }
+
+       if (total_deletions)
+       {
+               *total_deletions = td;
+       }
+
+       return TRUE;
+}
+
+/**
+ * ggit_diff_patch_get_num_hunks:
+ * @diff_patch: a #GgitDiffPatch.
+ *
+ * Get the number of hunks in the patch.
+ *
+ * Returns: the number of hunks.
+ *
+ **/
+gsize
+ggit_diff_patch_get_num_hunks (GgitDiffPatch *diff_patch)
+{
+       g_return_val_if_fail (diff_patch != NULL, FALSE);
+
+       return git_diff_patch_num_hunks (diff_patch->diff_patch);
+}
+
+/**
+ * ggit_diff_patch_get_num_lines_in_hunk:
+ * @diff_patch: a #GgitDiffPatch.
+ * @hunk: the hunk index.
+ *
+ * Get the number of lines in @hunk.
+ *
+ * Returns: the number of lines.
+ *
+ **/
+gint
+ggit_diff_patch_get_num_lines_in_hunk (GgitDiffPatch *diff_patch,
+                                       gsize          hunk)
+{
+       g_return_val_if_fail (diff_patch != NULL, FALSE);
+
+       return git_diff_patch_num_lines_in_hunk (diff_patch->diff_patch, hunk);
+}
+
 /* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-diff-patch.h b/libgit2-glib/ggit-diff-patch.h
index b7eccb0..6b580d6 100644
--- a/libgit2-glib/ggit-diff-patch.h
+++ b/libgit2-glib/ggit-diff-patch.h
@@ -46,6 +46,18 @@ gboolean         ggit_diff_patch_to_stream      (GgitDiffPatch    *diff_patch,
                                                  GOutputStream    *stream,
                                                  GError          **error);
 
+gboolean         ggit_diff_patch_get_line_stats (GgitDiffPatch    *diff_patch,
+                                                 gsize            *total_context,
+                                                 gsize            *total_additions,
+                                                 gsize            *total_deletions,
+                                                 GError          **error);
+
+gsize            ggit_diff_patch_get_num_hunks  (GgitDiffPatch    *diff_patch);
+
+gint             ggit_diff_patch_get_num_lines_in_hunk (
+                                                 GgitDiffPatch    *diff_patch,
+                                                 gsize             hunk);
+
 G_END_DECLS
 
 #endif /* __GGIT_DIFF_PATCH_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]