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>
This commit is contained in:

committed by
Junio C Hamano

parent
a9a3e82e6d
commit
2de9de5e4a
10
exec_cmd.c
10
exec_cmd.c
@ -40,6 +40,16 @@ static const char *builtin_exec_path(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *system_path(const char *path)
|
||||
{
|
||||
if (!is_absolute_path(path)) {
|
||||
struct strbuf d = STRBUF_INIT;
|
||||
strbuf_addf(&d, "%s/%s", git_exec_path(), path);
|
||||
path = strbuf_detach(&d, NULL);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
void git_set_argv_exec_path(const char *exec_path)
|
||||
{
|
||||
argv_exec_path = exec_path;
|
||||
|
Reference in New Issue
Block a user