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

4 messages from 2006-07-07 to 2006-07-07. Participants: Luben Tuikov, Junio C Hamano.
Thread: https://gitlist.dev/t/4791

## Luben Tuikov, 2006-07-07 06:39

Subject: [PATCH] Add "raw" output option to blobs in "tree" view format
Message-ID: <20060707063930.7752.qmail@web31805.mail.mud.yahoo.com>
URL: https://gitlist.dev/e/20060707063930.7752.qmail%40web31805.mail.mud.yahoo.com

```
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(-)

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, 2006-07-07 06:58

Subject: Re: [PATCH] Add "raw" output option to blobs in "tree" view format
Message-ID: <7vmzbl3nqj.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vmzbl3nqj.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20060707063930.7752.qmail@web31805.mail.mud.yahoo.com>

```
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, 2006-07-07 16:41

Subject: Re: [PATCH] Add "raw" output option to blobs in "tree" view format
Message-ID: <20060707164152.86022.qmail@web31805.mail.mud.yahoo.com>
URL: https://gitlist.dev/e/20060707164152.86022.qmail%40web31805.mail.mud.yahoo.com
In-Reply-To: <7vmzbl3nqj.fsf@assigned-by-dhcp.cox.net>

```
--- Junio C Hamano <junkio@cox.net> wrote:
> 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").

> 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, 2006-07-07 18:45

Subject: Re: [PATCH] Add "raw" output option to blobs in "tree" view format
Message-ID: <7vejwxxni5.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vejwxxni5.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20060707164152.86022.qmail@web31805.mail.mud.yahoo.com>

```
Luben Tuikov <ltuikov@yahoo.com> writes:

> 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.

```
