diff options
author | Junio C Hamano <gitster@pobox.com> | 2007-11-24 16:31:25 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-11-24 16:31:25 -0800 |
commit | ab002e34e26c39a716dc80359450f739ba907122 (patch) | |
tree | 8728bf9611ec83ea36325960c43c707aa43820b3 /builtin-init-db.c | |
parent | Merge branch 'mh/rebase-skip-hard' (diff) | |
parent | fetch-pack: Prepare for a side-band demultiplexer in a thread. (diff) | |
download | tgif-ab002e34e26c39a716dc80359450f739ba907122.tar.xz |
Merge branch 'js/mingw-fallouts'
* js/mingw-fallouts:
fetch-pack: Prepare for a side-band demultiplexer in a thread.
rehabilitate some t5302 tests on 32-bit off_t machines
Allow ETC_GITCONFIG to be a relative path.
Introduce git_etc_gitconfig() that encapsulates access of ETC_GITCONFIG.
Allow a relative builtin template directory.
Close files opened by lock_file() before unlinking.
builtin run_command: do not exit with -1.
Move #include <sys/select.h> and <sys/ioctl.h> to git-compat-util.h.
Use is_absolute_path() in sha1_file.c.
Skip t3902-quoted.sh if the file system does not support funny names.
t5302-pack-index: Skip tests of 64-bit offsets if necessary.
t7501-commit.sh: Not all seds understand option -i
t5300-pack-object.sh: Split the big verify-pack test into smaller parts.
Diffstat (limited to 'builtin-init-db.c')
-rw-r--r-- | builtin-init-db.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/builtin-init-db.c b/builtin-init-db.c index 763fa55e76..e1393b8d1e 100644 --- a/builtin-init-db.c +++ b/builtin-init-db.c @@ -5,6 +5,7 @@ */ #include "cache.h" #include "builtin.h" +#include "exec_cmd.h" #ifndef DEFAULT_GIT_TEMPLATE_DIR #define DEFAULT_GIT_TEMPLATE_DIR "/usr/share/git-core/templates" @@ -131,10 +132,19 @@ static void copy_templates(const char *git_dir, int len, const char *template_di int template_len; DIR *dir; - if (!template_dir) { + if (!template_dir) template_dir = getenv(TEMPLATE_DIR_ENVIRONMENT); - if (!template_dir) - template_dir = DEFAULT_GIT_TEMPLATE_DIR; + if (!template_dir) { + /* + * if the hard-coded template is relative, it is + * interpreted relative to the exec_dir + */ + template_dir = DEFAULT_GIT_TEMPLATE_DIR; + if (!is_absolute_path(template_dir)) { + const char *exec_path = git_exec_path(); + template_dir = prefix_path(exec_path, strlen(exec_path), + template_dir); + } } strcpy(template_path, template_dir); template_len = strlen(template_path); |