Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- builtin/init-db.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/builtin/init-db.c b/builtin/init-db.c index 8069cd2..37e318b 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -22,7 +22,6 @@ static int init_is_bare_repository = 0; static int init_shared_repository = -1; static const char *init_db_template_dir; -static const char *git_link; static void copy_templates_1(struct strbuf *path, struct strbuf *template, DIR *dir) @@ -312,7 +311,7 @@ static void create_object_directory(void) strbuf_release(&path); } -static void separate_git_dir(const char *git_dir) +static void separate_git_dir(const char *git_dir, const char *git_link) { struct stat st; @@ -349,22 +348,15 @@ int init_db(const char *git_dir, const char *real_git_dir, if (!exist_ok && !stat(real_git_dir, &st)) die(_("%s already exists"), real_git_dir); - /* - * make sure symlinks are resolved because we'll be - * moving the target repo later on in separate_git_dir() - */ - git_link = xstrdup(real_path(git_dir)); set_git_dir(real_path(real_git_dir)); + git_dir = get_git_dir(); + separate_git_dir(git_dir, original_git_dir); } else { set_git_dir(real_path(git_dir)); - git_link = NULL; + git_dir = get_git_dir(); } startup_info->have_repository = 1; - git_dir = get_git_dir(); - - if (git_link) - separate_git_dir(git_dir); safe_create_dir(git_dir, 0); -- 2.8.2.524.g6ff3d78