threads / patch / 4791

patchAdd "raw" output option to blobs in "tree" view format

Subject: [PATCH] Add "raw" output option to blobs in "tree" view format

## tl;dr

4 messages between Jul 7, 2006 and Jul 7, 2006. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Luben Tuikov· Jul 7, 2006, 06:39 UTC · lore

Add a "raw" output option to blobs in "tree" view format, so that the user doesn't have to click on "blob", wait for the (binary) file to be uploaded and shown in "blob" mode, and then click on "plain" to download the (binary) file.

This is useful when the file is clearly binary and we don't want the browser to upload and display it in "blob" mode, but we just want to download it. Case in point: pdf files, wlg.

Note: the "raw" format is equivalent to the blob->plain view, not
blob->head view. I.e. the view has the hash of the file as listed
by git-ls-tree, not just "HEAD".
Signed-off-by: Luben Tuikov <ltuikov@yahoo.com>
---
 gitweb/gitweb.cgi |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Show changes to gitweb/gitweb.cgi +1 −0
diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi
index 3e2790c..cce0753 100755
--- a/gitweb/gitweb.cgi
+++ b/gitweb/gitweb.cgi
@@ -1668,6 +1668,7 @@ sub git_tree {
 			      $cgi->a({-href => "$my_uri?" .
esc_param("p=$project;a=blob;h=$t_hash$base_key;f=$base$t_name")}, "blob") .
 #			      " | " . $cgi->a({-href => "$my_uri?" .
esc_param("p=$project;a=blame;h=$t_hash$base_key;f=$base$t_name")}, "blame") .
 			      " | " . $cgi->a({-href => "$my_uri?" .
esc_param("p=$project;a=history;h=$hash_base;f=$base$t_name")}, "history") .
+			      " | " . $cgi->a({-href => "$my_uri?" .
esc_param("p=$project;a=blob_plain;h=$t_hash;f=$base$t_name")}, "raw") .
 			      "</td>\n";
 		} elsif ($t_type eq "tree") {
 			print "<td class=\"list\">" .
-- 
1.4.1.g88ada

26f034dc7bf30e675d53da4f215ca2e1e6b88d1f
diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi
index 3e2790c..cce0753 100755
--- a/gitweb/gitweb.cgi
+++ b/gitweb/gitweb.cgi
@@ -1668,6 +1668,7 @@ sub git_tree {
 			      $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$t_hash$base_key;f=$base$t_name")}, "blob") .
 #			      " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blame;h=$t_hash$base_key;f=$base$t_name")}, "blame") .
 			      " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;h=$hash_base;f=$base$t_name")}, "history") .
+			      " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;h=$t_hash;f=$base$t_name")}, "raw") .
 			      "</td>\n";
 		} elsif ($t_type eq "tree") {
 			print "<td class=\"list\">" .
Junio C Hamano· Jul 7, 2006, 06:58 UTC · re: Luben Tuikov · lore

Re: [PATCH] Add "raw" output option to blobs in "tree" view format

Luben Tuikov <ltuikov@yahoo.com> writes:
> Add a "raw" output option to blobs in "tree" view format, so that the
> user doesn't have to click on "blob", wait for the (binary) file to be
> uploaded and shown in "blob" mode, and then click on "plain" to
> download the (binary) file.

I appreciate what you are trying to achieve, but at the same time wonder if it would make more sense to simply teach a=blob action to do this automatically, perhaps using /etc/mime.types and/or File::MMagic.

If you know your MUA will mangle whitespace to make your patch inapplicable, please do not add a patch to the message _and_ attach the patch to the message. The mail-acceptance tools know how to flatten MIME attachments, but if you have your log, three-dash and then corrupt patch in the cover-letter part, and then the true patch in the attachment part, the flattened result will have the corrupt patch first to cause the patch application to fail. So please either (preferably) use a MUA that does not corrupt your patches, or do a log in the message part with patch only as attachment.

Luben Tuikov· Jul 7, 2006, 16:41 UTC · re: Junio C Hamano · lore

Re: [PATCH] Add "raw" output option to blobs in "tree" view format

--- Junio C Hamano <junkio@cox.net> wrote:
Show 11 quoted lines
> Luben Tuikov <ltuikov@yahoo.com> writes:
> 
> > Add a "raw" output option to blobs in "tree" view format, so that the
> > user doesn't have to click on "blob", wait for the (binary) file to be
> > uploaded and shown in "blob" mode, and then click on "plain" to
> > download the (binary) file.
> 
> I appreciate what you are trying to achieve, but at the same
> time wonder if it would make more sense to simply teach a=blob
> action to do this automatically, perhaps using /etc/mime.types
> and/or File::MMagic.

That'd be cool for non-"text/*" files, but it would leave the user go through the same click "tree->blob->plain" for "text/*" files, since they are "cat -n"-able and the default action would be git_blob() if such an algorithm is implemented.

That is, the user would still have to click through "tree->blob->plain" to download a "text/*" file, as opposed to just "tree->raw".

What this patch allows, is that the user be able to simply download the file, right from "tree" view, regardless of the type of file. (I.e. the type of file as decided by the _user_, not gitweb.cgi.)

Having said that, we can still implement it, so that "raw"="blob" for non-"text/*" files, but "raw"!="blob" for "text/*" files. I.e. allow the "cat -n" functionality for "text/*" files, as is currently implemented, as well as shortcut for downloading ("raw").

Show 10 quoted lines
> If you know your MUA will mangle whitespace to make your patch
> inapplicable, please do not add a patch to the message _and_
> attach the patch to the message.  The mail-acceptance tools know
> how to flatten MIME attachments, but if you have your log,
> three-dash and then corrupt patch in the cover-letter part, and
> then the true patch in the attachment part, the flattened result
> will have the corrupt patch first to cause the patch application
> to fail.  So please either (preferably) use a MUA that does not
> corrupt your patches, or do a log in the message part with patch
> only as attachment.
Will do.
    Luben
Junio C Hamano· Jul 7, 2006, 18:45 UTC · re: Luben Tuikov · lore

Re: [PATCH] Add "raw" output option to blobs in "tree" view format

Luben Tuikov <ltuikov@yahoo.com> writes:
Show 6 quoted lines
> That is, the user would still have to click through "tree->blob->plain"
> to download a "text/*" file, as opposed to just "tree->raw".
>
> What this patch allows, is that the user be able to simply download the file,
> right from "tree" view, regardless of the type of file. (I.e. the type of
> file as decided by the _user_, not gitweb.cgi.)
OK, I see what you are aiming at.

I have been irritated by the current git_blob that always seems to do "cat -n" even for non text/* files, but you are tackling the opposite problem.

← back to recent threads