summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Nader <jason.nader@protonmail.com>2021-11-05 02:28:37 +0900
committerJason Nader <jason.nader@protonmail.com>2021-11-12 14:59:37 +0900
commit709b1b62686d3526eb27169a4d80c0ed4e8f7e55 (patch)
tree65c0b6ff6afa03b0b7bdc993c33eeec714f5aa8e
parent358a60e1b46000ea99ef10b4dd709e92f75ff74b (diff)
downloadlibgit2-709b1b62686d3526eb27169a4d80c0ed4e8f7e55.tar.gz
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.
-rw-r--r--src/repository.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/repository.c b/src/repository.c
index 29684e463..2002e1186 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -2032,9 +2032,15 @@ static int repo_init_structure(
git_str_dispose(&template_buf);
git_config_free(cfg);
+ /* If tdir does not exist, then do not error out. This matches the
+ * behaviour of git(1), which just prints a warning and continues.
+ * TODO: issue warning when warning API is available.
+ * `git` prints to stderr: 'warning: templates not found in /path/to/tdir'
+ */
if (error < 0) {
- if (!default_template)
+ if (!default_template && error != GIT_ENOTFOUND) {
return error;
+ }
/* if template was default, ignore error and use internal */
git_error_clear();