[libgit2-glib] Update for changes in index API



commit 348e7595c4dc38f0554a8589bf682d75c9f23b7f
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Tue Oct 30 23:09:44 2012 +0100

    Update for changes in index API

 libgit2-glib/Makefile.am                     |    4 +-
 libgit2-glib/ggit-index-entry-resolve-undo.c |  301 ++++++++++++++++++++++++++
 libgit2-glib/ggit-index-entry-resolve-undo.h |   74 +++++++
 libgit2-glib/ggit-index-entry-unmerged.c     |  301 --------------------------
 libgit2-glib/ggit-index-entry-unmerged.h     |   74 -------
 libgit2-glib/ggit-index-entry.c              |   56 +++++-
 libgit2-glib/ggit-index-entry.h              |   11 +-
 libgit2-glib/ggit-index.c                    |   87 ++------
 libgit2-glib/ggit-index.h                    |   45 ++---
 libgit2-glib/ggit-types.h                    |   12 +-
 libgit2-glib/ggit.h                          |    2 +-
 11 files changed, 482 insertions(+), 485 deletions(-)
---
diff --git a/libgit2-glib/Makefile.am b/libgit2-glib/Makefile.am
index 84d0db2..953e144 100644
--- a/libgit2-glib/Makefile.am
+++ b/libgit2-glib/Makefile.am
@@ -28,7 +28,7 @@ INST_H_FILES =				\
 	ggit-error.h			\
 	ggit-index.h			\
 	ggit-index-entry.h		\
-	ggit-index-entry-unmerged.h	\
+	ggit-index-entry-resolve-undo.h	\
 	ggit-main.h			\
 	ggit-native.h			\
 	ggit-object.h			\
@@ -69,7 +69,7 @@ C_FILES =				\
 	ggit-error.c			\
 	ggit-index.c			\
 	ggit-index-entry.c		\
-	ggit-index-entry-unmerged.c	\
+	ggit-index-entry-resolve-undo.c	\
 	ggit-main.c			\
 	ggit-native.c			\
 	ggit-object.c			\
