summaryrefslogtreecommitdiff
path: root/src/repository.c
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2013-09-17 10:21:22 -0700
committerVicent Martí <vicent@github.com>2013-09-17 10:21:22 -0700
commit3d4f169867faf79abcfdff6667b361d88bb2e3b3 (patch)
tree89e3162ae00a27e2a63f947b27fe0fa80a2fa247 /src/repository.c
parentbb371b62e950e3307d3acf2f772495a60565d266 (diff)
parenta025907e0d751ed1022e65365243ae97acf3f598 (diff)
downloadlibgit2-3d4f169867faf79abcfdff6667b361d88bb2e3b3.tar.gz
Merge pull request #1858 from linquize/win32-template-dir
Configurable template dir for Win32
Diffstat (limited to 'src/repository.c')
-rw-r--r--src/repository.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/repository.c b/src/repository.c
index 76e8228b7..d1b7d9131 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -33,8 +33,6 @@
#define GIT_REPO_VERSION 0
-#define GIT_TEMPLATE_DIR "/usr/share/git-core/templates"
-
static void set_odb(git_repository *repo, git_odb *odb)
{
if (odb) {
@@ -1136,6 +1134,9 @@ static int repo_init_structure(
if (external_tpl) {
git_config *cfg;
const char *tdir;
+ git_buf template_buf = GIT_BUF_INIT;
+
+ git_futils_find_template_dir(&template_buf);
if (opts->template_path)
tdir = opts->template_path;
@@ -1150,7 +1151,7 @@ static int repo_init_structure(
return error;
giterr_clear();
- tdir = GIT_TEMPLATE_DIR;
+ tdir = template_buf.ptr;
}
error = git_futils_cp_r(tdir, repo_dir,
@@ -1158,14 +1159,17 @@ static int repo_init_structure(
GIT_CPDIR_SIMPLE_TO_MODE, dmode);
if (error < 0) {
- if (strcmp(tdir, GIT_TEMPLATE_DIR) != 0)
+ if (strcmp(tdir, template_buf.ptr) != 0) {
+ git_buf_free(&template_buf);
return error;
+ }
/* if template was default, ignore error and use internal */
giterr_clear();
external_tpl = false;
error = 0;
}
+ git_buf_free(&template_buf);
}
/* Copy internal template