* [PATCH] Always copy template files (no symlinking)
@ 2008-04-22 14:03 Michael Weber
2008-04-22 17:05 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Michael Weber @ 2008-04-22 14:03 UTC (permalink / raw)
To: git
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Always copy template files (no symlinking)
2008-04-22 14:03 [PATCH] Always copy template files (no symlinking) Michael Weber
@ 2008-04-22 17:05 ` Junio C Hamano
2008-04-22 19:12 ` Michael Weber
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2008-04-22 17:05 UTC (permalink / raw)
To: git
Michael Weber <michaelw@foldr.org> writes:
> 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.
This was very deliberately done to allow a relative symlink that points at
e.g. ../../hooks/pre-commit with .git/hooks/pre-commit. IOW, "use what
the project suggests".
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Always copy template files (no symlinking)
2008-04-22 17:05 ` Junio C Hamano
@ 2008-04-22 19:12 ` Michael Weber
0 siblings, 0 replies; 3+ messages in thread
From: Michael Weber @ 2008-04-22 19:12 UTC (permalink / raw)
To: git
[accidentally sent as PM]
On Apr 22, 2008, at 19:05 , Junio C Hamano wrote:
> Michael Weber <michaelw@foldr.org> writes:
>
>> 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.
>
> This was very deliberately done to allow a relative symlink that
> points at
> e.g. ../../hooks/pre-commit with .git/hooks/pre-commit. IOW, "use
> what
> the project suggests".
I see. How can I get the same functionality on a platform which does
not support symlinks?
Cheers,
Michael
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-04-22 19:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-22 14:03 [PATCH] Always copy template files (no symlinking) Michael Weber
2008-04-22 17:05 ` Junio C Hamano
2008-04-22 19:12 ` Michael Weber
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).