{"thread":{"id":"9254","subject":"gitweb chokes on recursive symlink","startedAt":"2007-07-27T08:23:03Z","lastAt":"2007-07-27T22:57:21Z","messageCount":2,"participants":["Junio C Hamano","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"48780","messageId":"7v8x922r2w.fsf@assigned-by-dhcp.cox.net","threadId":"9254","inReplyTo":null,"subject":"gitweb chokes on recursive symlink","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-27T08:23:03Z","receivedAt":"2007-07-27T08:23:03Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"If somebody used to advertise his repository that physically\nresides at /pub/lic.git/ as:\n\n\tgit://git.example.com/pub/lic.git/\n\nbut now wants to use --base-path to allow:\n\n\tgit://git.example.com/lic.git/\n\nshe can start git-daemon with --base-path option, like this:\n\n\tgit-daemon --base-path=/pub --export-all\n\nDuring the transition, however, she would also want to allow\nolder URL as well.  One natural way to achieve that is to create\na symlink:\n\n\tln -s /pub /pub/pub\n\nso that a request to git://git.example.com/pub/lic.git/ is first\ntranslated by --base-path to a request to /pub/pub/lic.git/\nwhich goes to /pub/lic.git, thanks to the symlink.\n\nSo far so good.\n\nHowever, gitweb chokes if there is such a symlink (File::Find\nbarfs with \"/pub/pub is a recursive symbolic link\" --- I think\nthis is because you use \"follow_fast => 1\").\n\nAs I happen to think using a symlink that goes up for backward\ncompatible URL support is a rather common practice, I think we\nshould do something about it.  My gut feeling is that we could\nsimply ignore such symlinks.\n\nWhat do you think about this issue?\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex b381692..c8ad84e 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1492,6 +1492,7 @@ sub git_get_projects_list {\n \n \t\tFile::Find::find({\n \t\t\tfollow_fast => 1, # follow symbolic links\n+\t\t\tfollow_skip => 2, # ignore duplicates\n \t\t\tdangling_symlinks => 0, # ignore dangling symlinks, silently\n \t\t\twanted => sub {\n \t\t\t\t# skip project-list toplevel, if we get it.\n\n\t\n"},{"id":"48845","messageId":"200707280057.22311.jnareb@gmail.com","threadId":"9254","inReplyTo":"7v8x922r2w.fsf@assigned-by-dhcp.cox.net","subject":"Re: gitweb chokes on recursive symlink","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-07-27T22:57:21Z","receivedAt":"2007-07-27T22:57:21Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n\n[cut explanation about why one would want something like below]\n \n> \tln -s /pub /pub/pub\n[...]\n> However, gitweb chokes if there is such a symlink (File::Find\n> barfs with \"/pub/pub is a recursive symbolic link\" --- I think\n> this is because you use \"follow_fast => 1\").\n> \n> As I happen to think using a symlink that goes up for backward\n> compatible URL support is a rather common practice, I think we\n> should do something about it.  My gut feeling is that we could\n> simply ignore such symlinks.\n> \n> What do you think about this issue?\n> \n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index b381692..c8ad84e 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -1492,6 +1492,7 @@ sub git_get_projects_list {\n>  \n>  \t\tFile::Find::find({\n>  \t\t\tfollow_fast => 1, # follow symbolic links\n> +\t\t\tfollow_skip => 2, # ignore duplicates\n>  \t\t\tdangling_symlinks => 0, # ignore dangling symlinks, silently\n>  \t\t\twanted => sub {\n>  \t\t\t\t# skip project-list toplevel, if we get it.\n> \n\nI guess that is a good solution, but I'm not Perl expert...\n\n-- \nJakub Narebski\nPoland\n"}]}