[gnome-builder] flatpak: avoid duplicate --env entries



commit 6ca8c472e4b56ce4fa60491076f1acc7d83f1469
Author: Christian Hergert <chergert redhat com>
Date:   Fri Apr 26 13:40:11 2019 -0700

    flatpak: avoid duplicate --env entries

 src/plugins/flatpak/gbp-flatpak-runner.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/src/plugins/flatpak/gbp-flatpak-runner.c b/src/plugins/flatpak/gbp-flatpak-runner.c
index 5336d996e..b44b93a62 100644
--- a/src/plugins/flatpak/gbp-flatpak-runner.c
+++ b/src/plugins/flatpak/gbp-flatpak-runner.c
@@ -50,6 +50,21 @@ gbp_flatpak_runner_create_launcher (IdeRunner *runner)
                        NULL);
 }
 
+static gboolean
+contains_argv (IdeSubprocessLauncher *launcher,
+               const gchar           *arg)
+{
+  const gchar * const *args;
+
+  if (arg == NULL)
+    return TRUE;
+
+  if (!(args = ide_subprocess_launcher_get_argv (launcher)))
+    return FALSE;
+
+  return g_strv_contains (args, arg);
+}
+
 static void
 gbp_flatpak_runner_fixup_launcher (IdeRunner             *runner,
                                    IdeSubprocessLauncher *launcher)
@@ -131,7 +146,9 @@ gbp_flatpak_runner_fixup_launcher (IdeRunner             *runner,
       for (guint j = 0; environ_[j]; j++)
         {
           g_autofree gchar *arg = g_strdup_printf ("--env=%s", environ_[j]);
-          ide_subprocess_launcher_insert_argv (launcher, i++, arg);
+
+          if (!contains_argv (launcher, arg))
+            ide_subprocess_launcher_insert_argv (launcher, i++, arg);
         }
     }
 


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