Commit 0a66454c authored by Jesse van den Kieboom's avatar Jesse van den Kieboom
Browse files

Add ggit_repository_discover_full

https://bugzilla.gnome.org/show_bug.cgi?id=772837
parent 059a63ad
...@@ -955,25 +955,58 @@ ggit_repository_set_head (GgitRepository *repository, ...@@ -955,25 +955,58 @@ ggit_repository_set_head (GgitRepository *repository,
GFile * GFile *
ggit_repository_discover (GFile *location, ggit_repository_discover (GFile *location,
GError **error) 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; gchar *path;
gint ret; gint ret;
git_buf buf = {0,}; git_buf buf = {0,};
GFile *rep = NULL; 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 (G_IS_FILE (location), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL);
path = g_file_get_path (location); path = g_file_get_path (location);
g_return_val_if_fail (path != NULL, NULL); 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, ret = git_repository_discover (&buf,
path, path,
0, across_fs ? 1 : 0,
""); dirs_path);
g_free (path); g_free (path);
g_free (dirs_path);
if (ret == GIT_OK) if (ret == GIT_OK)
{ {
......
...@@ -272,6 +272,11 @@ gboolean ggit_repository_set_head (GgitRepository *re ...@@ -272,6 +272,11 @@ gboolean ggit_repository_set_head (GgitRepository *re
GFile *ggit_repository_discover (GFile *location, GFile *ggit_repository_discover (GFile *location,
GError **error); 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, gboolean ggit_repository_is_head_detached (GgitRepository *repository,
GError **error); GError **error);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment