git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* gitweb / cg-export
@ 2006-08-16  0:16 Toby White
  2006-08-16  0:23 ` gitweb / cg-export - corrected patch Toby White
  2006-08-16  9:54 ` gitweb / cg-export Jakub Narebski
  0 siblings, 2 replies; 13+ messages in thread
From: Toby White @ 2006-08-16  0:16 UTC (permalink / raw)
  To: git

I was wondering if a feature like the following would be of
use to anyone except me: I'd like to be able to download
the full source of a given tree from gitweb.

Use cases:

a) I'm browsing history through gitweb, find the tree
I'm interested in & want to download the whole tree without
cutting and pasting hashes.

b) I want to be able to quickly let people grab my latest
revision who don't have git installed, without faffing
about creating tarballs & emailing them; I'd like to be
able to paste a URL straight into my IM client.

I've quickly hacked gitweb to do this for me - patch below.

It adds an extra link to the 'commit' page. Next to the link
that would lead you to 'tree', there is 'tar.gz' which simply
returns the tar.gz of the same tree.

The patch is against the version of gitweb currently in
Debian, which is, erm, '264-1', apparently, because that's
what I had to hand.

Anyway. I'm no git expert so perhaps this is a really bad
idea, but I find it useful.

Toby White


--- gitweb.cgi.orig     2006-08-16 01:00:03.000000000 +0100
+++ gitweb.cgi  2006-08-16 00:58:38.000000000 +0100
@@ -180,6 +180,9 @@
 } elsif ($action eq "tree") {
        git_tree();
+       exit;
 } elsif ($action eq "rss") {
        git_rss();
        exit;
@@ -1523,6 +1526,21 @@
        git_footer_html();
 }

+sub git_export {
+       if (!defined $hash) {
+               $hash = git_read_head($project);
+               if (defined $file_name) {
+                       my $base = $hash_base || $hash;
+                       $hash = git_get_hash_by_path($base, $file_name, "tree");
+               }
+               if (!defined $hash_base) {
+                       $hash_base = $hash;
+               }
+       }
+       print $cgi->header(-type=>'application/x-tar',  -Content-Encoding=>'x-gzip', -status=> '200 OK');
+       exec "$gitbin/git-tar-tree $hash $project | gzip -c9" or die_error(undef, "Execute git-tar-tree failed.");
+}
+
 sub git_rss {
        # http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
        open my $fd, "-|", "$gitbin/git-rev-list --max-count=150 " . git_read_head($project) or die_error(undef, "Open failed.");
@@ -1779,6 +1797,7 @@
              $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash"), class => "list"}, $co{'tree'})
.
              "</td>" .
              "<td class=\"link\">" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree"
) .
+              "|" . $cgi->a({-href => "$my_uri/$project.tar.gz?" . esc_param("p=$project;a=export;h=$co{'tree'};hb=$hash")}, "tar.
gz") .
              "</td>" .
              "</tr>\n";
        my $parents  = $co{'parents'};

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2006-08-17  9:48 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-16  0:16 gitweb / cg-export Toby White
2006-08-16  0:23 ` gitweb / cg-export - corrected patch Toby White
2006-08-16  9:54 ` gitweb / cg-export Jakub Narebski
2006-08-16 10:53   ` Aneesh Kumar K.V
2006-08-16 11:32     ` Aneesh Kumar K.V
2006-08-16 20:05       ` Fredrik Kuivinen
2006-08-16 18:01     ` Junio C Hamano
2006-08-17  6:29       ` gitweb: Support for snapshots in gitweb Aneesh Kumar K.V
2006-08-17  7:34         ` Junio C Hamano
2006-08-17  7:48           ` Aneesh Kumar
2006-08-17  9:49         ` Jakub Narebski
2006-08-16 22:40     ` gitweb / cg-export Martin Waitz
2006-08-16 22:50       ` Kay Sievers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).