[libgit2-glib] repository: add ggit_repository_path_is_ignored()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] repository: add ggit_repository_path_is_ignored()
- Date: Mon, 13 Apr 2015 18:49:59 +0000 (UTC)
commit c3224b70acfdbe0a9b4f927ca474cff4953f2453
Author: Christian Hergert <christian hergert me>
Date: Mon Apr 13 11:49:30 2015 -0700
repository: add ggit_repository_path_is_ignored()
This function is a convenience wrapper around git_ignore_path_is_ignored()
which takes a git_repository* and a path.
https://bugzilla.gnome.org/show_bug.cgi?id=747727
libgit2-glib/ggit-repository.c | 35 +++++++++++++++++++++++++++++++++++
libgit2-glib/ggit-repository.h | 3 +++
2 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/libgit2-glib/ggit-repository.c b/libgit2-glib/ggit-repository.c
index 0dbee2c..bc7094d 100644
--- a/libgit2-glib/ggit-repository.c
+++ b/libgit2-glib/ggit-repository.c
@@ -116,6 +116,41 @@ unregister_repository (git_repository *repository)
}
}
+/**
+ * ggit_repository_path_is_ignored:
+ * @repository: A #GgitRepository.
+ * @path: A path within the repository.
+ * @error: (allow-none): A location for a #GError, or %NULL.
+ *
+ * Tests if the ignore rules apply to the path provided.
+ *
+ * This acts similar to filtering performed when calling "git add ."
+ * on the command line.
+ *
+ * Returns: %TRUE if @path should be ignored.
+ */
+gboolean
+ggit_repository_path_is_ignored (GgitRepository *repository,
+ const gchar *path,
+ GError **error)
+{
+ int ignored = FALSE;
+ int ret;
+
+ g_return_val_if_fail (GGIT_IS_REPOSITORY (repository), FALSE);
+ g_return_val_if_fail (path != NULL, FALSE);
+
+ ret = git_ignore_path_is_ignored (&ignored, _ggit_native_get (repository), path);
+
+ if (ret != GIT_OK)
+ {
+ _ggit_error_set (error, ret);
+ return FALSE;
+ }
+
+ return !!ignored;
+}
+
static void
ggit_repository_finalize (GObject *object)
{
diff --git a/libgit2-glib/ggit-repository.h b/libgit2-glib/ggit-repository.h
index e48fd70..fd9536b 100644
--- a/libgit2-glib/ggit-repository.h
+++ b/libgit2-glib/ggit-repository.h
@@ -419,6 +419,9 @@ gboolean ggit_repository_note_foreach (GgitRepository
GgitNoteCallback callback,
gpointer user_data,
GError **error);
+gboolean ggit_repository_path_is_ignored (GgitRepository *repository,
+ const gchar *path,
+ GError **error);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]