[libgit2-glib] Bind ggit_ref_is_valid_name



commit d8527deb14ffd84bee136b584390d2b57ee1258a
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Tue Jan 7 14:45:06 2014 +0100

    Bind ggit_ref_is_valid_name

 libgit2-glib/ggit-ref.c |   24 ++++++++++++++++++++++++
 libgit2-glib/ggit-ref.h |    2 ++
 2 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/libgit2-glib/ggit-ref.c b/libgit2-glib/ggit-ref.c
index 4c2fbb0..67405f4 100644
--- a/libgit2-glib/ggit-ref.c
+++ b/libgit2-glib/ggit-ref.c
@@ -51,6 +51,30 @@ _ggit_ref_wrap (git_reference *ref)
 }
 
 /**
+ * ggit_ref_is_valid_name:
+ * @name: the name to validate.
+ *
+ * Check if the given @name is a valid name for a reference. Note that @name
+ * should be the full ref name (including prefixes).
+ *
+ * Valid toplevel names can contain only capital letters and underscores
+ * and must start and end with a letter (e.g. HEAD, ORIG_HEAD).
+ *
+ * Valid refs/ names may contain any characters, except '~', '^', ':', '\', '?',
+ * '[', '*', ".." and "@{", because they are interpreted by revparse.
+ *
+ * Returns: %TRUE if @name is valid, %FALSE otherwise.
+ *
+ **/
+gboolean
+ggit_ref_is_valid_name (const gchar *name)
+{
+       g_return_val_if_fail (name != NULL, FALSE);
+
+       return git_reference_is_valid_name (name) == 1;
+}
+
+/**
  * ggit_ref_get_target:
  * @ref: a #GgitRef.
  *
diff --git a/libgit2-glib/ggit-ref.h b/libgit2-glib/ggit-ref.h
index f122721..616a56b 100644
--- a/libgit2-glib/ggit-ref.h
+++ b/libgit2-glib/ggit-ref.h
@@ -62,6 +62,8 @@ GType           ggit_ref_get_type           (void) G_GNUC_CONST;
 
 GgitRef        *_ggit_ref_wrap              (git_reference  *ref);
 
+gboolean        ggit_ref_is_valid_name      (const gchar    *name);
+
 GgitOId        *ggit_ref_get_target         (GgitRef        *ref);
 
 const gchar    *ggit_ref_get_symbolic_target(GgitRef        *ref);


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