@@ -12,6 +12,7 @@ enum repo_mode {
12
12
13
13
static git_repository * _repo = NULL ;
14
14
static git_buf _global_path = GIT_BUF_INIT ;
15
+ static git_buf _tmp_path = GIT_BUF_INIT ;
15
16
static mode_t g_umask = 0 ;
16
17
17
18
void test_repo_init__initialize (void )
@@ -33,6 +34,10 @@ void test_repo_init__cleanup(void)
33
34
git_libgit2_opts (GIT_OPT_SET_SEARCH_PATH , GIT_CONFIG_LEVEL_GLOBAL ,
34
35
_global_path .ptr );
35
36
git_buf_free (& _global_path );
37
+
38
+ if (_tmp_path .size > 0 && git_path_isdir (_tmp_path .ptr ))
39
+ git_futils_rmdir_r (_tmp_path .ptr , NULL , GIT_RMDIR_REMOVE_FILES );
40
+ git_buf_free (& _tmp_path );
36
41
}
37
42
38
43
static void cleanup_repository (void * path )
@@ -544,14 +549,14 @@ static void configure_templatedir(const char *template_path)
544
549
git_buf config_data = GIT_BUF_INIT ;
545
550
546
551
cl_git_pass (git_libgit2_opts (GIT_OPT_GET_SEARCH_PATH ,
547
- GIT_CONFIG_LEVEL_GLOBAL , & config_path ));
548
- cl_git_pass (git_buf_puts (& config_path , ".tmp" ));
552
+ GIT_CONFIG_LEVEL_GLOBAL , & _tmp_path ));
553
+ cl_git_pass (git_buf_puts (& _tmp_path , ".tmp" ));
549
554
cl_git_pass (git_libgit2_opts (GIT_OPT_SET_SEARCH_PATH ,
550
- GIT_CONFIG_LEVEL_GLOBAL , config_path .ptr ));
555
+ GIT_CONFIG_LEVEL_GLOBAL , _tmp_path .ptr ));
551
556
552
- cl_must_pass (p_mkdir (config_path .ptr , 0777 ));
557
+ cl_must_pass (p_mkdir (_tmp_path .ptr , 0777 ));
553
558
554
- cl_git_pass (git_buf_joinpath (& config_path , config_path .ptr , ".gitconfig" ));
559
+ cl_git_pass (git_buf_joinpath (& config_path , _tmp_path .ptr , ".gitconfig" ));
555
560
556
561
cl_git_pass (git_buf_printf (& config_data ,
557
562
"[init]\n\ttemplatedir = \"%s\"\n" , template_path ));
@@ -636,16 +641,39 @@ void test_repo_init__external_templates_specified_in_config(void)
636
641
637
642
cl_git_pass (git_repository_init_ext (& _repo , "templated.git" , & opts ));
638
643
639
- cl_assert (git_repository_is_bare (_repo ));
640
-
641
- cl_assert (!git__suffixcmp (git_repository_path (_repo ), "/templated.git/" ));
642
-
643
644
validate_templates (_repo , "template" );
644
645
cl_fixture_cleanup ("template" );
645
646
646
647
git_buf_free (& template_path );
647
648
}
648
649
650
+ void test_repo_init__external_templates_with_leading_dot (void )
651
+ {
652
+ git_buf template_path = GIT_BUF_INIT ;
653
+
654
+ git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT ;
655
+
656
+ cl_set_cleanup (& cleanup_repository , "templated.git" );
657
+ template_sandbox ("template" );
658
+
659
+ cl_must_pass (p_rename ("template" , ".template_with_leading_dot" ));
660
+
661
+ cl_git_pass (git_buf_joinpath (& template_path , clar_sandbox_path (),
662
+ ".template_with_leading_dot" ));
663
+
664
+ configure_templatedir (template_path .ptr );
665
+
666
+ opts .flags = GIT_REPOSITORY_INIT_MKPATH | GIT_REPOSITORY_INIT_BARE |
667
+ GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE ;
668
+
669
+ cl_git_pass (git_repository_init_ext (& _repo , "templated.git" , & opts ));
670
+
671
+ validate_templates (_repo , ".template_with_leading_dot" );
672
+ cl_fixture_cleanup (".template_with_leading_dot" );
673
+
674
+ git_buf_free (& template_path );
675
+ }
676
+
649
677
void test_repo_init__extended_with_template_and_shared_mode (void )
650
678
{
651
679
git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT ;
0 commit comments