@matheusbsbs / matheus-bagliano / commits / 75d2449903
Fork 0

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>

Junio C Hamano committed Aug 31, 2007 at 00:25 UTC 75d244990364e322e87e2549846b17252f440627
1 file changed +15
builtin-init-db.c
+15
@@ -264,6 +264,21 @@ static int create_default_files(const char *git_dir, const char *template_path)
264 if (work_tree != git_work_tree_cfg)
265 git_config_set("core.worktree", work_tree);
266 }
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 +
282 return reinit;
283 }
284