[gitg] Added debugging of runner commands



commit 8f84b02d7faceaa0063f534a6cc527171894e408
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date:   Fri Aug 19 21:03:39 2011 +0200

    Added debugging of runner commands

 libgitg/gitg-runner.c |   56 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)
---
diff --git a/libgitg/gitg-runner.c b/libgitg/gitg-runner.c
index 78f0bc8..1b24996 100644
--- a/libgitg/gitg-runner.c
+++ b/libgitg/gitg-runner.c
@@ -413,6 +413,57 @@ process_watch_cb (GPid        pid,
 	}
 }
 
+static void
+debug_runner_command (GitgRunner *runner)
+{
+	gchar *argstr;
+	gchar const * const *envs;
+	GFile *wd;
+
+	argstr = g_strjoinv (" ", (gchar **)gitg_command_get_arguments (runner->priv->command));
+
+	gitg_debug (GITG_DEBUG_SHELL,
+	            "Running command: %s", argstr);
+
+	g_free (argstr);
+
+	envs = gitg_command_get_environment (runner->priv->command);
+
+	if (envs)
+	{
+		gchar *environment;
+		environment = g_strjoinv (", ", (gchar **)envs);
+
+		gitg_debug (GITG_DEBUG_SHELL,
+		            "Environment: %s", environment);
+
+		g_free (environment);
+	}
+	else
+	{
+		gitg_debug (GITG_DEBUG_SHELL,
+		            "Environment: None");
+	}
+
+	wd = gitg_command_get_working_directory (runner->priv->command);
+
+	if (wd)
+	{
+		gchar *path;
+
+		path = g_file_get_path (wd);
+
+		gitg_debug (GITG_DEBUG_SHELL, "CWD: %s", path);
+
+		g_free (path);
+		g_object_unref (wd);
+	}
+	else
+	{
+		gitg_debug (GITG_DEBUG_SHELL, "CWD: None\n");
+	}
+}
+
 void
 gitg_runner_run (GitgRunner *runner)
 {
@@ -443,6 +494,11 @@ gitg_runner_run (GitgRunner *runner)
 
 	start_input = gitg_io_get_input (GITG_IO (runner));
 
+	if (gitg_debug_enabled (GITG_DEBUG_SHELL))
+	{
+		debug_runner_command (runner);
+	}
+
 	ret = g_spawn_async_with_pipes (wd_path,
 	                                (gchar **)gitg_command_get_arguments (runner->priv->command),
 	                                (gchar **)gitg_command_get_environment (runner->priv->command),



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