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 <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Sixt committed
Nov 13, 2007 at 21:05 UTC
7f0e39faa2929541f61039be96d3f40f74207585
1 file changed
+12
-1
config.c
+12
-1
@@ -6,6 +6,7 @@
6
*
7
*/
8
#include "cache.h"
9
+#include "exec_cmd.h"
10
11
#define MAXNAME (256)
12
@@ -461,7 +462,17 @@ int git_config_from_file(config_fn_t fn, const char *filename)
462
463
const char *git_etc_gitconfig(void)
464
{
464
- return ETC_GITCONFIG;
465
+ static const char *system_wide;
466
+ if (!system_wide) {
467
+ system_wide = ETC_GITCONFIG;
468
+ if (!is_absolute_path(system_wide)) {
469
+ /* interpret path relative to exec-dir */
470
+ const char *exec_path = git_exec_path();
471
+ system_wide = prefix_path(exec_path, strlen(exec_path),
472
+ system_wide);
473
+ }
474
+ }
475
+ return system_wide;
476
}
477
478
int git_config(config_fn_t fn)