diff --git a/libgit2-glib/ggit-index-entry-resolve-undo.c b/libgit2-glib/ggit-index-entry-resolve-undo.c
new file mode 100644
index 0000000..f9cf660
--- /dev/null
+++ b/libgit2-glib/ggit-index-entry-resolve-undo.c
@@ -0,0 +1,301 @@
+/*
+ * ggit-index-entry-resolve_undo.c
+ * This file is part of libgit2-glib
+ *
+ * Copyright (C) 2012 - Jesse van den Kieboom
+ *
+ * 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/>.
+ */
+
+#include "ggit-index-entry-resolve-undo.h"
+#include "ggit-index.h"
+
+struct _GgitIndexEntriesResolveUndo
+{
+	GgitIndex *owner;
+	gint ref_count;
+};
+
+struct _GgitIndexEntryResolveUndo
+{
+	git_index_reuc_entry *entry;
+	gint ref_count;
+};
+
+G_DEFINE_BOXED_TYPE (GgitIndexEntriesResolveUndo,
+                     ggit_index_entries_resolve_undo,
+                     ggit_index_entries_resolve_undo_ref,
+                     ggit_index_entries_resolve_undo_unref)
+
+G_DEFINE_BOXED_TYPE (GgitIndexEntryResolveUndo,
+                     ggit_index_entry_resolve_undo,
+                     ggit_index_entry_resolve_undo_ref,
+                     ggit_index_entry_resolve_undo_unref)
+
+static GgitIndexEntryResolveUndo *
+ggit_index_entry_resolve_undo_new (git_index_reuc_entry *entry)
+{
+	GgitIndexEntryResolveUndo *ret;
+
+	ret = g_slice_new (GgitIndexEntryResolveUndo);
+	ret->entry = entry;
+	ret->ref_count = 1;
+
+	return ret;
+}
+
+GgitIndexEntriesResolveUndo *
+_ggit_index_entries_resolve_undo_new (GgitIndex *owner)
+{
+	GgitIndexEntriesResolveUndo *ret;
+
+	ret = g_slice_new (GgitIndexEntriesResolveUndo);
+	ret->owner = g_object_ref (owner);
+	ret->ref_count = 1;
+
+	return ret;
+}
+
+/**
+ * ggit_index_entry_resolve_undo_ref:
+ * @entry: a #GgitIndexEntryResolveUndo.
+ *
+ * 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 #GgitIndexEntryResolveUndo.
+ **/
+GgitIndexEntryResolveUndo *
+ggit_index_entry_resolve_undo_ref (GgitIndexEntryResolveUndo *entry)
+{
+	g_return_val_if_fail (entry != NULL, NULL);
+
+	g_atomic_int_inc (&entry->ref_count);
+
+	return entry;
+}
+
+/**
+ * ggit_index_entry_resolve_undo_unref:
+ * @entry: a #GgitIndexEntryResolveUndo.
+ *
+ * Atomically decrements the reference count of @entry by one.
+ * If the reference count drops to 0, @entry is freed.
+ **/
+void
+ggit_index_entry_resolve_undo_unref (GgitIndexEntryResolveUndo *entry)
+{
+	g_return_if_fail (entry != NULL);
+
+	if (g_atomic_int_dec_and_test (&entry->ref_count))
+	{
+		g_slice_free (GgitIndexEntryResolveUndo, entry);
+	}
+}
+
+/**
+ * ggit_index_entries_resolve_undo_ref:
+ * @entries: a #GgitIndexEntriesResolveUndo.
+ *
+ * Atomically increments the reference count of @entries by one.
+ * This function is MT-safe and may be called from any thread.
+ *
+ * Returns: (transfer none): a #GgitIndexEntriesResolveUndo.
+ *
+ **/
+GgitIndexEntriesResolveUndo *
+ggit_index_entries_resolve_undo_ref (GgitIndexEntriesResolveUndo *entries)
+{
+	g_return_val_if_fail (entries != NULL, NULL);
+
+	g_atomic_int_inc (&entries->ref_count);
+
+	return entries;
+}
+
+/**
+ * ggit_index_entries_resolve_undo_unref:
+ * @entries: a #GgitIndexEntriesResolveUndo.
+ *
+ * Atomically decrements the reference count of @entries by one.
+ * If the reference count drops to 0, @entries is freed.
+ **/
+void
+ggit_index_entries_resolve_undo_unref (GgitIndexEntriesResolveUndo *entries)
+{
+	g_return_if_fail (entries != NULL);
+
+	if (g_atomic_int_dec_and_test (&entries->ref_count))
+	{
+		g_clear_object (&entries->owner);
+		g_slice_free (GgitIndexEntriesResolveUndo, entries);
+	}
+}
+
+/**
+ * ggit_index_entries_resolve_undo_get:
+ * @entries: a #GgitIndexEntriesResolveUndo.
+ * @idx: the index of the entry.
+ *
+ * Get a #GgitIndexEntryResolveUndo by index. Note that the returned
+ * #GgitIndexEntryResolveUndo is _only_ valid as long as:
+ *
+ * 1) The associated index has been closed
+ * 2) The entry has not been removed (see ggit_index_remove())
+ * 3) The index has not been refreshed (see ggit_index_read())
+ *
+ * Returns: (transfer full): a #GgitIndexEntryResolveUndo.
+ *
+ **/
+GgitIndexEntryResolveUndo *
+ggit_index_entries_resolve_undo_get (GgitIndexEntriesResolveUndo *entries,
+                                     guint                        idx)
+{
+	git_index *gidx;
+	const git_index_reuc_entry *ret;
+
+	g_return_val_if_fail (entries != NULL, NULL);
+
+	gidx = _ggit_index_get_index (entries->owner);
+	ret = git_index_reuc_get_byindex (gidx, idx);
+
+	return ggit_index_entry_resolve_undo_new ((git_index_reuc_entry *)ret);
+}
+
+/**
+ * ggit_index_entries_resolve_undo_size:
+ * @entries: a #GgitIndexEntriesResolveUndo.
+ *
+ * Get the number of #GgitIndexEntryResolveUndo entries.
+ *
+ * Returns: the number of entries.
+ *
+ **/
+guint
+ggit_index_entries_resolve_undo_size (GgitIndexEntriesResolveUndo *entries)
+{
+	git_index *gidx;
+
+	g_return_val_if_fail (entries != NULL, 0);
+
+	gidx = _ggit_index_get_index (entries->owner);
+
+	return git_index_reuc_entrycount (gidx);
+}
+
+/**
+ * ggit_index_entries_resolve_undo_get_by_file:
+ * @entries: a #GgitIndexEntriesResolveUndo.
+ * @file: a #GFile.
+ *
+ * Get an resolve_undo entry specified by path. The returned entry is read
+ * only and should not be modified by the caller. If the entry could not be
+ * found, %NULL is returned.
+ *
+ * Returns: (transfer full): a #GgitIndexEntryResolveUndo or %NULL.
+ *
+ **/
+GgitIndexEntryResolveUndo *
+ggit_index_entries_resolve_undo_get_by_file (GgitIndexEntriesResolveUndo  *entries,
+                                             GFile                        *file)
+{
+	git_index *gidx;
+	const git_index_reuc_entry *ret;
+	gchar *path;
+
+	g_return_val_if_fail (entries != NULL, NULL);
+	g_return_val_if_fail (G_IS_FILE (file), NULL);
+
+	gidx = _ggit_index_get_index (entries->owner);
+	path = g_file_get_path (file);
+
+	g_return_val_if_fail (path != NULL, NULL);
+
+	ret = git_index_reuc_get_bypath (gidx, path);
+	g_free (path);
+
+	if (ret)
+	{
+		return ggit_index_entry_resolve_undo_new ((git_index_reuc_entry *)ret);
+	}
+	else
+	{
+		return NULL;
+	}
+}
+
+/**
+ * ggit_index_entry_resolve_undo_get_mode:
+ * @entry: a #GgitIndexEntryResolveUndo.
+ * @stage: the stage (0, 1 or 2)
+ *
+ * Get the mode of the index entry. The returned mode contains the modes from
+ * stage 1, 2 and 3.
+ *
+ * Returns: the mode.
+ *
+ **/
+guint
+ggit_index_entry_resolve_undo_get_mode (GgitIndexEntryResolveUndo *entry,
+                                        gint                    stage)
+{
+	g_return_val_if_fail (entry != NULL, 0);
+	g_return_val_if_fail (stage >= 0 && stage <= 3, 0);
+
+	return entry->entry->mode[stage];
+}
+
+/**
+ * ggit_index_entry_resolve_undo_get_id:
+ * @entry: a #GgitIndexEntryResolveUndo.
+ * @stage: the stage (0, 1 or 2)
+ *
+ * Get the oid of the index entry.
+ *
+ * Returns: the oid.
+ *
+ **/
+GgitOId *
+ggit_index_entry_resolve_undo_get_id (GgitIndexEntryResolveUndo *entry,
+                                      gint                    stage)
+{
+	g_return_val_if_fail (entry != NULL, NULL);
+	g_return_val_if_fail (stage >= 0 && stage <= 3, NULL);
+
+	return _ggit_oid_new (&entry->entry->oid[stage]);
+}
+
+/**
+ * ggit_index_entry_resolve_undo_get_file:
+ * @entry: a #GgitIndexEntryResolveUndo.
+ *
+ * Get the file of the index entry.
+ *
+ * Returns: (transfer full): a #GFile.
+ *
+ **/
+GFile *
+ggit_index_entry_resolve_undo_get_file (GgitIndexEntryResolveUndo *entry)
+{
+	g_return_val_if_fail (entry != NULL, 0);
+
+	if (entry->entry->path == NULL)
+	{
+		return NULL;
+	}
+
+	return g_file_new_for_path (entry->entry->path);
+}
+
+/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-index-entry-resolve-undo.h b/libgit2-glib/ggit-index-entry-resolve-undo.h
new file mode 100644
index 0000000..8db3047
--- /dev/null
+++ b/libgit2-glib/ggit-index-entry-resolve-undo.h
@@ -0,0 +1,74 @@
+/*
+ * ggit-index-entry-resolve-undo.h
+ * This file is part of libgit2-glib
+ *
+ * Copyright (C) 2012 - Jesse van den Kieboom
+ *
+ * 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_INDEX_ENTRY_RESOLVE_UNDO_H__
+#define __GGIT_INDEX_ENTRY_RESOLVE_UNDO_H__
+
+#include <glib-object.h>
+#include <gio/gio.h>
+#include <libgit2-glib/ggit-oid.h>
+#include <libgit2-glib/ggit-types.h>
+
+G_BEGIN_DECLS
+
+#define GGIT_TYPE_INDEX_ENTRY_RESOLVE_UNDO      (ggit_index_entry_resolve_undo_get_type ())
+#define GGIT_INDEX_ENTRY_RESOLVE_UNDO(obj)      ((GgitIndexEntryResolveUndo *)obj)
+
+#define GGIT_TYPE_INDEX_ENTRIES_RESOLVE_UNDO    (ggit_index_entries_resolve_undo_get_type ())
+#define GGIT_INDEX_ENTRIES_RESOLVE_UNDO(obj)    ((GgitIndexEntriesResolveUndo *)obj)
+
+GgitIndexEntriesResolveUndo *
+        _ggit_index_entries_resolve_undo_new        (GgitIndex                   *owner);
+
+GgitIndexEntryResolveUndo *
+         ggit_index_entries_resolve_undo_get        (GgitIndexEntriesResolveUndo *entries,
+                                                     guint                        idx);
+
+GgitIndexEntryResolveUndo *
+         ggit_index_entries_resolve_undo_get_by_file (GgitIndexEntriesResolveUndo *entries,
+                                                      GFile                       *file);
+
+GType    ggit_index_entries_resolve_undo_get_type    (void) G_GNUC_CONST;
+
+GgitIndexEntriesResolveUndo *
+         ggit_index_entries_resolve_undo_ref         (GgitIndexEntriesResolveUndo *entries);
+void     ggit_index_entries_resolve_undo_unref       (GgitIndexEntriesResolveUndo *entries);
+guint    ggit_index_entries_resolve_undo_size        (GgitIndexEntriesResolveUndo *entries);
+
+GType    ggit_index_entry_resolve_undo_get_type      (void) G_GNUC_CONST;
+
+GgitIndexEntryResolveUndo *
+         ggit_index_entry_resolve_undo_ref           (GgitIndexEntryResolveUndo   *entry);
+void     ggit_index_entry_resolve_undo_unref         (GgitIndexEntryResolveUndo   *entry);
+
+guint    ggit_index_entry_resolve_undo_get_mode      (GgitIndexEntryResolveUndo   *entry,
+                                                      gint                         stage);
+
+GgitOId *ggit_index_entry_resolve_undo_get_id        (GgitIndexEntryResolveUndo   *entry,
+                                                      gint                         stage);
+
+GFile   *ggit_index_entry_resolve_undo_get_file      (GgitIndexEntryResolveUndo   *entry);
+
+
+G_END_DECLS
+
+#endif /* __GGIT_INDEX_ENTRY_RESOLVE_UNDO_H__ */
+
+/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-index-entry.c b/libgit2-glib/ggit-index-entry.c
index 2dce962..539e6e8 100644
--- a/libgit2-glib/ggit-index-entry.c
+++ b/libgit2-glib/ggit-index-entry.c
@@ -144,7 +144,7 @@ ggit_index_entries_unref (GgitIndexEntries *entries)
 }
 
 /**
- * ggit_index_entries_get:
+ * ggit_index_entries_get_by_index:
  * @entries: a #GgitIndexEntries.
  * @idx: the index of the entry.
  *
@@ -162,8 +162,8 @@ ggit_index_entries_unref (GgitIndexEntries *entries)
  *
  **/
 GgitIndexEntry *
