[libgit2-glib] Bind git_attr_get



commit 988a7b201e864c1ba42e1ec35e21629d2748b7f1
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Fri Dec 27 16:16:32 2013 +0100

    Bind git_attr_get
    
    This API is exposed as ggit_repository_get_attribute on the
    GgitRepository.

 libgit2-glib/ggit-repository.c |   43 ++++++++++++++++++++++++++++++++++++++++
 libgit2-glib/ggit-repository.h |    6 +++++
 libgit2-glib/ggit-types.c      |    5 ++++
 libgit2-glib/ggit-types.h      |   20 ++++++++++++++++++
 4 files changed, 74 insertions(+), 0 deletions(-)
---
diff --git a/libgit2-glib/ggit-repository.c b/libgit2-glib/ggit-repository.c
index 9e1d058..b37d7a9 100644
--- a/libgit2-glib/ggit-repository.c
+++ b/libgit2-glib/ggit-repository.c
@@ -2394,4 +2394,47 @@ ggit_repository_blame_file (GgitRepository    *repository,
        return _ggit_blame_wrap (blame);
 }
 
+/**
+ * ggit_repository_get_attribute:
+ * @repository: a #GgitRepository.
+ * @path: the relative path to the file.
+ * @name: the name of the attribute.
+ * @flags: a #GgitAttributeCheckFlags.
+ * @error: a #GError.
+ *
+ * Get the attribute value of the specified attribute for the given file.
+ *
+ * Returns: the attribute value, or %NULL.
+ *
+ **/
+const gchar *
+ggit_repository_get_attribute (GgitRepository           *repository,
+                               const gchar              *path,
+                               const gchar              *name,
+                               GgitAttributeCheckFlags   flags,
+                               GError                  **error)
+{
+       const char *value;
+       int ret;
+
+       g_return_val_if_fail (GGIT_IS_REPOSITORY (repository), NULL);
+       g_return_val_if_fail (path != NULL, NULL);
+       g_return_val_if_fail (name != NULL, NULL);
+       g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+       ret = git_attr_get (&value,
+                           _ggit_native_get (repository),
+                           flags,
+                           path,
+                           name);
+
+       if (ret != GIT_OK)
+       {
+               _ggit_error_set (error, ret);
+               return NULL;
+       }
+
+       return value;
+}
+
 /* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-repository.h b/libgit2-glib/ggit-repository.h
index 8f2a348..55e2c51 100644
--- a/libgit2-glib/ggit-repository.h
+++ b/libgit2-glib/ggit-repository.h
@@ -310,6 +310,12 @@ GgitBlame          *ggit_repository_blame_file        (GgitRepository        *re
                                                        GgitBlameOptions      *blame_options,
                                                        GError               **error);
 
+const gchar        *ggit_repository_get_attribute     (GgitRepository           *repository,
+                                                       const gchar              *path,
+                                                       const gchar              *name,
+                                                       GgitAttributeCheckFlags   flags,
+                                                       GError                  **error);
+
 G_END_DECLS
 
 #endif /* __GGIT_REPOSITORY_H__ */
diff --git a/libgit2-glib/ggit-types.c b/libgit2-glib/ggit-types.c
index 117fd39..6041829 100644
--- a/libgit2-glib/ggit-types.c
+++ b/libgit2-glib/ggit-types.c
@@ -209,4 +209,9 @@ ASSERT_ENUM (GGIT_STATUS_SHOW_WORKDIR_ONLY,      GIT_STATUS_SHOW_WORKDIR_ONLY);
 ASSERT_ENUM (GGIT_BLAME_NORMAL,                 GIT_BLAME_NORMAL);
 ASSERT_ENUM (GGIT_BLAME_TRACK_COPIES_SAME_FILE, GIT_BLAME_TRACK_COPIES_SAME_FILE);
 
+ASSERT_ENUM (GGIT_ATTRIBUTE_CHECK_FILE_THEN_INDEX, GIT_ATTR_CHECK_FILE_THEN_INDEX);
+ASSERT_ENUM (GGIT_ATTRIBUTE_CHECK_INDEX_THEN_FILE, GIT_ATTR_CHECK_INDEX_THEN_FILE);
+ASSERT_ENUM (GGIT_ATTRIBUTE_CHECK_INDEX_ONLY,      GIT_ATTR_CHECK_INDEX_ONLY);
+ASSERT_ENUM (GGIT_ATTRIBUTE_CHECK_NO_SYSTEM,       GIT_ATTR_CHECK_NO_SYSTEM);
+
 /* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-types.h b/libgit2-glib/ggit-types.h
index 97a9ae5..f424012 100644
--- a/libgit2-glib/ggit-types.h
+++ b/libgit2-glib/ggit-types.h
@@ -913,6 +913,26 @@ typedef enum {
 } GgitStatusShow;
 
 /**
+ * GgitAttributeCheckFlags:
+ * @GGIT_ATTRIBUTE_CHECK_FILE_THEN_INDEX: check working directory, then index.
+ * @GGIT_ATTRIBUTE_CHECK_INDEX_THEN_FILE: check index, then working directory.
+ * @GGIT_ATTRIBUTE_CHECK_INDEX_ONLY: check only index.
+ * @GGIT_ATTRIBUTE_CHECK_NO_SYSTEM: ignore system wide attributes.
+ *
+ * Attribute check flags indicate the order in which to check for gitattributes.
+ * git core uses @GGIT_ATTRIBUTE_CHECK_FILE_THEN_INDEX for all operations,
+ * except on checkout, where it uses @GGIT_ATTRIBUTE_CHECK_INDEX_THEN_FILE.
+ *
+ */
+typedef enum
+{
+       GGIT_ATTRIBUTE_CHECK_FILE_THEN_INDEX = 0,
+       GGIT_ATTRIBUTE_CHECK_INDEX_THEN_FILE = 1 << 0,
+       GGIT_ATTRIBUTE_CHECK_INDEX_ONLY      = 1 << 1,
+       GGIT_ATTRIBUTE_CHECK_NO_SYSTEM       = 1 << 2,
+} GgitAttributeCheckFlags;
+
+/**
  * GgitConfigCallback:
  * @entry: a #GgitConfigEntry.
  * @user_data: (closure): user-supplied data.


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