summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorSteffen Prohaska <prohaska@zib.de>2008-07-13 22:31:18 +0200
committerJunio C Hamano <gitster@pobox.com>2008-07-13 14:41:28 -0700
commit2de9de5e4ae1353f1552f61cf8cf532e3f1dc5f6 (patch)
treeaa862fe50c73cb0f8cff6b717423388ca3cffc5c /config.c
parenta9a3e82e6d0018ff42ec11fd9560c1ff47add824 (diff)
downloadgit-2de9de5e4ae1353f1552f61cf8cf532e3f1dc5f6.tar.gz
Move code interpreting path relative to exec-dir to new function system_path()
Expanding system paths relative to git_exec_path can be used for creating an installation that can be moved to a different directory without re-compiling. We use this approach for template_dir and the system wide gitconfig. The Windows installer (msysgit) is an example for such a setup. This commit moves common code to a new function system_path(). System paths that are to be interpreted relative to git_exec_path are passed to system_path() and the return value is used instead of the original path. system_path() prefixes a relative path with git_exec_path and leaves absolute paths unmodified. For example, we now write template_dir = system_path(DEFAULT_GIT_TEMPLATE_DIR); [j6t: moved from path.c to exec_cmd.c] Signed-off-by: Steffen Prohaska <prohaska@zib.de> Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/config.c b/config.c
index 2862cc45cb..1e066c71e0 100644
--- a/config.c
+++ b/config.c
@@ -581,15 +581,8 @@ int git_config_from_file(config_fn_t fn, const char *filename, void *data)
const char *git_etc_gitconfig(void)
{
static const char *system_wide;
- if (!system_wide) {
- system_wide = ETC_GITCONFIG;
- if (!is_absolute_path(system_wide)) {
- /* interpret path relative to exec-dir */
- struct strbuf d = STRBUF_INIT;
- strbuf_addf(&d, "%s/%s", git_exec_path(), system_wide);
- system_wide = strbuf_detach(&d, NULL);
- }
- }
+ if (!system_wide)
+ system_wide = system_path(ETC_GITCONFIG);
return system_wide;
}