From 44bacc53bf8d5e0e7f526f6599ec0b9a9836ebc2 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Sun, 10 Jun 2007 20:14:53 +0200 Subject: [PATCH] Allow ETC_GITCONFIG to be a relative path. If ETC_GITCONFIG is not an absolute path, interpret it relative to --exec-dir. This makes the installed binaries relocatable because the prefix is not compiled-in. Signed-off-by: Johannes Sixt --- config.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index 79c32a0338..1c87e8e3f9 100644 --- a/config.c +++ b/config.c @@ -395,7 +395,17 @@ int git_config_from_file(config_fn_t fn, const char *filename) const char *git_etc_gitconfig(void) { - return ETC_GITCONFIG; + static const char *system_wide; + if (!system_wide) { + system_wide = ETC_GITCONFIG; + /* interpret path relative to exec-dir */ + if (system_wide[0] != '/' && system_wide[1] != ':') { + const char *exec_path = git_exec_path(); + system_wide = prefix_path(exec_path, strlen(exec_path), + system_wide); + } + } + return system_wide; } int git_config(config_fn_t fn)