]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t0001-init.sh
init: fix bug regarding ~/ expansion in init.templateDir
[thirdparty/git.git] / t / t0001-init.sh
index 0803994874f91659551ac5e9f1a8c0b484430cfe..acd662e403b9d3a89e58a0dc4d682b2b9e21b533 100755 (executable)
@@ -186,21 +186,33 @@ test_expect_success 'init with --template (blank)' '
        test_path_is_missing template-blank/.git/info/exclude
 '
 
-test_expect_success 'init with init.templatedir set' '
-       mkdir templatedir-source &&
-       echo Content >templatedir-source/file &&
-       test_config_global init.templatedir "${HOME}/templatedir-source" &&
+init_no_templatedir_env () {
        (
-               mkdir templatedir-set &&
-               cd templatedir-set &&
                sane_unset GIT_TEMPLATE_DIR &&
                NO_SET_GIT_TEMPLATE_DIR=t &&
                export NO_SET_GIT_TEMPLATE_DIR &&
-               git init
-       ) &&
+               git init "$1"
+       )
+}
+
+test_expect_success 'init with init.templatedir set' '
+       mkdir templatedir-source &&
+       echo Content >templatedir-source/file &&
+       test_config_global init.templatedir "${HOME}/templatedir-source" &&
+
+       init_no_templatedir_env templatedir-set &&
        test_cmp templatedir-source/file templatedir-set/.git/file
 '
 
+test_expect_success 'init with init.templatedir using ~ expansion' '
+       mkdir -p templatedir-source &&
+       echo Content >templatedir-source/file &&
+       test_config_global init.templatedir "~/templatedir-source" &&
+
+       init_no_templatedir_env templatedir-expansion &&
+       test_cmp templatedir-source/file templatedir-expansion/.git/file
+'
+
 test_expect_success 'init --bare/--shared overrides system/global config' '
        test_config_global core.bare false &&
        test_config_global core.sharedRepository 0640 &&