summaryrefslogtreecommitdiff
path: root/builtin/init-db.c
diff options
context:
space:
mode:
authorLibravatar Nguyễn Thái Ngọc Duy <pclouds@gmail.com>2019-05-10 17:46:57 +0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-05-13 15:13:24 +0900
commite1df7fe43f4e2e607ed24668e2942d45df8d2743 (patch)
tree0f29c758dea88ebb71a2d08c1c215d0a715de296 /builtin/init-db.c
parentmingw: allow building with an MSYS2 runtime v3.x (diff)
downloadtgif-e1df7fe43f4e2e607ed24668e2942d45df8d2743.tar.xz
init: make --template path relative to $CWD
During git-init we chdir() to the target directory, but --template is not adjusted. So it's relative to the target directory instead of current directory. It would be ok if it's documented, but --template in git-init.txt mentions nothing about this behavior. Change it to be relative to $CWD, which is much more intuitive. The changes in the test suite show that this relative-to-target behavior is actually used. I just hope that it's only used in the test suite and it's safe to change. Otherwise, the other option is just document it (i.e. relative to target dir) and move on. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/init-db.c')
-rw-r--r--builtin/init-db.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/builtin/init-db.c b/builtin/init-db.c
index 93eff7618c..6b72a9bb09 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -494,6 +494,9 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
if (real_git_dir && !is_absolute_path(real_git_dir))
real_git_dir = real_pathdup(real_git_dir, 1);
+ if (template_dir && *template_dir && !is_absolute_path(template_dir))
+ template_dir = absolute_pathdup(template_dir);
+
if (argc == 1) {
int mkdir_tried = 0;
retry: