From ca5c53f923ad698d066e6901e822b03d15e28c90 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Thu, 28 Apr 2016 16:22:38 +0200
Subject: [PATCH] girepository: Merge overrides with the regular search path

This reverts commit e81c4681cc88a00fcd841c5a68d860d3714b55d7

The GI_TYPELIB_PATH envvar will still allow overriding the default
typelib dir (based on gobject-introspection libdir), but applications
will have the last say about typelib lookup directories. The resulting
lookup order is now:

- Paths added through g_irepository_prepend_search_path()
- Paths in GI_TYPELIB_PATH
- The default gobject introspection lookup dir

This makes g_irespository_prepend_search_path() work as announced
despite environment variables. If any application was relying on
GI_TYPELIB_PATH overriding the paths of this function call (for e.g.
make check, or to be able to run code inside the project tree), it
is encouraged to set up a similar envvar for their application specific
lookup dir, or perform this override through other means.

https://bugzilla.gnome.org/show_bug.cgi?id=765735
---
 girepository/girepository.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/girepository/girepository.c b/girepository/girepository.c
index 4537c03..5eacbeb 100644
--- a/girepository/girepository.c
+++ b/girepository/girepository.c
@@ -46,7 +46,6 @@
 
 static GIRepository *default_repository = NULL;
 static GSList *search_path = NULL;
-static GSList *override_search_path = NULL;
 
 struct _GIRepositoryPrivate
 {
@@ -163,7 +162,6 @@ init_globals (void)
       type_lib_path_env = g_getenv ("GI_TYPELIB_PATH");
 
       search_path = NULL;
-      override_search_path = NULL;
       if (type_lib_path_env)
         {
           gchar **custom_dirs;
@@ -174,7 +172,7 @@ init_globals (void)
           d = custom_dirs;
           while (*d)
             {
-              override_search_path = g_slist_prepend (override_search_path, *d);
+              search_path = g_slist_prepend (search_path, *d);
               d++;
             }
 
@@ -182,9 +180,6 @@ init_globals (void)
           g_free (custom_dirs);
         }
 
-      if (override_search_path != NULL)
-        override_search_path = g_slist_reverse (override_search_path);
-
       libdir = GOBJECT_INTROSPECTION_LIBDIR;
 
       typelib_dir = g_build_filename (libdir, "girepository-1.0", NULL);
@@ -234,14 +229,7 @@ build_search_path_with_overrides (void)
 
   init_globals ();
 
-  if (override_search_path != NULL)
-    {
-      result = g_slist_copy (override_search_path);
-      g_slist_last (result)->next = g_slist_copy (search_path);
-    }
-  else
-    result = g_slist_copy (search_path);
-  return result;
+  return g_slist_copy (search_path);
 }
 
 static char *
-- 
2.7.3