Skip to content

Commit 709b1b6

Browse files
committed
repository: do not copy templates if dir nonexistent
This mimics the behaviour of git which just prints a warning and continues with the repo initialisation.
1 parent 358a60e commit 709b1b6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/repository.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2032,9 +2032,15 @@ 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;
2043+
}
20382044

20392045
/* if template was default, ignore error and use internal */
20402046
git_error_clear();

0 commit comments

Comments
 (0)