[libgit2-glib] Add ggit_patch_get_hunk
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Add ggit_patch_get_hunk
- Date: Sat, 23 Nov 2013 14:53:30 +0000 (UTC)
commit 72f60e508a6efdab029bf0f8370271aacdb3c1f6
Author: Jesse van den Kieboom <jessevdk gmail com>
Date: Sat Nov 23 15:38:42 2013 +0100
Add ggit_patch_get_hunk
libgit2-glib/ggit-patch.c | 33 +++++++++++++++++++++++++++++++++
libgit2-glib/ggit-patch.h | 4 ++++
2 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/libgit2-glib/ggit-patch.c b/libgit2-glib/ggit-patch.c
index e89313b..a865d12 100644
--- a/libgit2-glib/ggit-patch.c
+++ b/libgit2-glib/ggit-patch.c
@@ -21,6 +21,7 @@
#include "ggit-patch.h"
#include "ggit-diff.h"
#include "ggit-diff-delta.h"
+#include "ggit-diff-hunk.h"
#include "ggit-error.h"
#include "ggit-diff-options.h"
@@ -379,4 +380,36 @@ ggit_patch_get_delta (GgitPatch *patch)
return _ggit_diff_delta_wrap (git_patch_get_delta (patch->patch));
}
+/**
+ * ggit_patch_get_hunk:
+ * @patch: a #GgitPatch
+ * @idx: the hunk index.
+ * @error: a #GError
+ *
+ * Get the @idx'th hunk in the patch.
+ *
+ * Returns: (transfer full): a new #GgitDiffHunk or %NULL on error.
+ */
+GgitDiffHunk *
+ggit_patch_get_hunk (GgitPatch *patch,
+ gsize idx,
+ GError **error)
+{
+ const git_diff_hunk *hunk;
+ size_t tlines;
+ gint ret;
+
+ g_return_val_if_fail (patch != NULL, NULL);
+
+ ret = git_patch_get_hunk (&hunk, &tlines, patch->patch, idx);
+
+ if (ret != GIT_OK)
+ {
+ _ggit_error_set (error, ret);
+ return NULL;
+ }
+
+ return _ggit_diff_hunk_wrap (hunk);
+}
+
/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-patch.h b/libgit2-glib/ggit-patch.h
index 7e5d7c1..2d2b848 100644
--- a/libgit2-glib/ggit-patch.h
+++ b/libgit2-glib/ggit-patch.h
@@ -71,6 +71,10 @@ gint ggit_patch_get_num_lines_in_hunk (
GgitDiffDelta *ggit_patch_get_delta (GgitPatch *patch);
+GgitDiffHunk *ggit_patch_get_hunk (GgitPatch *patch,
+ gsize idx,
+ GError **error);
+
G_END_DECLS
#endif /* __GGIT_PATCH_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]