diff options
context:
space:
mode:
-rw-r--r--source/cgit.c8
1 file changed, 7 insertions, 1 deletion
diff --git a/source/cgit.c b/source/cgit.c
index 156d2a7..909e120 100644
--- a/source/cgit.c
+++ b/source/cgit.c
@@ -24,8 +24,14 @@ const char *cgit_version = CGIT_VERSION;
__attribute__((constructor))
static void constructor_environment()
{
- /* Do not look in /etc/ for gitconfig and gitattributes. */
+ /*
+ * Isolate git from the calling user's configuration. Ignore the
+ * system and global config and attributes, so a snapshot cannot be
+ * broken by something like a core.excludesfile pointing at a "~" path
+ * that git can no longer expand once HOME is unset below.
+ */
setenv("GIT_CONFIG_NOSYSTEM", "1", 1);
+ setenv("GIT_CONFIG_GLOBAL", "/dev/null", 1);
setenv("GIT_ATTR_NOSYSTEM", "1", 1);
unsetenv("HOME");
unsetenv("XDG_CONFIG_HOME");