{"thread":{"id":"13215","subject":"[PATCH] Always copy template files (no symlinking)","startedAt":"2008-04-22T14:03:59Z","lastAt":"2008-04-22T19:12:32Z","messageCount":3,"participants":["Michael Weber","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"74967","messageId":"20080422140359.GA9590@roadkill.foldr.org","threadId":"13215","inReplyTo":null,"subject":"[PATCH] Always copy template files (no symlinking)","fromName":"Michael Weber","fromEmail":"michaelw@foldr.org","sentAt":"2008-04-22T14:03:59Z","receivedAt":"2008-04-22T14:03:59Z","isPatch":true,"sender":{"key":"michaelw@foldr.org","avatar":null},"body":"Previously, git would readlink(2) template files that are symlinks,\nand then symlink(2) the result into .git/.  This does not work for\nrelative symlinks (as produced by, e.g., encap), and is probably not a\ngood idea either: it is an irrelevant detail that a file in the\ntemplate directory is symlinked.\n\nSigned-off-by: Michael Weber <michaelw@foldr.org>\n---\n builtin-init-db.c |   15 ++-------------\n 1 files changed, 2 insertions(+), 13 deletions(-)\n\ndiff --git a/builtin-init-db.c b/builtin-init-db.c\nindex 2854868..b025a62 100644\n--- a/builtin-init-db.c\n+++ b/builtin-init-db.c\n@@ -83,19 +83,8 @@ static void copy_templates_1(char *path, int baselen,\n \t\t}\n \t\telse if (exists)\n \t\t\tcontinue;\n-\t\telse if (S_ISLNK(st_template.st_mode)) {\n-\t\t\tchar lnk[256];\n-\t\t\tint len;\n-\t\t\tlen = readlink(template, lnk, sizeof(lnk));\n-\t\t\tif (len < 0)\n-\t\t\t\tdie(\"cannot readlink %s\", template);\n-\t\t\tif (sizeof(lnk) <= len)\n-\t\t\t\tdie(\"insanely long symlink %s\", template);\n-\t\t\tlnk[len] = 0;\n-\t\t\tif (symlink(lnk, path))\n-\t\t\t\tdie(\"cannot symlink %s %s\", lnk, path);\n-\t\t}\n-\t\telse if (S_ISREG(st_template.st_mode)) {\n+\t\telse if (S_ISREG(st_template.st_mode) ||\n+\t\t\t S_ISLNK(st_template.st_mode)) {\n \t\t\tif (copy_file(path, template, st_template.st_mode))\n \t\t\t\tdie(\"cannot copy %s to %s\", template, path);\n \t\t}\n-- \n1.5.5.69.ga0a105\n"},{"id":"74985","messageId":"7vprshyg5e.fsf@gitster.siamese.dyndns.org","threadId":"13215","inReplyTo":"20080422140359.GA9590@roadkill.foldr.org","subject":"Re: [PATCH] Always copy template files (no symlinking)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-04-22T17:05:01Z","receivedAt":"2008-04-22T17:05:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Weber <michaelw@foldr.org> writes:\n\n> Previously, git would readlink(2) template files that are symlinks,\n> and then symlink(2) the result into .git/.  This does not work for\n> relative symlinks (as produced by, e.g., encap), and is probably not a\n> good idea either: it is an irrelevant detail that a file in the\n> template directory is symlinked.\n\nThis was very deliberately done to allow a relative symlink that points at\ne.g. ../../hooks/pre-commit with .git/hooks/pre-commit.  IOW, \"use what\nthe project suggests\".\n"},{"id":"75006","messageId":"30F967B1-A971-4F8B-A74D-4BDA8BB184B5@foldr.org","threadId":"13215","inReplyTo":"7vprshyg5e.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Always copy template files (no symlinking)","fromName":"Michael Weber","fromEmail":"michaelw@foldr.org","sentAt":"2008-04-22T19:12:32Z","receivedAt":"2008-04-22T19:12:32Z","isPatch":true,"sender":{"key":"michaelw@foldr.org","avatar":null},"body":"[accidentally sent as PM]\n\nOn Apr 22, 2008, at 19:05 , Junio C Hamano wrote:\n\n> Michael Weber <michaelw@foldr.org> writes:\n>\n>> Previously, git would readlink(2) template files that are symlinks,\n>> and then symlink(2) the result into .git/.  This does not work for\n>> relative symlinks (as produced by, e.g., encap), and is probably  \n>> not a\n>> good idea either: it is an irrelevant detail that a file in the\n>> template directory is symlinked.\n>\n> This was very deliberately done to allow a relative symlink that  \n> points at\n> e.g. ../../hooks/pre-commit with .git/hooks/pre-commit.  IOW, \"use  \n> what\n> the project suggests\".\n\nI see.  How can I get the same functionality on a platform which does  \nnot support symlinks?\n\n\nCheers,\nMichael\n"}]}