[libgit2-glib] Add ggit_repository_discover_full
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Add ggit_repository_discover_full
- Date: Sun, 6 Nov 2016 09:52:14 +0000 (UTC)
commit 0a66454cc2fc2333bbe41772e8508e617ac6a91b
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Sun Nov 6 01:50:44 2016 -0800
Add ggit_repository_discover_full
https://bugzilla.gnome.org/show_bug.cgi?id=772837
libgit2-glib/ggit-repository.c | 39 ++++++++++++++++++++++++++++++++++++---
libgit2-glib/ggit-repository.h | 5 +++++
2 files changed, 41 insertions(+), 3 deletions(-)
---
diff --git a/libgit2-glib/ggit-repository.c b/libgit2-glib/ggit-repository.c
index 90ded1a..c295c67 100644
--- a/libgit2-glib/ggit-repository.c
+++ b/libgit2-glib/ggit-repository.c
@@ -956,24 +956,57 @@ GFile *
ggit_repository_discover (GFile *location,
GError **error)
{
+ g_return_val_if_fail (G_IS_FILE (location), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ return ggit_repository_discover_full (location, FALSE, NULL, error);
+}
+
+/**
+ * ggit_repository_discover_full:
+ * @location: the base location where the lookup starts.
+ * @across_fs: indictaes whether lookup will work across filesystem devices.
+ * @ceiling_dirs: (array zero-terminated=1) (allow-none): a list of absolute paths
+ * at which lookup will stop when reached, or %NULL.
+ * @error: a #GError for error reporting, or %NULL.
+ *
+ * Looks for a git repository.
+ *
+ * The lookup starts from @path and walks up the parent directories
+ * and stops when a repository is found.
+ *
+ * Returns: (transfer full): the repository location.
+ */
+GFile *
+ggit_repository_discover_full (GFile *location,
+ gboolean across_fs,
+ const gchar **ceiling_dirs,
+ GError **error)
+{
gchar *path;
gint ret;
git_buf buf = {0,};
GFile *rep = NULL;
+ gchar *dirs_path = NULL;
+ gchar path_sep[2] = { GIT_PATH_LIST_SEPARATOR, 0 };
g_return_val_if_fail (G_IS_FILE (location), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
path = g_file_get_path (location);
-
g_return_val_if_fail (path != NULL, NULL);
+ if (ceiling_dirs != NULL) {
+ dirs_path = g_strjoinv (path_sep, (gchar **)ceiling_dirs);
+ }
+
ret = git_repository_discover (&buf,
path,
- 0,
- "");
+ across_fs ? 1 : 0,
+ dirs_path);
g_free (path);
+ g_free (dirs_path);
if (ret == GIT_OK)
{
diff --git a/libgit2-glib/ggit-repository.h b/libgit2-glib/ggit-repository.h
index 0254a45..9cdb09c 100644
--- a/libgit2-glib/ggit-repository.h
+++ b/libgit2-glib/ggit-repository.h
@@ -272,6 +272,11 @@ gboolean ggit_repository_set_head (GgitRepository *re
GFile *ggit_repository_discover (GFile *location,
GError **error);
+GFile *ggit_repository_discover_full (GFile *location,
+ gboolean across_fs,
+ const gchar **ceiling_dirs,
+ GError **error);
+
gboolean ggit_repository_is_head_detached (GgitRepository *repository,
GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]