git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] autodetect core.symlinks in git-init

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 31, 2007, 07:22 UTC
Message-ID
<7vodgo2moe.fsf_-_@gitster.siamese.dyndns.org>
In-Reply-To
<7vveaw2na9.fsf@gitster.siamese.dyndns.org>

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>
---
 * The earlier one left the test symlink behind after testing is
   complete.  Embarrassing...
 builtin-init-db.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/builtin-init-db.c b/builtin-init-db.c
index af15cb2..763fa55 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -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;
 }
 
Previous: Junio C HamanoNext: Nanako Shiraishi
Message 8 of 12 in “[RFC] Change handling of RelNotes”
  1. Stephen CuppettAug 31, 2007
  2. Petr BaudisAug 31, 2007
  3. Junio C HamanoAug 31, 2007
  4. Junio C HamanoAug 31, 2007
  5. Marius Storm-OlsenAug 31, 2007
  6. Nanako ShiraishiAug 31, 2007
  7. Junio C HamanoAug 31, 2007
  8. autodetect core.symlinks in git-initJunio C Hamano, Aug 31, 2007
  9. Nanako ShiraishiAug 31, 2007
  10. Marius Storm-OlsenAug 31, 2007
  11. Stephen CuppettAug 31, 2007
  12. Junio C HamanoAug 31, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.