{"thread":{"id":"4791","subject":"[PATCH] Add \"raw\" output option to blobs in \"tree\" view format","startedAt":"2006-07-07T06:39:30Z","lastAt":"2006-07-07T18:45:22Z","messageCount":4,"participants":["Luben Tuikov","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"23342","messageId":"20060707063930.7752.qmail@web31805.mail.mud.yahoo.com","threadId":"4791","inReplyTo":null,"subject":"[PATCH] Add \"raw\" output option to blobs in \"tree\" view format","fromName":"Luben Tuikov","fromEmail":"ltuikov@yahoo.com","sentAt":"2006-07-07T06:39:30Z","receivedAt":"2006-07-07T06:39:30Z","isPatch":true,"sender":{"key":"ltuikov@yahoo.com","avatar":null},"body":"Add a \"raw\" output option to blobs in \"tree\" view format, so that the\nuser doesn't have to click on \"blob\", wait for the (binary) file to be\nuploaded and shown in \"blob\" mode, and then click on \"plain\" to\ndownload the (binary) file.\n\nThis is useful when the file is clearly binary and we don't want the\nbrowser to upload and display it in \"blob\" mode, but we just want to\ndownload it.  Case in point: pdf files, wlg.\n\nNote: the \"raw\" format is equivalent to the blob->plain view, not\nblob->head view. I.e. the view has the hash of the file as listed\nby git-ls-tree, not just \"HEAD\".\n\nSigned-off-by: Luben Tuikov <ltuikov@yahoo.com>\n---\n gitweb/gitweb.cgi |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi\nindex 3e2790c..cce0753 100755\n--- a/gitweb/gitweb.cgi\n+++ b/gitweb/gitweb.cgi\n@@ -1668,6 +1668,7 @@ sub git_tree {\n \t\t\t      $cgi->a({-href => \"$my_uri?\" .\nesc_param(\"p=$project;a=blob;h=$t_hash$base_key;f=$base$t_name\")}, \"blob\") .\n #\t\t\t      \" | \" . $cgi->a({-href => \"$my_uri?\" .\nesc_param(\"p=$project;a=blame;h=$t_hash$base_key;f=$base$t_name\")}, \"blame\") .\n \t\t\t      \" | \" . $cgi->a({-href => \"$my_uri?\" .\nesc_param(\"p=$project;a=history;h=$hash_base;f=$base$t_name\")}, \"history\") .\n+\t\t\t      \" | \" . $cgi->a({-href => \"$my_uri?\" .\nesc_param(\"p=$project;a=blob_plain;h=$t_hash;f=$base$t_name\")}, \"raw\") .\n \t\t\t      \"</td>\\n\";\n \t\t} elsif ($t_type eq \"tree\") {\n \t\t\tprint \"<td class=\\\"list\\\">\" .\n-- \n1.4.1.g88ada\n\n26f034dc7bf30e675d53da4f215ca2e1e6b88d1f\ndiff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi\nindex 3e2790c..cce0753 100755\n--- a/gitweb/gitweb.cgi\n+++ b/gitweb/gitweb.cgi\n@@ -1668,6 +1668,7 @@ sub git_tree {\n \t\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$t_hash$base_key;f=$base$t_name\")}, \"blob\") .\n #\t\t\t      \" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blame;h=$t_hash$base_key;f=$base$t_name\")}, \"blame\") .\n \t\t\t      \" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=history;h=$hash_base;f=$base$t_name\")}, \"history\") .\n+\t\t\t      \" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob_plain;h=$t_hash;f=$base$t_name\")}, \"raw\") .\n \t\t\t      \"</td>\\n\";\n \t\t} elsif ($t_type eq \"tree\") {\n \t\t\tprint \"<td class=\\\"list\\\">\" .\n"},{"id":"23343","messageId":"7vmzbl3nqj.fsf@assigned-by-dhcp.cox.net","threadId":"4791","inReplyTo":"20060707063930.7752.qmail@web31805.mail.mud.yahoo.com","subject":"Re: [PATCH] Add \"raw\" output option to blobs in \"tree\" view format","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-07-07T06:58:28Z","receivedAt":"2006-07-07T06:58:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Luben Tuikov <ltuikov@yahoo.com> writes:\n\n> Add a \"raw\" output option to blobs in \"tree\" view format, so that the\n> user doesn't have to click on \"blob\", wait for the (binary) file to be\n> uploaded and shown in \"blob\" mode, and then click on \"plain\" to\n> download the (binary) file.\n\nI appreciate what you are trying to achieve, but at the same\ntime wonder if it would make more sense to simply teach a=blob\naction to do this automatically, perhaps using /etc/mime.types\nand/or File::MMagic.\n\nIf you know your MUA will mangle whitespace to make your patch\ninapplicable, please do not add a patch to the message _and_\nattach the patch to the message.  The mail-acceptance tools know\nhow to flatten MIME attachments, but if you have your log,\nthree-dash and then corrupt patch in the cover-letter part, and\nthen the true patch in the attachment part, the flattened result\nwill have the corrupt patch first to cause the patch application\nto fail.  So please either (preferably) use a MUA that does not\ncorrupt your patches, or do a log in the message part with patch\nonly as attachment.\n"},{"id":"23378","messageId":"20060707164152.86022.qmail@web31805.mail.mud.yahoo.com","threadId":"4791","inReplyTo":"7vmzbl3nqj.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Add \"raw\" output option to blobs in \"tree\" view format","fromName":"Luben Tuikov","fromEmail":"ltuikov@yahoo.com","sentAt":"2006-07-07T16:41:52Z","receivedAt":"2006-07-07T16:41:52Z","isPatch":true,"sender":{"key":"ltuikov@yahoo.com","avatar":null},"body":"--- Junio C Hamano <junkio@cox.net> wrote:\n> Luben Tuikov <ltuikov@yahoo.com> writes:\n> \n> > Add a \"raw\" output option to blobs in \"tree\" view format, so that the\n> > user doesn't have to click on \"blob\", wait for the (binary) file to be\n> > uploaded and shown in \"blob\" mode, and then click on \"plain\" to\n> > download the (binary) file.\n> \n> I appreciate what you are trying to achieve, but at the same\n> time wonder if it would make more sense to simply teach a=blob\n> action to do this automatically, perhaps using /etc/mime.types\n> and/or File::MMagic.\n\nThat'd be cool for non-\"text/*\" files, but it would leave the user\ngo through the same click \"tree->blob->plain\" for \"text/*\" files,\nsince they are \"cat -n\"-able and the default action would be git_blob()\nif such an algorithm is implemented.\n\nThat is, the user would still have to click through \"tree->blob->plain\"\nto download a \"text/*\" file, as opposed to just \"tree->raw\".\n\nWhat this patch allows, is that the user be able to simply download the file,\nright from \"tree\" view, regardless of the type of file. (I.e. the type of\nfile as decided by the _user_, not gitweb.cgi.)\n\nHaving said that, we can still implement it, so that \"raw\"=\"blob\" for\nnon-\"text/*\" files, but \"raw\"!=\"blob\" for \"text/*\" files.  I.e. allow\nthe \"cat -n\" functionality for \"text/*\" files, as is currently implemented,\nas well as shortcut for downloading (\"raw\").\n\n> If you know your MUA will mangle whitespace to make your patch\n> inapplicable, please do not add a patch to the message _and_\n> attach the patch to the message.  The mail-acceptance tools know\n> how to flatten MIME attachments, but if you have your log,\n> three-dash and then corrupt patch in the cover-letter part, and\n> then the true patch in the attachment part, the flattened result\n> will have the corrupt patch first to cause the patch application\n> to fail.  So please either (preferably) use a MUA that does not\n> corrupt your patches, or do a log in the message part with patch\n> only as attachment.\n\nWill do.\n\n    Luben\n"},{"id":"23382","messageId":"7vejwxxni5.fsf@assigned-by-dhcp.cox.net","threadId":"4791","inReplyTo":"20060707164152.86022.qmail@web31805.mail.mud.yahoo.com","subject":"Re: [PATCH] Add \"raw\" output option to blobs in \"tree\" view format","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-07-07T18:45:22Z","receivedAt":"2006-07-07T18:45:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Luben Tuikov <ltuikov@yahoo.com> writes:\n\n> That is, the user would still have to click through \"tree->blob->plain\"\n> to download a \"text/*\" file, as opposed to just \"tree->raw\".\n>\n> What this patch allows, is that the user be able to simply download the file,\n> right from \"tree\" view, regardless of the type of file. (I.e. the type of\n> file as decided by the _user_, not gitweb.cgi.)\n\nOK, I see what you are aiming at.\n\nI have been irritated by the current git_blob that always seems\nto do \"cat -n\" even for non text/* files, but you are tackling\nthe opposite problem.\n"}]}