From: Junio C Hamano Date: Thu, 25 Jul 2019 21:27:06 +0000 (-0700) Subject: Merge branch 'nd/init-relative-template-fix' into maint X-Git-Tag: v2.23.0-rc0~6^2~25 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/35d771591f673e1c2c7bc90b998670bed1e9e567?hp=-c Merge branch 'nd/init-relative-template-fix' into maint A relative pathname given to "git init --template= " ought to be relative to the directory "git init" gets invoked in, but it instead was made relative to the repository, which has been corrected. * nd/init-relative-template-fix: init: make --template path relative to $CWD --- 35d771591f673e1c2c7bc90b998670bed1e9e567 diff --combined builtin/init-db.c index 6ca002893f,6b72a9bb09..944ec77fe1 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@@ -96,7 -96,7 +96,7 @@@ static void copy_templates(const char * struct strbuf path = STRBUF_INIT; struct strbuf template_path = STRBUF_INIT; size_t template_len; - struct repository_format template_format; + struct repository_format template_format = REPOSITORY_FORMAT_INIT; struct strbuf err = STRBUF_INIT; DIR *dir; char *to_free = NULL; @@@ -148,7 -148,6 +148,7 @@@ free_return free(to_free); strbuf_release(&path); strbuf_release(&template_path); + clear_repository_format(&template_format); } static int git_init_db_config(const char *k, const char *v, void *cb) @@@ -156,9 -155,6 +156,9 @@@ if (!strcmp(k, "init.templatedir")) return git_config_pathname(&init_db_template_dir, k, v); + if (starts_with(k, "core.")) + return platform_core_config(k, v, cb); + return 0; } @@@ -189,7 -185,6 +189,7 @@@ static int create_default_files(const c struct strbuf err = STRBUF_INIT; /* Just look for `init.templatedir` */ + init_db_template_dir = NULL; /* re-set in case it was set before */ git_config(git_init_db_config, NULL); /* @@@ -366,9 -361,6 +366,9 @@@ int init_db(const char *git_dir, const } startup_info->have_repository = 1; + /* Just look for `core.hidedotfiles` */ + git_config(git_init_db_config, NULL); + safe_create_dir(git_dir, 0); init_is_bare_repository = is_bare_repository(); @@@ -502,6 -494,9 +502,9 @@@ int cmd_init_db(int argc, const char ** 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: diff --combined t/t0001-init.sh index 77a224aafb,802edb6c8f..0276d14a0b --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@@ -93,7 -93,6 +93,7 @@@ test_expect_success 'No extra GIT_* on sed -n \ -e "/^GIT_PREFIX=/d" \ -e "/^GIT_TEXTDOMAINDIR=/d" \ + -e "/^GIT_TRACE2_PARENT/d" \ -e "/^GIT_/s/=.*//p" | sort EOF @@@ -175,7 -174,7 +175,7 @@@ test_expect_success 'reinit' test_expect_success 'init with --template' ' mkdir template-source && echo content >template-source/file && - git init --template=../template-source template-custom && + git init --template=template-source template-custom && test_cmp template-source/file template-custom/.git/file ' @@@ -454,17 -453,6 +454,17 @@@ test_expect_success 're-init from a lin ) ' +test_expect_success MINGW 'core.hidedotfiles = false' ' + git config --global core.hidedotfiles false && + rm -rf newdir && + mkdir newdir && + ( + sane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG && + git -C newdir init + ) && + ! is_hidden newdir/.git +' + test_expect_success MINGW 'redirect std handles' ' GIT_REDIRECT_STDOUT=output.txt git rev-parse --git-dir && test .git = "$(cat output.txt)" &&