[PATCH] autodetect core.symlinks in git-init

Subsystems: the rest

DORMANTno replies

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

[PATCH] autodetect core.symlinks in git-init

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:31

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 <redacted>
---

 * 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;
 }
 

Re: [PATCH] autodetect core.symlinks in git-init

From: Nanako Shiraishi <hidden>
Date: 2016-06-15 22:43:31

Quoting Junio C Hamano [off-list ref]:
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 <redacted>
---

 * 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(-)
Thank you for a quick patch.  I was about to report that leftover test
file as a bug.  Do you ever sleep?  I am always amazed how quickly any
potential issue raised on the mailing list is resolved.

With this patch my "git init" in a pendrive correctly says "[core]
symlinks = false".

-- 
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/

----------------------------------------------------------------------
Get a free email account with anti spam protection.
http://www.bluebottle.com/tag/2

Re: [PATCH] autodetect core.symlinks in git-init

From: Marius Storm-Olsen <hidden>
Date: 2016-06-15 22:43:31

Junio C Hamano said the following on 31.08.2007 09:22:
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 <redacted>
---
+		if (!close(xmkstemp(path)) &&
Just tried this with 4msysgit (so, MinGW on Windows), and with a patch 
for adding xmkstemp() to git-compat-util.h, this patch works perfectly 
on Windows. It's obviously the right thing to do.

Acked-by: Marius Storm-Olsen <redacted>

-- 
.marius
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help