[gnome-builder] vcs: allow NULL self for pattern checking
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] vcs: allow NULL self for pattern checking
- Date: Thu, 25 Jan 2018 11:14:49 +0000 (UTC)
commit c0d52e9e4ddb15733a111a5a8433af8cd16a03ef
Author: Christian Hergert <chergert redhat com>
Date: Thu Jan 25 03:10:50 2018 -0800
vcs: allow NULL self for pattern checking
It would be nice to reuse the pattern checking code here without
having to have a VCS instance we're working with. This is useful
for such situations ans avoiding common build directories in
threaded workers.
src/libide/vcs/ide-vcs.c | 33 ++++++++++++++++++++++-----------
1 file changed, 22 insertions(+), 11 deletions(-)
---
diff --git a/src/libide/vcs/ide-vcs.c b/src/libide/vcs/ide-vcs.c
index 0ac81a560..d92b50995 100644
--- a/src/libide/vcs/ide-vcs.c
+++ b/src/libide/vcs/ide-vcs.c
@@ -137,6 +137,9 @@ ide_vcs_default_init (IdeVcsInterface *iface)
*
* For convenience, this function will return %TRUE if @file is %NULL.
*
+ * If @self is %NULL, only static checks against known ignored files
+ * will be performed (such as .git, .flatpak-builder, etc).
+ *
* Returns: %TRUE if the path should be ignored.
*
* Thread safety: This function is safe to call from a thread as
@@ -152,7 +155,7 @@ ide_vcs_is_ignored (IdeVcs *self,
{
gboolean ret = FALSE;
- g_return_val_if_fail (IDE_IS_VCS (self), FALSE);
+ g_return_val_if_fail (!self || IDE_IS_VCS (self), FALSE);
g_return_val_if_fail (!file || G_IS_FILE (file), FALSE);
if (file == NULL)
@@ -180,8 +183,11 @@ ide_vcs_is_ignored (IdeVcs *self,
G_UNLOCK (ignored);
- if (!ret && IDE_VCS_GET_IFACE (self)->is_ignored)
- ret = IDE_VCS_GET_IFACE (self)->is_ignored (self, file, error);
+ if (self != NULL)
+ {
+ if (!ret && IDE_VCS_GET_IFACE (self)->is_ignored)
+ ret = IDE_VCS_GET_IFACE (self)->is_ignored (self, file, error);
+ }
return ret;
}
@@ -200,6 +206,8 @@ ide_vcs_is_ignored (IdeVcs *self,
*
* For convenience, this function will return %TRUE if @path is %NULL.
*
+ * If @self is %NULL, only registered ignore patterns will be checked.
+ *
* Returns: %TRUE if the path should be ignored.
*
* Thread safety: This function is safe to call from a thread as
@@ -215,7 +223,7 @@ ide_vcs_path_is_ignored (IdeVcs *self,
{
gboolean ret = FALSE;
- g_return_val_if_fail (IDE_IS_VCS (self), FALSE);
+ g_return_val_if_fail (!self || IDE_IS_VCS (self), FALSE);
if (path == NULL)
return TRUE;
@@ -242,16 +250,19 @@ ide_vcs_path_is_ignored (IdeVcs *self,
G_UNLOCK (ignored);
- if (!ret && IDE_VCS_GET_IFACE (self)->is_ignored)
+ if (self != NULL)
{
- g_autoptr(GFile) file = NULL;
+ if (!ret && IDE_VCS_GET_IFACE (self)->is_ignored)
+ {
+ g_autoptr(GFile) file = NULL;
- if (g_path_is_absolute (path))
- file = g_file_new_for_path (path);
- else
- file = g_file_get_child (ide_vcs_get_working_directory (self), path);
+ if (g_path_is_absolute (path))
+ file = g_file_new_for_path (path);
+ else
+ file = g_file_get_child (ide_vcs_get_working_directory (self), path);
- ret = IDE_VCS_GET_IFACE (self)->is_ignored (self, file, error);
+ ret = IDE_VCS_GET_IFACE (self)->is_ignored (self, file, error);
+ }
}
return ret;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]