git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] allow GIT_CONFIG_ETC to override compile-time setting

From
Jeff King <peff@peff.net>
Date
Feb 6, 2008, 09:07 UTC
Message-ID
<20080206090736.GA3258@coredump.intra.peff.net>
In-Reply-To
<20080206090453.GA6762@coredump.intra.peff.net>

This is not expected to be used by mere mortals, since the GIT_CONFIG_LOCAL variable already accomplishes more or less the same thing. However, to keep the testing environment clean, it is necessary to be able to suppress the use of this file (which may have settings that interfere with the tests).

Signed-off-by: Jeff King <peff@peff.net>
---
Junio, more rationale for the series is available in the first message
of the thread.
 cache.h  |    1 +
 config.c |    4 +++-
 2 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/cache.h b/cache.h
index 549f4bb..d8322a1 100644
--- a/cache.h
+++ b/cache.h
@@ -208,6 +208,7 @@ static inline enum object_type object_type(unsigned int mode)
 #define TEMPLATE_DIR_ENVIRONMENT "GIT_TEMPLATE_DIR"
 #define CONFIG_ENVIRONMENT "GIT_CONFIG"
 #define CONFIG_LOCAL_ENVIRONMENT "GIT_CONFIG_LOCAL"
+#define CONFIG_ETC_ENVIRONMENT "GIT_CONFIG_ETC"
 #define EXEC_PATH_ENVIRONMENT "GIT_EXEC_PATH"
 #define GITATTRIBUTES_FILE ".gitattributes"
 #define INFOATTRIBUTES_FILE "info/attributes"
diff --git a/config.c b/config.c
index 498259e..2a0d005 100644
--- a/config.c
+++ b/config.c
@@ -481,7 +481,9 @@ const char *git_etc_gitconfig(void)
 {
 	static const char *system_wide;
 	if (!system_wide) {
-		system_wide = ETC_GITCONFIG;
+		system_wide = getenv(CONFIG_ETC_ENVIRONMENT);
+	        if (!system_wide)
+			system_wide = ETC_GITCONFIG;
 		if (!is_absolute_path(system_wide)) {
 			/* interpret path relative to exec-dir */
 			struct strbuf d = STRBUF_INIT;
-- 
1.5.4.26.g9be9
Previous: Jeff KingNext: Jeff King
Message 3 of 8 in “Re: [PATCH] Make tests independent of global config files”
  1. Jeff KingFeb 6, 2008
  2. Jeff KingFeb 6, 2008
  3. 1/2 allow GIT_CONFIG_ETC to override compile-time settingJeff King, Feb 6, 2008
  4. 2/2 fix config reading in testsJeff King, Feb 6, 2008
  5. Junio C HamanoFeb 6, 2008
  6. Jeff KingFeb 6, 2008
  7. 1/2 allow suppressing of global and system configJeff King, Feb 6, 2008
  8. 2/2 fix config reading in testsJeff King, Feb 6, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.