{"thread":{"id":"5613","subject":"[PATCH] gitweb: Fix @git_base_url_list usage","startedAt":"2006-09-20T00:09:46Z","lastAt":"2006-09-22T23:15:18Z","messageCount":5,"participants":["Petr Baudis","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"27201","messageId":"20060920000946.GC13132@pasky.or.cz","threadId":"5613","inReplyTo":null,"subject":"[PATCH] gitweb: Fix @git_base_url_list usage","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-09-20T00:09:46Z","receivedAt":"2006-09-20T00:09:46Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"As it is now, that array was never used because the customurl accessor was\nbroken and ''unless @url_list'' never happenned.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n---\n\n gitweb/gitweb.perl |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 2d0d56f..1b029ac 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -731,7 +731,7 @@ sub git_get_project_description {\n sub git_get_project_url_list {\n \tmy $path = shift;\n \n-\topen my $fd, \"$projectroot/$path/cloneurl\" or return undef;\n+\topen my $fd, \"$projectroot/$path/cloneurl\" or return wantarray ? () : undef;\n \tmy @git_project_url_list = map { chomp; $_ } <$fd>;\n \tclose $fd;\n \n"},{"id":"27203","messageId":"7v64fjnzyr.fsf@assigned-by-dhcp.cox.net","threadId":"5613","inReplyTo":"20060920000946.GC13132@pasky.or.cz","subject":"Re: [PATCH] gitweb: Fix @git_base_url_list usage","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-20T00:28:28Z","receivedAt":"2006-09-20T00:28:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Petr Baudis <pasky@suse.cz> writes:\n\n> As it is now, that array was never used because the customurl accessor was\n> broken and ''unless @url_list'' never happenned.\n>\n> Signed-off-by: Petr Baudis <pasky@suse.cz>\n> ---\n>...\n>  sub git_get_project_url_list {\n>  \tmy $path = shift;\n>  \n> -\topen my $fd, \"$projectroot/$path/cloneurl\" or return undef;\n> +\topen my $fd, \"$projectroot/$path/cloneurl\" or return wantarray ? () : undef;\n>  \tmy @git_project_url_list = map { chomp; $_ } <$fd>;\n>  \tclose $fd;\n\nWhy on earth do you want to use wantarray for something like\nthis?\n\nIt's not like you are implementinging any fancy DWIM magic.\n\nIsn't\n\n\topen my $fd, \"foobar\" or return;\n\nmuch easier to read?\n\n#!/usr/bin/perl\n\nsub return_undef {\n\topen my $fd, \"no-such-file\"\n\t    or return wantarray ? () : undef;\n}\nsub return_broken {\n\topen my $fd, \"no-such-file\"\n\t    or return undef;\n}\n\nsub return_empty {\n\topen my $fd, \"no-such-file\"\n\t    or return;\n}\n\nmy $returned_undef_1 = return_undef();\nmy ($returned_undef_2) = return_undef();\nmy @returned_undef = return_undef();\n\nmy $returned_broken_1 = return_broken();\nmy ($returned_broken_2) = return_broken();\nmy @returned_broken = return_broken();\n\nmy $returned_empty_1 = return_empty();\nmy ($returned_empty_2) = return_empty();\nmy @returned_empty = return_empty();\n\nprintf \"U %d B %d E %d\\n\",\n    scalar(@returned_undef),\n    scalar(@returned_broken),\n    scalar(@returned_empty);\n\nfor ($returned_undef_1,\n     $returned_undef_2,\n     $returned_broken_1,\n     $returned_broken_2,\n     $returned_empty_1,\n     $returned_empty_2) {\n\tprint \"What I said was bogus.\\n\" if (defined $_);\n}\n"},{"id":"27204","messageId":"7vodtbmkq2.fsf@assigned-by-dhcp.cox.net","threadId":"5613","inReplyTo":"7v64fjnzyr.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] gitweb: Fix @git_base_url_list usage","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-20T00:43:01Z","receivedAt":"2006-09-20T00:43:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> Why on earth do you want to use wantarray for something like\n> this?\n>\n> It's not like you are implementinging any fancy DWIM magic.\n\nSide note.  I really hate it when people abuse wantarray.\n\nI can think of only two valid reasons (well, perhaps three but\nthe last one is a logical consequence of the first two) to use\nwantarray.  They are:\n\n (1) The information you are giving back the caller is list of\n     things in nature, but there is a natural representation for\n     that list as a single scalar, and that representation is\n     not the last element of the list.  You would want to help\n     the caller by DWIMmery.\n\n     Perl's built-in localtime() is an excellent example for\n     wanting to do something like this.  It returns broken-down\n     \"struct tm\" in list context, but returns string ctime(3) in\n     scalar context.\n\n (2) You want to avoid complex computations when the caller does\n     not need full return values from you.  A good example is\n     found in perlfunc.pod:\n\n        return unless defined wantarray;\t# don't bother doing more\n        my @a = complex_calculation();\n        return wantarray ? @a : \"@a\";\n\n (3) You are emulating Perl's built-in function that DWIMs for\n     one of the above reasons, usually (1).\n"},{"id":"27206","messageId":"20060920004935.GJ8259@pasky.or.cz","threadId":"5613","inReplyTo":"7v64fjnzyr.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] gitweb: Fix @git_base_url_list usage","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-09-20T00:49:35Z","receivedAt":"2006-09-20T00:49:35Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Wed, Sep 20, 2006 at 02:28:28AM CEST, I got a letter\nwhere Junio C Hamano <junkio@cox.net> said that...\n> Petr Baudis <pasky@suse.cz> writes:\n> \n> > As it is now, that array was never used because the customurl accessor was\n> > broken and ''unless @url_list'' never happenned.\n> >\n> > Signed-off-by: Petr Baudis <pasky@suse.cz>\n> > ---\n> >...\n> >  sub git_get_project_url_list {\n> >  \tmy $path = shift;\n> >  \n> > -\topen my $fd, \"$projectroot/$path/cloneurl\" or return undef;\n> > +\topen my $fd, \"$projectroot/$path/cloneurl\" or return wantarray ? () : undef;\n> >  \tmy @git_project_url_list = map { chomp; $_ } <$fd>;\n> >  \tclose $fd;\n> \n> Why on earth do you want to use wantarray for something like\n> this?\n> \n> It's not like you are implementinging any fancy DWIM magic.\n> \n> Isn't\n> \n> \topen my $fd, \"foobar\" or return;\n> \n> much easier to read?\n\nSure, that's what I meant, I'm only already a bit tired so I just\nmimicked the other return in that sub, sorry.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nSnow falling on Perl. White noise covering line noise.\nHides all the bugs too. -- J. Putnam\n"},{"id":"27426","messageId":"20060922231518.32050.73077.stgit@rover","threadId":"5613","inReplyTo":"20060920004935.GJ8259@pasky.or.cz","subject":"[PATCH] gitweb: Fix @git_base_url_list usage","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-09-22T23:15:18Z","receivedAt":"2006-09-22T23:15:18Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"As it is now, that array was never used because the customurl accessor was\nbroken and ''unless @url_list'' never happenned.\n---\n\n gitweb/gitweb.perl |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex f7e7d10..a357604 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -752,7 +752,7 @@ sub git_get_project_description {\n sub git_get_project_url_list {\n \tmy $path = shift;\n \n-\topen my $fd, \"$projectroot/$path/cloneurl\" or return undef;\n+\topen my $fd, \"$projectroot/$path/cloneurl\" or return;\n \tmy @git_project_url_list = map { chomp; $_ } <$fd>;\n \tclose $fd;\n \n"}]}