-ggit_index_entries_get (GgitIndexEntries *entries,
-                        guint             idx)
+ggit_index_entries_get_by_index (GgitIndexEntries *entries,
+                                 gsize             idx)
 {
 	git_index *gidx;
 
@@ -171,7 +171,47 @@ ggit_index_entries_get (GgitIndexEntries *entries,
 
 	gidx = _ggit_index_get_index (entries->owner);
 
-	return ggit_index_entry_new (git_index_get (gidx, idx));
+	return ggit_index_entry_new (git_index_get_byindex (gidx, idx));
+}
+
+/**
+ * ggit_index_entries_get_by_path:
+ * @entries: a #GgitIndexEntries.
+ * @file: the path to search.
+ * @stage: stage to search.
+ *
+ * Get a #GgitIndexEntry by index. Note that the returned #GgitIndexEntry is
+ * _only_ valid as long as:
+ *
+ * 1) The associated index has been closed
+ * 2) The entry has not been removed (see ggit_index_remove())
+ * 3) The index has not been refreshed (see ggit_index_read())
+ *
+ * Changes to the #GgitIndexEntry will be reflected in the index once written
+ * back to disk using ggit_index_write().
+ *
+ * Returns: (transfer full): a #GgitIndexEntry.
+ *
+ **/
+GgitIndexEntry *
+ggit_index_entries_get_by_path (GgitIndexEntries *entries,
+                                GFile            *file,
+                                gboolean          stage)
+{
+	git_index *gidx;
+	git_index_entry *entry;
+	gchar *path;
+
+	g_return_val_if_fail (entries != NULL, NULL);
+	g_return_val_if_fail (G_IS_FILE (file), NULL);
+	g_return_val_if_fail (stage >= 0 && stage <= 3, NULL);
+
+	gidx = _ggit_index_get_index (entries->owner);
+	path = g_file_get_path (file);
+	entry = git_index_get_bypath (gidx, path, stage);
+	g_free (path);
+
+	return ggit_index_entry_new (entry);
 }
 
 /**
@@ -370,4 +410,12 @@ ggit_index_entry_get_file (GgitIndexEntry *entry)
 	return g_file_new_for_path (entry->entry->path);
 }
 
+git_index_entry *
+_ggit_index_entry_get_native (GgitIndexEntry *entry)
+{
+	g_return_val_if_fail (entry != NULL, NULL);
+
+	return entry->entry;
+}
+
 /* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-index-entry.h b/libgit2-glib/ggit-index-entry.h
index c32e912..16ff95e 100644
--- a/libgit2-glib/ggit-index-entry.h
+++ b/libgit2-glib/ggit-index-entry.h
@@ -25,6 +25,7 @@
 #include <gio/gio.h>
 #include <libgit2-glib/ggit-oid.h>
 #include <libgit2-glib/ggit-types.h>
+#include <git2/index.h>
 
 G_BEGIN_DECLS
 
@@ -39,8 +40,12 @@ GgitIndexEntries *_ggit_index_entries_new             (GgitIndex         *owner)
 GgitIndexEntries *ggit_index_entries_ref              (GgitIndexEntries  *entries);
 void              ggit_index_entries_unref            (GgitIndexEntries  *entries);
 
-GgitIndexEntry   *ggit_index_entries_get              (GgitIndexEntries  *entries,
-                                                       guint              idx);
+GgitIndexEntry   *ggit_index_entries_get_by_index      (GgitIndexEntries  *entries,
+                                                        gsize              idx);
+
+GgitIndexEntry   *ggit_index_entries_get_by_path       (GgitIndexEntries *entries,
+                                                        GFile            *file,
+                                                        gboolean          stage);
 
 guint             ggit_index_entries_size             (GgitIndexEntries  *entries);
 
@@ -62,6 +67,8 @@ guint             ggit_index_entry_get_flags_extended (GgitIndexEntry    *entry)
 
 GFile            *ggit_index_entry_get_file           (GgitIndexEntry    *entry);
 
+git_index_entry *_ggit_index_entry_get_native         (GgitIndexEntry    *entry);
+
 G_END_DECLS
 
 #endif /* __GGIT_INDEX_ENTRY_H__ */
diff --git a/libgit2-glib/ggit-index.c b/libgit2-glib/ggit-index.c
index 5a70804..4120eea 100644
--- a/libgit2-glib/ggit-index.c
+++ b/libgit2-glib/ggit-index.c
@@ -300,24 +300,10 @@ ggit_index_write (GgitIndex  *idx,
 }
 
 /**
- * ggit_index_uniq:
- * @idx: a #GgitIndex.
- *
- * Remove all entries with equal path except last added.
- *
- **/
-void
-ggit_index_uniq (GgitIndex *idx)
-{
-	g_return_if_fail (GGIT_IS_INDEX (idx));
-
-	git_index_uniq (_ggit_native_get (idx));
-}
-
-/**
  * ggit_index_remove:
  * @idx: a #GgitIndex.
- * @position: the position of the file in the index.
+ * @file: the file to search.
+ * @stage: the stage to search.
  * @error: a #GError.
  *
  * Remove a file from the index (specified by position).
@@ -327,39 +313,6 @@ ggit_index_uniq (GgitIndex *idx)
  **/
 gboolean
 ggit_index_remove (GgitIndex  *idx,
-                   gint        position,
-                   GError    **error)
-{
-	gint ret;
-
-	g_return_val_if_fail (GGIT_IS_INDEX (idx), FALSE);
-	g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
-	ret = git_index_remove (_ggit_native_get (idx), position);
-
-	if (ret != GIT_OK)
-	{
-		_ggit_error_set (error, ret);
-		return FALSE;
-	}
-
-	return TRUE;
-}
-
-/**
- * ggit_index_append:
- * @idx: a #GgitIndex.
- * @file: a #GFile.
- * @stage: the stage.
- * @error: a #GError.
- *
- * Append a file to the index.
- *
- * Returns: %TRUE if the file was appended successfully, %FALSE otherwise.
- *
- **/
-gboolean
-ggit_index_append (GgitIndex  *idx,
                    GFile      *file,
                    gint        stage,
                    GError    **error)
@@ -369,13 +322,14 @@ ggit_index_append (GgitIndex  *idx,
 
 	g_return_val_if_fail (GGIT_IS_INDEX (idx), FALSE);
 	g_return_val_if_fail (G_IS_FILE (file), FALSE);
+	g_return_val_if_fail (stage >= 0 && stage <= 3, FALSE);
 	g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
 	path = g_file_get_path (file);
 
 	g_return_val_if_fail (path != NULL, FALSE);
 
-	ret = git_index_append (_ggit_native_get (idx), path, stage);
+	ret = git_index_remove (_ggit_native_get (idx), path, stage);
 	g_free (path);
 
 	if (ret != GIT_OK)
@@ -390,8 +344,7 @@ ggit_index_append (GgitIndex  *idx,
 /**
  * ggit_index_add:
  * @idx: a #GgitIndex.
- * @file: a #GFile.
- * @stage: the stage.
+ * @entry: a #GgitIndexEntry
  * @error: a #GError.
  *
  * Add a file to the index.
@@ -400,24 +353,18 @@ ggit_index_append (GgitIndex  *idx,
  *
  **/
 gboolean
-ggit_index_add (GgitIndex  *idx,
-                GFile      *file,
-                gint        stage,
-                GError    **error)
+ggit_index_add (GgitIndex       *idx,
+                GgitIndexEntry  *entry,
+                GError         **error)
 {
 	gint ret;
-	gchar *path;
 
 	g_return_val_if_fail (GGIT_IS_INDEX (idx), FALSE);
-	g_return_val_if_fail (G_IS_FILE (file), FALSE);
+	g_return_val_if_fail (entry != NULL, FALSE);
 	g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
-	path = g_file_get_path (file);
-
-	g_return_val_if_fail (path != NULL, FALSE);
-
-	ret = git_index_add (_ggit_native_get (idx), path, stage);
-	g_free (path);
+	ret = git_index_add (_ggit_native_get (idx),
+	                     _ggit_index_entry_get_native (entry));
 
 	if (ret != GIT_OK)
 	{
@@ -446,20 +393,20 @@ ggit_index_get_entries (GgitIndex *idx)
 }
 
 /**
- * ggit_index_get_entries_unmerged:
+ * ggit_index_get_entries_resolve_undo:
  * @idx: a #GgitIndex.
  *
- * Get the unmerged entries enumerator.
+ * Get the resolve undo entries enumerator.
  *
- * Returns: (transfer full): a #GgitIndexEntriesUnmerged.
+ * Returns: (transfer full): a #GgitIndexEntriesResolveUndo.
  *
  **/
-GgitIndexEntriesUnmerged *
-ggit_index_get_entries_unmerged (GgitIndex *idx)
+GgitIndexEntriesResolveUndo *
+ggit_index_get_entries_resolve_undo (GgitIndex *idx)
 {
 	g_return_val_if_fail (GGIT_IS_INDEX (idx), NULL);
 
-	return _ggit_index_entries_unmerged_new (idx);
+	return _ggit_index_entries_resolve_undo_new (idx);
 }
 
 /* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-index.h b/libgit2-glib/ggit-index.h
index 1f72cc1..16017bc 100644
--- a/libgit2-glib/ggit-index.h
+++ b/libgit2-glib/ggit-index.h
@@ -26,7 +26,7 @@
 #include <git2/index.h>
 #include <libgit2-glib/ggit-types.h>
 #include <libgit2-glib/ggit-index-entry.h>
-#include <libgit2-glib/ggit-index-entry-unmerged.h>
+#include <libgit2-glib/ggit-index-entry-resolve-undo.h>
 #include "ggit-native.h"
 
 G_BEGIN_DECLS
@@ -59,37 +59,32 @@ struct _GgitIndexClass
 	GgitNativeClass parent_class;
 };
 
-GType                     ggit_index_get_type             (void) G_GNUC_CONST;
+GType                     ggit_index_get_type                 (void) G_GNUC_CONST;
 
-git_index                *_ggit_index_get_index           (GgitIndex  *idx);
-GgitIndex                *_ggit_index_wrap                (git_index  *idx);
+git_index                *_ggit_index_get_index               (GgitIndex  *idx);
+GgitIndex                *_ggit_index_wrap                    (git_index  *idx);
 
-GgitIndex                *ggit_index_open                 (GFile      *file,
-                                                           GError    **error);
+GgitIndex                *ggit_index_open                     (GFile      *file,
+                                                               GError    **error);
 
+gboolean                  ggit_index_read                     (GgitIndex  *idx,
+                                                               GError    **error);
 
-gboolean                  ggit_index_read                 (GgitIndex  *idx,
-                                                           GError    **error);
-gboolean                  ggit_index_write                (GgitIndex  *idx,
-                                                           GError    **error);
-void                      ggit_index_uniq                 (GgitIndex  *idx);
+gboolean                  ggit_index_write                    (GgitIndex  *idx,
+                                                               GError    **error);
 
-gboolean                  ggit_index_remove               (GgitIndex  *idx,
-                                                           gint        position,
-                                                           GError    **error);
+gboolean                  ggit_index_remove                   (GgitIndex  *idx,
+                                                               GFile      *file,
+                                                               gint        stage,
+                                                               GError    **error);
 
-gboolean                  ggit_index_append               (GgitIndex  *idx,
-                                                           GFile      *file,
-                                                           gint        stage,
-                                                           GError    **error);
+gboolean                  ggit_index_add                      (GgitIndex       *idx,
+                                                               GgitIndexEntry  *entry,
+                                                               GError         **error);
 
-gboolean                  ggit_index_add                  (GgitIndex  *idx,
-                                                           GFile      *file,
-                                                           gint        stage,
-                                                           GError    **error);
-
-GgitIndexEntries         *ggit_index_get_entries          (GgitIndex  *idx);
-GgitIndexEntriesUnmerged *ggit_index_get_entries_unmerged (GgitIndex  *idx);
+GgitIndexEntries         *ggit_index_get_entries              (GgitIndex  *idx);
+GgitIndexEntriesResolveUndo *
+                          ggit_index_get_entries_resolve_undo (GgitIndex  *idx);
 
 G_END_DECLS
 
diff --git a/libgit2-glib/ggit-types.h b/libgit2-glib/ggit-types.h
index aef062f..fc0ad83 100644
--- a/libgit2-glib/ggit-types.h
+++ b/libgit2-glib/ggit-types.h
@@ -117,18 +117,18 @@ typedef struct _GgitIndexEntries GgitIndexEntries;
 typedef struct _GgitIndexEntry GgitIndexEntry;
 
 /**
- * GgitIndexEntriesUnmerged:
+ * GgitIndexEntriesResolveUndo:
  *
- * Represents the unmerged entries in an index object.
+ * Represents the resolve undo entries in an index object.
  */
-typedef struct _GgitIndexEntriesUnmerged GgitIndexEntriesUnmerged;
+typedef struct _GgitIndexEntriesResolveUndo GgitIndexEntriesResolveUndo;
 
 /**
- * GgitIndexEntryUnmerged:
+ * GgitIndexEntryResolveUndo:
  *
- * Represents an unmerged index entry object.
+ * Represents an resolve undo index entry object.
  */
-typedef struct _GgitIndexEntryUnmerged GgitIndexEntryUnmerged;
+typedef struct _GgitIndexEntryResolveUndo GgitIndexEntryResolveUndo;
 
 /**
  * GgitNative:
diff --git a/libgit2-glib/ggit.h b/libgit2-glib/ggit.h
index 8ac4504..4189ed5 100644
--- a/libgit2-glib/ggit.h
+++ b/libgit2-glib/ggit.h
@@ -33,7 +33,7 @@
 #include <libgit2-glib/ggit-error.h>
 #include <libgit2-glib/ggit-index.h>
 #include <libgit2-glib/ggit-index-entry.h>
-#include <libgit2-glib/ggit-index-entry-unmerged.h>
+#include <libgit2-glib/ggit-index-entry-resolve-undo.h>
 #include <libgit2-glib/ggit-main.h>
 #include <libgit2-glib/ggit-native.h>
 #include <libgit2-glib/ggit-object.h>



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