Skip to content

Commit

Permalink
git-init: autodetect core.symlinks
Browse files Browse the repository at this point in the history
We already autodetect if filemode is reliable on the filesystem
to deal with VFAT and friends.  Do the same for symbolic link
support.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Aug 31, 2007
1 parent 608403d commit 75d2449
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions builtin-init-db.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,21 @@ static int create_default_files(const char *git_dir, const char *template_path)
if (work_tree != git_work_tree_cfg)
git_config_set("core.worktree", work_tree);
}

/* Check if symlink is supported in the work tree */
if (!reinit) {
path[len] = 0;
strcpy(path + len, "tXXXXXX");
if (!close(xmkstemp(path)) &&
!unlink(path) &&
!symlink("testing", path) &&
!lstat(path, &st1) &&
S_ISLNK(st1.st_mode))
unlink(path); /* good */
else
git_config_set("core.symlinks", "false");
}

return reinit;
}

Expand Down

0 comments on commit 75d2449

Please sign in to comment.