File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -2032,8 +2032,13 @@ static int repo_init_structure(
20322032 git_str_dispose (& template_buf );
20332033 git_config_free (cfg );
20342034
2035+ /* If tdir does not exist, then do not error out. This matches the
2036+ * behaviour of git(1), which just prints a warning and continues.
2037+ * TODO: issue warning when warning API is available.
2038+ * `git` prints to stderr: 'warning: templates not found in /path/to/tdir'
2039+ */
20352040 if (error < 0 ) {
2036- if (!default_template )
2041+ if (!default_template && error != GIT_ENOTFOUND )
20372042 return error ;
20382043
20392044 /* if template was default, ignore error and use internal */
Original file line number Diff line number Diff line change @@ -293,3 +293,13 @@ void test_repo_template__empty_template_path(void)
293293
294294 setup_repo ("foo" , & opts );
295295}
296+
297+ void test_repo_template__nonexistent_template_path (void )
298+ {
299+ git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT ;
300+
301+ opts .flags = GIT_REPOSITORY_INIT_MKPATH | GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE ;
302+ opts .template_path = "/tmp/path/that/does/not/exist/for/libgit2/test" ;
303+
304+ setup_repo ("bar" , & opts );
305+ }
You can’t perform that action at this time.
0 commit comments