[libgit2-glib] Rename GgitDiffPatch to GgitPatch
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Rename GgitDiffPatch to GgitPatch
- Date: Thu, 21 Nov 2013 12:41:22 +0000 (UTC)
commit 6ee2c022627254a81599003daa3d162c736c3746
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Thu Nov 21 13:24:08 2013 +0100
Rename GgitDiffPatch to GgitPatch
libgit2-glib/Makefile.am | 4 +-
libgit2-glib/ggit-diff-list.c | 12 +-
libgit2-glib/ggit-diff-list.h | 2 +-
libgit2-glib/ggit-diff-patch.h | 65 -----------
libgit2-glib/{ggit-diff-patch.c => ggit-patch.c} | 126 +++++++++++-----------
libgit2-glib/ggit-patch.h | 65 +++++++++++
libgit2-glib/ggit-types.h | 14 ++--
libgit2-glib/ggit.h | 2 +-
8 files changed, 145 insertions(+), 145 deletions(-)
---
diff --git a/libgit2-glib/Makefile.am b/libgit2-glib/Makefile.am
index fa3341d..76fd8bb 100644
--- a/libgit2-glib/Makefile.am
+++ b/libgit2-glib/Makefile.am
@@ -31,7 +31,6 @@ INST_H_FILES = \
ggit-diff-delta.h \
ggit-diff-file.h \
ggit-diff-options.h \
- ggit-diff-patch.h \
ggit-diff-range.h \
ggit-diff-similarity-metric.h \
ggit-error.h \
@@ -46,6 +45,7 @@ INST_H_FILES = \
ggit-object-factory.h \
ggit-object-factory-base.h \
ggit-oid.h \
+ ggit-patch.h \
ggit-push.h \
ggit-ref.h \
ggit-ref-spec.h \
@@ -84,7 +84,6 @@ C_FILES = \
ggit-diff-delta.c \
ggit-diff-file.c \
ggit-diff-options.c \
- ggit-diff-patch.c \
ggit-diff-range.c \
ggit-diff-similarity-metric.c \
ggit-error.c \
@@ -99,6 +98,7 @@ C_FILES = \
ggit-object-factory.c \
ggit-object-factory-base.c \
ggit-oid.c \
+ ggit-patch.c \
ggit-push.c \
ggit-ref.c \
ggit-ref-spec.c \
diff --git a/libgit2-glib/ggit-diff-list.c b/libgit2-glib/ggit-diff-list.c
index 79b87e8..9b6c70b 100644
--- a/libgit2-glib/ggit-diff-list.c
+++ b/libgit2-glib/ggit-diff-list.c
@@ -21,10 +21,10 @@
#include <git2.h>
#include "ggit-diff-list.h"
-#include "ggit-diff-patch.h"
#include "ggit-diff-delta.h"
#include "ggit-diff-options.h"
#include "ggit-diff-range.h"
+#include "ggit-patch.h"
#include "ggit-error.h"
#include "ggit-repository.h"
@@ -493,18 +493,18 @@ ggit_diff_list_get_num_deltas (GgitDiffList *diff)
* ggit_diff_list_get_patch:
* @diff: a #GgitDiffList.
* @idx: index into @diff.
- * @patch: (allow-none) (out): a #GgitDiffPatch or %NULL.
+ * @patch: (allow-none) (out): a #GgitPatch or %NULL.
* @delta: (allow-none) (out): a #GgitDiffDelta or %NULL.
* @error: a #GError for error reporting, or %NULL.
*
* Gets the diff delta and patch for an entry in @diff.
*
- * The #GgitDiffPatch is a newly created object contains the text diffs
+ * The #GgitPatch is a newly created object contains the text diffs
* for the delta. You have to call git_diff_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.
*
- * For an unchanged file or a binary file, no #GgitDiffPatch will be
+ * For an unchanged file or a binary file, no #GgitPatch will be
* created, the output will be set to %NULL, and the `binary` flag will be
* set true in @delta.
*
@@ -514,7 +514,7 @@ ggit_diff_list_get_num_deltas (GgitDiffList *diff)
void
ggit_diff_list_get_patch (GgitDiffList *diff,
gsize idx,
- GgitDiffPatch **patch,
+ GgitPatch **patch,
GgitDiffDelta **delta,
GError **error)
{
@@ -538,7 +538,7 @@ ggit_diff_list_get_patch (GgitDiffList *diff,
if (patch && patch_out)
{
- *patch = _ggit_diff_patch_wrap (patch_out);
+ *patch = _ggit_patch_wrap (patch_out);
}
if (delta)
diff --git a/libgit2-glib/ggit-diff-list.h b/libgit2-glib/ggit-diff-list.h
index 30dbf40..f240079 100644
--- a/libgit2-glib/ggit-diff-list.h
+++ b/libgit2-glib/ggit-diff-list.h
@@ -104,7 +104,7 @@ gint ggit_diff_list_get_num_deltas (GgitDiffList *diff)
void ggit_diff_list_get_patch (GgitDiffList *diff,
gsize idx,
- GgitDiffPatch **patch,
+ GgitPatch **patch,
GgitDiffDelta **delta,
GError **error);
diff --git a/libgit2-glib/ggit-diff-patch.c b/libgit2-glib/ggit-patch.c
similarity index 59%
rename from libgit2-glib/ggit-diff-patch.c
rename to libgit2-glib/ggit-patch.c
index 41fa249..574bb50 100644
--- a/libgit2-glib/ggit-diff-patch.c
+++ b/libgit2-glib/ggit-patch.c
@@ -1,5 +1,5 @@
/*
- * ggit-diff-patch.c
+ * ggit-patch.c
* This file is part of libgit2-glib
*
* Copyright (C) 2013 - Sindhu S
@@ -18,71 +18,71 @@
* along with libgit2-glib. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ggit-diff-patch.h"
+#include "ggit-patch.h"
#include "ggit-error.h"
-struct _GgitDiffPatch
+struct _GgitPatch
{
- git_diff_patch *diff_patch;
+ git_patch *patch;
gint ref_count;
};
-G_DEFINE_BOXED_TYPE (GgitDiffPatch, ggit_diff_patch,
- ggit_diff_patch_ref, ggit_diff_patch_unref)
+G_DEFINE_BOXED_TYPE (GgitPatch, ggit_patch,
+ ggit_patch_ref, ggit_patch_unref)
-GgitDiffPatch *
-_ggit_diff_patch_wrap (git_diff_patch *diff_patch)
+GgitPatch *
+_ggit_patch_wrap (git_patch *patch)
{
- GgitDiffPatch *gdiff_patch;
+ GgitPatch *gpatch;
- gdiff_patch = g_slice_new (GgitDiffPatch);
- gdiff_patch->diff_patch = diff_patch;
- gdiff_patch->ref_count = 1;
+ gpatch = g_slice_new (GgitPatch);
+ gpatch->patch = patch;
+ gpatch->ref_count = 1;
- return gdiff_patch;
+ return gpatch;
}
/**
- * ggit_diff_patch_ref:
- * @diff_patch: a #GgitDiffPatch.
+ * ggit_patch_ref:
+ * @patch: a #GgitPatch.
*
* Atomically increments the reference count of @entry by one.
* This function is MT-safe and may be called from any thread.
*
- * Returns: (transfer none): a #GgitDiffPatch.
+ * Returns: (transfer none): a #GgitPatch.
*/
-GgitDiffPatch *
-ggit_diff_patch_ref (GgitDiffPatch *diff_patch)
+GgitPatch *
+ggit_patch_ref (GgitPatch *patch)
{
- g_return_val_if_fail (diff_patch != NULL, NULL);
+ g_return_val_if_fail (patch != NULL, NULL);
- g_atomic_int_inc (&diff_patch->ref_count);
+ g_atomic_int_inc (&patch->ref_count);
- return diff_patch;
+ return patch;
}
/**
- * ggit_diff_patch_unref:
- * @diff_patch: a #GgitDiffPatch.
+ * ggit_patch_unref:
+ * @patch: a #GgitPatch.
*
* Atomically decrements the reference count of @entry by one.
* If the reference count drops to 0, @entry is freed.
*/
void
-ggit_diff_patch_unref (GgitDiffPatch *diff_patch)
+ggit_patch_unref (GgitPatch *patch)
{
- g_return_if_fail (diff_patch != NULL);
+ g_return_if_fail (patch != NULL);
- if (g_atomic_int_dec_and_test (&diff_patch->ref_count))
+ if (g_atomic_int_dec_and_test (&patch->ref_count))
{
- git_diff_patch_free (diff_patch->diff_patch);
- g_slice_free (GgitDiffPatch, diff_patch);
+ git_patch_free (patch->patch);
+ g_slice_free (GgitPatch, patch);
}
}
/**
- * ggit_diff_patch_to_string:
- * @diff_patch: a #GgitDiffPatch.
+ * ggit_patch_to_string:
+ * @patch: a #GgitPatch.
* @error: a #GError for error reporting, or %NULL.
*
* Gets the content of a patch as a single diff text.
@@ -90,17 +90,17 @@ ggit_diff_patch_unref (GgitDiffPatch *diff_patch)
* Returns: the content of a patch as a single diff text.
*/
gchar *
-ggit_diff_patch_to_string (GgitDiffPatch *diff_patch,
- GError **error)
+ggit_patch_to_string (GgitPatch *patch,
+ GError **error)
{
char *retval;
gchar *result = NULL;
gint ret;
- g_return_val_if_fail (diff_patch != NULL, NULL);
+ g_return_val_if_fail (patch != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- ret = git_diff_patch_to_str (&retval, diff_patch->diff_patch);
+ ret = git_patch_to_str (&retval, diff_patch->diff_patch);
if (ret == GIT_OK)
{
result = g_strdup (retval);
@@ -146,8 +146,8 @@ patch_to_stream (const git_diff_delta *delta,
}
/**
- * ggit_diff_patch_to_stream:
- * @diff_patch: a #GgitDiffPatch.
+ * ggit_patch_to_stream:
+ * @patch: a #GgitPatch.
* @stream: a #GOutputStream.
* @error: a #GError for error reporting, or %NULL.
*
@@ -157,23 +157,23 @@ patch_to_stream (const git_diff_delta *delta,
*
**/
gboolean
-ggit_diff_patch_to_stream (GgitDiffPatch *diff_patch,
- GOutputStream *stream,
- GError **error)
+ggit_patch_to_stream (GgitPatch *patch,
+ GOutputStream *stream,
+ GError **error)
{
PatchToStream info;
gint ret;
- g_return_val_if_fail (diff_patch != NULL, FALSE);
+ g_return_val_if_fail (patch != NULL, FALSE);
g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
info.stream = stream;
info.error = error;
- ret = git_diff_patch_print (diff_patch->diff_patch,
- patch_to_stream,
- &info);
+ ret = git_patch_print (patch->patch,
+ patch_to_stream,
+ &info);
if (ret != GIT_OK)
{
@@ -189,8 +189,8 @@ ggit_diff_patch_to_stream (GgitDiffPatch *diff_patch,
}
/**
- * ggit_diff_patch_get_line_stats:
- * @diff_patch: a #GgitDiffPatch.
+ * ggit_patch_get_line_stats:
+ * @patch: a #GgitPatch.
* @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.
@@ -202,21 +202,21 @@ ggit_diff_patch_to_stream (GgitDiffPatch *diff_patch,
*
**/
gboolean
-ggit_diff_patch_get_line_stats (GgitDiffPatch *diff_patch,
- gsize *total_context,
- gsize *total_additions,
- gsize *total_deletions,
- GError **error)
+ggit_patch_get_line_stats (GgitPatch *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 (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);
+ ret = git_patch_line_stats (&tc, &ta, &td, patch->patch);
if (ret != GIT_OK)
{
@@ -243,8 +243,8 @@ ggit_diff_patch_get_line_stats (GgitDiffPatch *diff_patch,
}
/**
- * ggit_diff_patch_get_num_hunks:
- * @diff_patch: a #GgitDiffPatch.
+ * ggit_patch_get_num_hunks:
+ * @patch: a #GgitPatch.
*
* Get the number of hunks in the patch.
*
@@ -252,16 +252,16 @@ ggit_diff_patch_get_line_stats (GgitDiffPatch *diff_patch,
*
**/
gsize
-ggit_diff_patch_get_num_hunks (GgitDiffPatch *diff_patch)
+ggit_patch_get_num_hunks (GgitPatch *patch)
{
- g_return_val_if_fail (diff_patch != NULL, FALSE);
+ g_return_val_if_fail (patch != NULL, FALSE);
- return git_diff_patch_num_hunks (diff_patch->diff_patch);
+ return git_patch_num_hunks (patch->patch);
}
/**
- * ggit_diff_patch_get_num_lines_in_hunk:
- * @diff_patch: a #GgitDiffPatch.
+ * ggit_patch_get_num_lines_in_hunk:
+ * @patch: a #GgitPatch.
* @hunk: the hunk index.
*
* Get the number of lines in @hunk.
@@ -270,12 +270,12 @@ ggit_diff_patch_get_num_hunks (GgitDiffPatch *diff_patch)
*
**/
gint
-ggit_diff_patch_get_num_lines_in_hunk (GgitDiffPatch *diff_patch,
- gsize hunk)
+ggit_patch_get_num_lines_in_hunk (GgitPatch *patch,
+ gsize hunk)
{
- g_return_val_if_fail (diff_patch != NULL, FALSE);
+ g_return_val_if_fail (patch != NULL, FALSE);
- return git_diff_patch_num_lines_in_hunk (diff_patch->diff_patch, hunk);
+ return git_patch_num_lines_in_hunk (patch->patch, hunk);
}
/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-patch.h b/libgit2-glib/ggit-patch.h
new file mode 100644
index 0000000..7484261
--- /dev/null
+++ b/libgit2-glib/ggit-patch.h
@@ -0,0 +1,65 @@
+/*
+ * ggit-patch.h
+ * This file is part of libgit2-glib
+ *
+ * Copyright (C) 2013 - Sindhu S
+ *
+ * libgit2-glib is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * libgit2-glib is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with libgit2-glib. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GGIT_PATCH_H__
+#define __GGIT_PATCH_H__
+
+#include <glib-object.h>
+#include <gio/gio.h>
+#include <git2.h>
+#include "ggit-types.h"
+
+G_BEGIN_DECLS
+
+#define GGIT_TYPE_PATCH (ggit_patch_get_type ())
+#define GGIT_PATCH(obj) ((GgitPatch *)obj)
+
+GType ggit_patch_get_type (void) G_GNUC_CONST;
+
+GgitPatch *_ggit_patch_wrap (git_patch *patch);
+
+GgitPatch *ggit_patch_ref (GgitPatch *patch);
+
+void ggit_patch_unref (GgitPatch *patch);
+
+gchar *ggit_patch_to_string (GgitPatch *patch,
+ GError **error);
+
+gboolean ggit_patch_to_stream (GgitPatch *patch,
+ GOutputStream *stream,
+ GError **error);
+
+gboolean ggit_patch_get_line_stats (GgitPatch *patch,
+ gsize *total_context,
+ gsize *total_additions,
+ gsize *total_deletions,
+ GError **error);
+
+gsize ggit_patch_get_num_hunks (GgitPatch *patch);
+
+gint ggit_patch_get_num_lines_in_hunk (
+ GgitPatch *patch,
+ gsize hunk);
+
+G_END_DECLS
+
+#endif /* __GGIT_PATCH_H__ */
+
+/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-types.h b/libgit2-glib/ggit-types.h
index 7f29a8d..4a269d8 100644
--- a/libgit2-glib/ggit-types.h
+++ b/libgit2-glib/ggit-types.h
@@ -110,13 +110,6 @@ typedef struct _GgitDiffList GgitDiffList;
typedef struct _GgitDiffDelta GgitDiffDelta;
/**
- * GgitDiffPatch:
- *
- * Represents a patch object.
- */
-typedef struct _GgitDiffPatch GgitDiffPatch;
-
-/**
* GgitDiffFile:
*
* Represents a file in a #GgitDiff.
@@ -222,6 +215,13 @@ typedef struct _GgitObjectFactoryBase GgitObjectFactoryBase;
typedef struct _GgitOId GgitOId;
/**
+ * GgitPatch:
+ *
+ * Represents a patch object.
+ */
+typedef struct _GgitPatch GgitPatch;
+
+/**
* GgitPush:
*
* Represents a git push.
diff --git a/libgit2-glib/ggit.h b/libgit2-glib/ggit.h
index 2e8cd50..dbef8f7 100644
--- a/libgit2-glib/ggit.h
+++ b/libgit2-glib/ggit.h
@@ -34,7 +34,6 @@
#include <libgit2-glib/ggit-diff-delta.h>
#include <libgit2-glib/ggit-diff-file.h>
#include <libgit2-glib/ggit-diff-options.h>
-#include <libgit2-glib/ggit-diff-patch.h>
#include <libgit2-glib/ggit-diff-range.h>
#include <libgit2-glib/ggit-enum-types.h>
#include <libgit2-glib/ggit-error.h>
@@ -48,6 +47,7 @@
#include <libgit2-glib/ggit-object-factory.h>
#include <libgit2-glib/ggit-object-factory-base.h>
#include <libgit2-glib/ggit-oid.h>
+#include <libgit2-glib/ggit-patch.h>
#include <libgit2-glib/ggit-push.h>
#include <libgit2-glib/ggit-ref.h>
#include <libgit2-glib/ggit-ref-spec.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]