{"thread":{"id":"4413","subject":"[PATCH][gitweb] Make it possible to retrieve HEAD plain blob","startedAt":"2006-06-06T20:57:37Z","lastAt":"2006-06-06T22:10:09Z","messageCount":5,"participants":["Petr Baudis","Jakub Narebski","Bertrand Jacquin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"21341","messageId":"20060606205737.GX10488@pasky.or.cz","threadId":"4413","inReplyTo":null,"subject":"[PATCH][gitweb] Make it possible to retrieve HEAD plain blob","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-06-06T20:57:37Z","receivedAt":"2006-06-06T20:57:37Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Sometimes, it is useful to be able to link directly to the blob plain\nversion in the latest tree. This patch implements that.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n\ndiff --git a/gitweb.cgi b/gitweb.cgi\nindex ea21fbe..abaf6ce 100755\n--- a/gitweb.cgi\n+++ b/gitweb.cgi\n@@ -1376,7 +1376,8 @@ sub git_blob {\n \t\t      \" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=tree;h=$co{'tree'};hb=$hash_base\")}, \"tree\") . \"<br/>\\n\";\n \t\tif (defined $file_name) {\n \t\t\tprint $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob_plain;h=$hash;f=$file_name\")}, \"plain\") .\n-\t\t\t\" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;hb=HEAD;f=$file_name\")}, \"head\") . \"<br/>\\n\";\n+\t\t\t\" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;hb=HEAD;f=$file_name\")}, \"head\") .\n+\t\t\t\" (\" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob_plain;hb=HEAD;f=$file_name\")}, \"plain\") . \")<br/>\\n\";\n \t\t} else {\n \t\t\tprint $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob_plain;h=$hash\")}, \"plain\") . \"<br/>\\n\";\n \t\t}\n@@ -1414,6 +1415,10 @@ sub git_blob_plain {\n \tmy $save_as = \"$hash.txt\";\n \tif (defined $file_name) {\n \t\t$save_as = $file_name;\n+\t\tif (!defined $hash) {\n+\t\t\tmy $base = $hash_base || git_read_head($project);\n+\t\t\t$hash = git_get_hash_by_path($base, $file_name, \"blob\") || die_error(undef, \"Error lookup file.\");\n+\t\t}\n \t}\n \tprint $cgi->header(-type => \"text/plain\", -charset => 'utf-8', '-content-disposition' => \"inline; filename=\\\"$save_as\\\"\");\n \topen my $fd, \"-|\", \"$gitbin/git-cat-file blob $hash\" or return;\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nA person is just about as big as the things that make them angry.\n"},{"id":"21342","messageId":"e64rhu$i7n$1@sea.gmane.org","threadId":"4413","inReplyTo":"20060606205737.GX10488@pasky.or.cz","subject":"Re: [PATCH][gitweb] Make it possible to retrieve HEAD plain blob","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-06-06T21:20:05Z","receivedAt":"2006-06-06T21:20:05Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Petr Baudis wrote:\n\n> Sometimes, it is useful to be able to link directly to the blob plain\n> version in the latest tree. This patch implements that.\n\nBy the way, how to download binary file, like for example image, via gitweb?\nblob_plain doesn't give correct file after Save As (in the case of image,\nit is not recognized as such)...\n\n-- \nJakub Narebski\nWarsaw, Poland\n"},{"id":"21345","messageId":"4fb292fa0606061431g2fcc8cdet93685b5a4977c29f@mail.gmail.com","threadId":"4413","inReplyTo":"e64rhu$i7n$1@sea.gmane.org","subject":"Re: [PATCH][gitweb] Make it possible to retrieve HEAD plain blob","fromName":"Bertrand Jacquin","fromEmail":"beber.mailing@gmail.com","sentAt":"2006-06-06T21:31:09Z","receivedAt":"2006-06-06T21:31:09Z","isPatch":true,"sender":{"key":"beber.mailing@gmail.com","avatar":null},"body":"On 6/6/06, Jakub Narebski <jnareb@gmail.com> wrote:\n> Petr Baudis wrote:\n>\n> > Sometimes, it is useful to be able to link directly to the blob plain\n> > version in the latest tree. This patch implements that.\n>\n> By the way, how to download binary file, like for example image, via gitweb?\n> blob_plain doesn't give correct file after Save As (in the case of image,\n> it is not recognized as such)...\n\nThis is also a gitweb fault which always define document as plain-text\ninstead of correct MIME.\n\n-- \n# Beber : beber@gna.org\n# IM : beber@jabber.fr\n# http://guybrush.ath.cx, irc://irc.freenode.net/#{e.fr,gentoofr}\n"},{"id":"21348","messageId":"7vwtbulz32.fsf@assigned-by-dhcp.cox.net","threadId":"4413","inReplyTo":"4fb292fa0606061431g2fcc8cdet93685b5a4977c29f@mail.gmail.com","subject":"Re: [PATCH][gitweb] Make it possible to retrieve HEAD plain blob","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-06-06T22:05:21Z","receivedAt":"2006-06-06T22:05:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Bertrand Jacquin\" <beber.mailing@gmail.com> writes:\n\n> This is also a gitweb fault which always define document as plain-text\n> instead of correct MIME.\n\nBut that is somewhat unfair to blame it for -- we do not store\nwhat the correct mime-type is for each blob, so gitweb has to\nchoose between guessing and getting it wrong, or not guessing\nand havign the browser deal with it.  It chose the latter, which\nis understandably sensible.\n\nHaving said that, I would agree it would be very nice if I can\nsee t/test4012.png blob in gitweb automagically ;-).\n"},{"id":"21349","messageId":"4fb292fa0606061510s73fa6f3ag6e12766370749c77@mail.gmail.com","threadId":"4413","inReplyTo":"7vwtbulz32.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH][gitweb] Make it possible to retrieve HEAD plain blob","fromName":"Bertrand Jacquin","fromEmail":"beber.mailing@gmail.com","sentAt":"2006-06-06T22:10:09Z","receivedAt":"2006-06-06T22:10:09Z","isPatch":true,"sender":{"key":"beber.mailing@gmail.com","avatar":null},"body":"On 6/7/06, Junio C Hamano <junkio@cox.net> wrote:\n> \"Bertrand Jacquin\" <beber.mailing@gmail.com> writes:\n>\n> > This is also a gitweb fault which always define document as plain-text\n> > instead of correct MIME.\n>\n> But that is somewhat unfair to blame it for -- we do not store\n> what the correct mime-type is for each blob, so gitweb has to\n> choose between guessing and getting it wrong, or not guessing\n> and havign the browser deal with it.  It chose the latter, which\n> is understandably sensible.\n\nI'm ok with that. Browser can deal with if serveur do pass to it a\ntype=text/plain. And it's case for now :('\n\n-- \n# Beber : beber@gna.org\n# IM : beber@jabber.fr\n# http://guybrush.ath.cx, irc://irc.freenode.net/#{e.fr,gentoofr}\n"}]}