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

[PATCH] Always copy template files (no symlinking)

From
MWMichael Weber <michaelw@foldr.org>
Date
Apr 22, 2008, 14:03 UTC
Message-ID
<20080422140359.GA9590@roadkill.foldr.org>

Previously, git would readlink(2) template files that are symlinks, and then symlink(2) the result into .git/. This does not work for relative symlinks (as produced by, e.g., encap), and is probably not a good idea either: it is an irrelevant detail that a file in the template directory is symlinked.

Signed-off-by: Michael Weber <michaelw@foldr.org>
---
 builtin-init-db.c |   15 ++-------------
 1 files changed, 2 insertions(+), 13 deletions(-)
diff --git a/builtin-init-db.c b/builtin-init-db.c
index 2854868..b025a62 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -83,19 +83,8 @@ static void copy_templates_1(char *path, int baselen,
 		}
 		else if (exists)
 			continue;
-		else if (S_ISLNK(st_template.st_mode)) {
-			char lnk[256];
-			int len;
-			len = readlink(template, lnk, sizeof(lnk));
-			if (len < 0)
-				die("cannot readlink %s", template);
-			if (sizeof(lnk) <= len)
-				die("insanely long symlink %s", template);
-			lnk[len] = 0;
-			if (symlink(lnk, path))
-				die("cannot symlink %s %s", lnk, path);
-		}
-		else if (S_ISREG(st_template.st_mode)) {
+		else if (S_ISREG(st_template.st_mode) ||
+			 S_ISLNK(st_template.st_mode)) {
 			if (copy_file(path, template, st_template.st_mode))
 				die("cannot copy %s to %s", template, path);
 		}
-- 
1.5.5.69.ga0a105
Next: Junio C Hamano
Message 1 of 3 in “Always copy template files (no symlinking)”
  1. Always copy template files (no symlinking)Michael Weber, Apr 22, 2008
  2. Junio C HamanoApr 22, 2008
  3. Michael WeberApr 22, 2008

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.