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(
2032
2032
git_str_dispose (& template_buf );
2033
2033
git_config_free (cfg );
2034
2034
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
+ */
2035
2040
if (error < 0 ) {
2036
- if (!default_template )
2041
+ if (!default_template && error != GIT_ENOTFOUND )
2037
2042
return error ;
2038
2043
2039
2044
/* 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)
293
293
294
294
setup_repo ("foo" , & opts );
295
295
6D35
}
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