Skip to content

Commit 75d2449

Browse files
committed
git-init: autodetect core.symlinks
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>
1 parent 608403d commit 75d2449

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

builtin-init-db.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,21 @@ static int create_default_files(const char *git_dir, const char *template_path)
264264
if (work_tree != git_work_tree_cfg)
265265
git_config_set("core.worktree", work_tree);
266266
}
267+
268+
/* Check if symlink is supported in the work tree */
269+
if (!reinit) {
270+
path[len] = 0;
271+
strcpy(path + len, "tXXXXXX");
272+
if (!close(xmkstemp(path)) &&
273+
!unlink(path) &&
274+
!symlink("testing", path) &&
275+
!lstat(path, &st1) &&
276+
S_ISLNK(st1.st_mode))
277+
unlink(path); /* good */
278+
else
279+
git_config_set("core.symlinks", "false");
280+
}
281+
267282
return reinit;
268283
}
269284

0 commit comments

Comments
 (0)