[gitg] Set working directory, GIT_DIR and GIT_INDEX_FILE when running hooks



commit 1f8ca045177b2b944782a824042b11d63bbc57fc
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date:   Fri Aug 19 23:15:52 2011 +0200

    Set working directory, GIT_DIR and GIT_INDEX_FILE when running hooks

 libgitg/gitg-repository.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/libgitg/gitg-repository.c b/libgitg/gitg-repository.c
index 0bf8fa6..f1d1b18 100644
--- a/libgitg/gitg-repository.c
+++ b/libgitg/gitg-repository.c
@@ -1957,6 +1957,7 @@ gitg_repository_run_hook (GitgRepository       *repository,
 	gboolean retval;
 	GitgShell *shell;
 	GPtrArray *ptrar;
+	GFile *index_file;
 
 	g_return_val_if_fail (GITG_IS_REPOSITORY (repository), FALSE);
 
@@ -2012,6 +2013,19 @@ gitg_repository_run_hook (GitgRepository       *repository,
 	command = gitg_command_newv (NULL,
 	                             (gchar const * const *)argsv);
 
+	gitg_command_set_working_directory (command, repository->priv->work_tree);
+
+	path = g_file_get_path (repository->priv->git_dir);
+	gitg_command_add_environment (command, "GIT_DIR", path, NULL);
+	g_free (path);
+
+	index_file = g_file_get_child (repository->priv->git_dir, "index");
+	path = g_file_get_path (index_file);
+	g_object_unref (index_file);
+
+	gitg_command_add_environment (command, "GIT_INDEX_FILE", path, NULL);
+	g_free (path);
+
 	g_strfreev (argsv);
 
 	shell = gitg_shell_new_synchronized (1000);



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