For bare repository, use repo_dir to test if symlinks are supported
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
diff --git a/src/repository.c b/src/repository.c
index 6a80070..cf9c7d1 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -1606,6 +1606,7 @@ int git_repository_init_ext(
{
int error;
git_buf repo_path = GIT_BUF_INIT, wd_path = GIT_BUF_INIT;
+ const char *wd;
assert(out && given_repo && opts);
@@ -1615,6 +1616,7 @@ int git_repository_init_ext(
if (error < 0)
goto cleanup;
+ wd = (opts->flags & GIT_REPOSITORY_INIT_BARE) ? NULL : git_buf_cstr(&wd_path);
if (valid_repository_path(&repo_path)) {
if ((opts->flags & GIT_REPOSITORY_INIT_NO_REINIT) != 0) {
@@ -1627,15 +1629,15 @@ int git_repository_init_ext(
opts->flags |= GIT_REPOSITORY_INIT__IS_REINIT;
error = repo_init_config(
- repo_path.ptr, wd_path.ptr, opts->flags, opts->mode);
+ repo_path.ptr, wd, opts->flags, opts->mode);
/* TODO: reinitialize the templates */
}
else {
if (!(error = repo_init_structure(
- repo_path.ptr, wd_path.ptr, opts)) &&
+ repo_path.ptr, wd, opts)) &&
!(error = repo_init_config(
- repo_path.ptr, wd_path.ptr, opts->flags, opts->mode)))
+ repo_path.ptr, wd, opts->flags, opts->mode)))
error = repo_init_create_head(
repo_path.ptr, opts->initial_head);
}