{"thread":{"id":"5294","subject":"gitweb / cg-export","startedAt":"2006-08-16T00:16:29Z","lastAt":"2006-08-17T09:49:03Z","messageCount":13,"participants":["Toby White","Jakub Narebski","Aneesh Kumar K.V","Junio C Hamano","Fredrik Kuivinen","Martin Waitz","Kay Sievers","Aneesh Kumar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"25393","messageId":"44E263DD.6030305@cam.ac.uk","threadId":"5294","inReplyTo":null,"subject":"gitweb / cg-export","fromName":"Toby White","fromEmail":"tow21@cam.ac.uk","sentAt":"2006-08-16T00:16:29Z","receivedAt":"2006-08-16T00:16:29Z","isPatch":false,"sender":{"key":"tow21@cam.ac.uk","avatar":null},"body":"I was wondering if a feature like the following would be of\nuse to anyone except me: I'd like to be able to download\nthe full source of a given tree from gitweb.\n\nUse cases:\n\na) I'm browsing history through gitweb, find the tree\nI'm interested in & want to download the whole tree without\ncutting and pasting hashes.\n\nb) I want to be able to quickly let people grab my latest\nrevision who don't have git installed, without faffing\nabout creating tarballs & emailing them; I'd like to be\nable to paste a URL straight into my IM client.\n\nI've quickly hacked gitweb to do this for me - patch below.\n\nIt adds an extra link to the 'commit' page. Next to the link\nthat would lead you to 'tree', there is 'tar.gz' which simply\nreturns the tar.gz of the same tree.\n\nThe patch is against the version of gitweb currently in\nDebian, which is, erm, '264-1', apparently, because that's\nwhat I had to hand.\n\nAnyway. I'm no git expert so perhaps this is a really bad\nidea, but I find it useful.\n\nToby White\n\n\n--- gitweb.cgi.orig     2006-08-16 01:00:03.000000000 +0100\n+++ gitweb.cgi  2006-08-16 00:58:38.000000000 +0100\n@@ -180,6 +180,9 @@\n } elsif ($action eq \"tree\") {\n        git_tree();\n+       exit;\n } elsif ($action eq \"rss\") {\n        git_rss();\n        exit;\n@@ -1523,6 +1526,21 @@\n        git_footer_html();\n }\n\n+sub git_export {\n+       if (!defined $hash) {\n+               $hash = git_read_head($project);\n+               if (defined $file_name) {\n+                       my $base = $hash_base || $hash;\n+                       $hash = git_get_hash_by_path($base, $file_name, \"tree\");\n+               }\n+               if (!defined $hash_base) {\n+                       $hash_base = $hash;\n+               }\n+       }\n+       print $cgi->header(-type=>'application/x-tar',  -Content-Encoding=>'x-gzip', -status=> '200 OK');\n+       exec \"$gitbin/git-tar-tree $hash $project | gzip -c9\" or die_error(undef, \"Execute git-tar-tree failed.\");\n+}\n+\n sub git_rss {\n        # http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ\n        open my $fd, \"-|\", \"$gitbin/git-rev-list --max-count=150 \" . git_read_head($project) or die_error(undef, \"Open failed.\");\n@@ -1779,6 +1797,7 @@\n              $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=tree;h=$co{'tree'};hb=$hash\"), class => \"list\"}, $co{'tree'})\n.\n              \"</td>\" .\n              \"<td class=\\\"link\\\">\" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=tree;h=$co{'tree'};hb=$hash\")}, \"tree\"\n) .\n+              \"|\" . $cgi->a({-href => \"$my_uri/$project.tar.gz?\" . esc_param(\"p=$project;a=export;h=$co{'tree'};hb=$hash\")}, \"tar.\ngz\") .\n              \"</td>\" .\n              \"</tr>\\n\";\n        my $parents  = $co{'parents'};\n"},{"id":"25395","messageId":"44E2658D.9020600@cam.ac.uk","threadId":"5294","inReplyTo":"44E263DD.6030305@cam.ac.uk","subject":"Re: gitweb / cg-export - corrected patch","fromName":"Toby White","fromEmail":"tow21@cam.ac.uk","sentAt":"2006-08-16T00:23:41Z","receivedAt":"2006-08-16T00:23:41Z","isPatch":false,"sender":{"key":"tow21@cam.ac.uk","avatar":null},"body":"Argh - sorry, patch got mangled somehow in previous message.\n\nCorrect patch below.\n\nToby\n\n--- gitweb.cgi.orig     2006-08-16 01:00:03.000000000 +0100\n+++ gitweb.cgi  2006-08-16 00:58:38.000000000 +0100\n@@ -180,6 +180,9 @@\n } elsif ($action eq \"tree\") {\n        git_tree();\n        exit;\n+} elsif ($action eq \"export\") {\n+       git_export();\n+       exit;\n } elsif ($action eq \"rss\") {\n        git_rss();\n        exit;\n@@ -1523,6 +1526,21 @@\n        git_footer_html();\n }\n\n+sub git_export {\n+       if (!defined $hash) {\n+               $hash = git_read_head($project);\n+               if (defined $file_name) {\n+                       my $base = $hash_base || $hash;\n+                       $hash = git_get_hash_by_path($base, $file_name, \"tree\");\n+               }\n+               if (!defined $hash_base) {\n+                       $hash_base = $hash;\n+               }\n+       }\n+       print $cgi->header(-type=>'application/x-tar',  -Content-Encoding=>'x-gzip', -status=> '200 OK');\n+       exec \"$gitbin/git-tar-tree $hash $project | gzip -c9\" or die_error(undef, \"Execute git-tar-tree failed.\");\n+}\n+\n sub git_rss {\n        # http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ\n        open my $fd, \"-|\", \"$gitbin/git-rev-list --max-count=150 \" . git_read_head($project) or die_error(undef, \"Open failed.\");\n@@ -1779,6 +1797,7 @@\n              $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=tree;h=$co{'tree'};hb=$hash\"), class => \"list\"}, $co{'tree'})\n.\n              \"</td>\" .\n              \"<td class=\\\"link\\\">\" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=tree;h=$co{'tree'};hb=$hash\")}, \"tree\"\n) .\n+              \"|\" . $cgi->a({-href => \"$my_uri/$project.tar.gz?\" . esc_param(\"p=$project;a=export;h=$co{'tree'};hb=$hash\")}, \"tar.\ngz\") .\n              \"</td>\" .\n              \"</tr>\\n\";\n        my $parents  = $co{'parents'};\n"},{"id":"25410","messageId":"ebupuk$dgl$1@sea.gmane.org","threadId":"5294","inReplyTo":"44E263DD.6030305@cam.ac.uk","subject":"Re: gitweb / cg-export","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-16T09:54:18Z","receivedAt":"2006-08-16T09:54:18Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Toby White wrote:\n\n> I was wondering if a feature like the following would be of\n> use to anyone except me: I'd like to be able to download\n> the full source of a given tree from gitweb.\n[...]\nSo you want to have snapshot of a tree. Why not snapshot of a commit, \nor of a tag?\n\n> I've quickly hacked gitweb to do this for me - patch below.\n> \n> It adds an extra link to the 'commit' page. Next to the link\n> that would lead you to 'tree', there is 'tar.gz' which simply\n> returns the tar.gz of the same tree.\n> \n> The patch is against the version of gitweb currently in\n> Debian, which is, erm, '264-1', apparently, because that's\n> what I had to hand.\n\nIt is really better to hack git with git. And you can use current gitweb\nwith old git (well, not always, as current gitweb requires --full-history\noption to git-rev-list to be available).\n \n> Anyway. I'm no git expert so perhaps this is a really bad\n> idea, but I find it useful.\n\nIt is usefull idea, as it was implemented independently by Sven Verdoolaege\nin http://marc.theaimsgroup.com/?l=git&m=111909432415478&w=2 directly in\ngitweb, and by Sham Chukoury in gitweb-xmms2 using snapshot.cgi in Python\nin \"Snapshot links support\" commit\nhttp://git.xmms.se/?p=gitweb-xmms2.git;a=commit;h=3d0284bb784041907de33df5cff8449f8aeb072e\nand \"Add xmms2 project's snapshot.cgi\" commit\nhttp://git.xmms.se/?p=gitweb-xmms2.git;a=commit;h=3d0284bb784041907de33df5cff8449f8aeb072e\n\nI have planned to add snapshot support, see \"[RFC] gitweb wishlist and TODO\nlist\" thread in mailing list archives, check\n   http://git.or.cz/gitwiki/GitCommunity\nfor list, but I was planning to do some refactoring, including \n<td class=\"link\"> links refactoring (that is where snapshot links would be\nadded).\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"25412","messageId":"44E2F911.6060002@gmail.com","threadId":"5294","inReplyTo":"ebupuk$dgl$1@sea.gmane.org","subject":"Re: gitweb / cg-export","fromName":"Aneesh Kumar K.V","fromEmail":"aneesh.kumar@gmail.com","sentAt":"2006-08-16T10:53:05Z","receivedAt":"2006-08-16T10:53:05Z","isPatch":false,"sender":{"key":"aneesh.kumar@gmail.com","avatar":"https://gravatar.com/avatar/0621fc0b2f14ead1e9024382f16053a808c148596da30c1b92572fa075621f68?d=mp&s=160"},"body":"Jakub Narebski wrote:\n> Toby White wrote:\n> \n>> I was wondering if a feature like the following would be of\n>> use to anyone except me: I'd like to be able to download\n>> the full source of a given tree from gitweb.\n> [...]\n> So you want to have snapshot of a tree. Why not snapshot of a commit, \n> or of a tag?\n> \n>> I've quickly hacked gitweb to do this for me - patch below.\n>>\n>> It adds an extra link to the 'commit' page. Next to the link\n>> that would lead you to 'tree', there is 'tar.gz' which simply\n>> returns the tar.gz of the same tree.\n>>\n>> The patch is against the version of gitweb currently in\n>> Debian, which is, erm, '264-1', apparently, because that's\n>> what I had to hand.\n> \n> It is really better to hack git with git. And you can use current gitweb\n> with old git (well, not always, as current gitweb requires --full-history\n> option to git-rev-list to be available).\n> \n\nHow about the below on top of latest git \n\n-aneesh\n\n\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 37a6284..b9b522a 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -175,6 +175,7 @@ my %actions = (\n \t\"tag\" => \\&git_tag,\n \t\"tags\" => \\&git_tags,\n \t\"tree\" => \\&git_tree,\n+\t\"snapshot\" => \\&git_snapshot,\n );\n \n $action = 'summary' if (!defined($action));\n@@ -1334,6 +1335,7 @@ sub git_shortlog_body {\n \t\t      \"<td class=\\\"link\\\">\" .\n \t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$commit)}, \"commit\") . \" | \" .\n \t\t      $cgi->a({-href => href(action=>\"commitdiff\", hash=>$commit)}, \"commitdiff\") .\n+\t\t      \" | \" .$cgi->a({-href => \"$my_uri/$project.tar.gz?\" . esc_param(\"p=$project;a=snapshot;h=$commit\")}, \"snapshot\") .\n \t\t      \"</td>\\n\" .\n \t\t      \"</tr>\\n\";\n \t}\n@@ -2097,6 +2099,21 @@ sub git_tree {\n \tgit_footer_html();\n }\n \n+sub git_snapshot {\n+\tif (!defined $hash) {\n+\t\t$hash = git_get_head_hash($project);\n+\t}\n+\tprint $cgi->header(-type=>'application/x-tar',\n+\t\t\t  -Content-Encoding=>'x-gzip', -status=> '200 OK');\n+\topen my $fd, \"-|\", \"$GIT tar-tree $hash $project | gzip -c9\" or die_error(undef, \"Execute git-tar-tree failed.\");\n+\tbinmode STDOUT, ':raw';\n+\tprint <$fd>;\n+\tbinmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi\n+\tclose $fd;\n+\n+\n+}\n+\n sub git_log {\n \tmy $head = git_get_head_hash($project);\n \tif (!defined $hash) {\n"},{"id":"25413","messageId":"ebuvok$vnv$1@sea.gmane.org","threadId":"5294","inReplyTo":"44E2F911.6060002@gmail.com","subject":"Re: gitweb / cg-export","fromName":"Aneesh Kumar K.V","fromEmail":"aneesh.kumar@gmail.com","sentAt":"2006-08-16T11:32:36Z","receivedAt":"2006-08-16T11:32:36Z","isPatch":false,"sender":{"key":"aneesh.kumar@gmail.com","avatar":"https://gravatar.com/avatar/0621fc0b2f14ead1e9024382f16053a808c148596da30c1b92572fa075621f68?d=mp&s=160"},"body":"Aneesh Kumar K.V wrote:\n> Jakub Narebski wrote:\n>> Toby White wrote:\n>>\n>>> I was wondering if a feature like the following would be of\n>>> use to anyone except me: I'd like to be able to download\n>>> the full source of a given tree from gitweb.\n>> [...]\n>> So you want to have snapshot of a tree. Why not snapshot of a commit, \n>> or of a tag?\n>>\n>>> I've quickly hacked gitweb to do this for me - patch below.\n>>>\n>>> It adds an extra link to the 'commit' page. Next to the link\n>>> that would lead you to 'tree', there is 'tar.gz' which simply\n>>> returns the tar.gz of the same tree.\n>>>\n>>> The patch is against the version of gitweb currently in\n>>> Debian, which is, erm, '264-1', apparently, because that's\n>>> what I had to hand.\n>>\n>> It is really better to hack git with git. And you can use current gitweb\n>> with old git (well, not always, as current gitweb requires --full-history\n>> option to git-rev-list to be available).\n>>\n> \n> How about the below on top of latest git\n\nAdd it to git_commit too. The patch contains the pervious changes also.\n\n-aneesh\n\n\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 37a6284..b2e375e 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -175,6 +175,7 @@ my %actions = (\n \t\"tag\" => \\&git_tag,\n \t\"tags\" => \\&git_tags,\n \t\"tree\" => \\&git_tree,\n+\t\"snapshot\" => \\&git_snapshot,\n );\n \n $action = 'summary' if (!defined($action));\n@@ -1334,6 +1335,7 @@ sub git_shortlog_body {\n \t\t      \"<td class=\\\"link\\\">\" .\n \t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$commit)}, \"commit\") . \" | \" .\n \t\t      $cgi->a({-href => href(action=>\"commitdiff\", hash=>$commit)}, \"commitdiff\") .\n+\t\t      \" | \" .$cgi->a({-href => \"$my_uri/$project.tar.gz?\" . esc_param(\"p=$project;a=snapshot;h=$commit\")}, \"snapshot\") .\n \t\t      \"</td>\\n\" .\n \t\t      \"</tr>\\n\";\n \t}\n@@ -2097,6 +2099,21 @@ sub git_tree {\n \tgit_footer_html();\n }\n \n+sub git_snapshot {\n+\tif (!defined $hash) {\n+\t\t$hash = git_get_head_hash($project);\n+\t}\n+\tprint $cgi->header(-type=>'application/x-tar',\n+\t\t\t  -Content-Encoding=>'x-gzip', -status=> '200 OK');\n+\topen my $fd, \"-|\", \"$GIT tar-tree $hash $project | gzip -c9\" or die_error(undef, \"Execute git-tar-tree failed.\");\n+\tbinmode STDOUT, ':raw';\n+\tprint <$fd>;\n+\tbinmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi\n+\tclose $fd;\n+\n+\n+}\n+\n sub git_log {\n \tmy $head = git_get_head_hash($project);\n \tif (!defined $hash) {\n@@ -2226,7 +2243,8 @@ sub git_commit {\n \t      \"<td class=\\\"sha1\\\">\" .\n \t      $cgi->a({-href => href(action=>\"tree\", hash=>$co{'tree'}, hash_base=>$hash), class => \"list\"}, $co{'tree'}) .\n \t      \"</td>\" .\n-\t      \"<td class=\\\"link\\\">\" . $cgi->a({-href => href(action=>\"tree\", hash=>$co{'tree'}, hash_base=>$hash)}, \"tree\") .\n+\t      \"<td class=\\\"link\\\">\" . $cgi->a({-href => href(action=>\"tree\", hash=>$co{'tree'}, hash_base=>$hash)}, \"tree\") . \" | \" .\n+\t      $cgi->a({-href => \"$my_uri/$project.tar.gz?\" . esc_param(\"p=$project;a=snapshot;h=$hash\")}, \"snapshot\") .\n \t      \"</td>\" .\n \t      \"</tr>\\n\";\n \tmy $parents = $co{'parents'};\n"},{"id":"25421","messageId":"7v4pwc4l0y.fsf@assigned-by-dhcp.cox.net","threadId":"5294","inReplyTo":"44E2F911.6060002@gmail.com","subject":"Re: gitweb / cg-export","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-16T18:01:49Z","receivedAt":"2006-08-16T18:01:49Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Aneesh Kumar K.V\" <aneesh.kumar@gmail.com> writes:\n\n> How about the below on top of latest git\n>\n> -aneesh\n\nThis looks Ok (except \"$project\" needs to be shell quoted on the\npipe-open line and possibly in the URL; there may be some other\nminor details I missed).  It needs to be protected by elective,\nopt-in configuration variable, similarly to how \"blame\" is done,\nsince I suspect this would be rather expensive.\n\n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index 37a6284..b9b522a 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -175,6 +175,7 @@ my %actions = (\n>  \t\"tag\" => \\&git_tag,\n>  \t\"tags\" => \\&git_tags,\n>  \t\"tree\" => \\&git_tree,\n> +\t\"snapshot\" => \\&git_snapshot,\n>  );\n>  \n>  $action = 'summary' if (!defined($action));\n> @@ -1334,6 +1335,7 @@ sub git_shortlog_body {\n>  \t\t      \"<td class=\\\"link\\\">\" .\n>  \t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$commit)}, \"commit\") . \" | \" .\n>  \t\t      $cgi->a({-href => href(action=>\"commitdiff\", hash=>$commit)}, \"commitdiff\") .\n> +\t\t      \" | \" .$cgi->a({-href => \"$my_uri/$project.tar.gz?\" . esc_param(\"p=$project;a=snapshot;h=$commit\")}, \"snapshot\") .\n>  \t\t      \"</td>\\n\" .\n>  \t\t      \"</tr>\\n\";\n>  \t}\n> @@ -2097,6 +2099,21 @@ sub git_tree {\n>  \tgit_footer_html();\n>  }\n>  \n> +sub git_snapshot {\n> +\tif (!defined $hash) {\n> +\t\t$hash = git_get_head_hash($project);\n> +\t}\n> +\tprint $cgi->header(-type=>'application/x-tar',\n> +\t\t\t  -Content-Encoding=>'x-gzip', -status=> '200 OK');\n> +\topen my $fd, \"-|\", \"$GIT tar-tree $hash $project | gzip -c9\" or die_error(undef, \"Execute git-tar-tree failed.\");\n> +\tbinmode STDOUT, ':raw';\n> +\tprint <$fd>;\n> +\tbinmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi\n> +\tclose $fd;\n> +\n> +\n> +}\n> +\n>  sub git_log {\n>  \tmy $head = git_get_head_hash($project);\n>  \tif (!defined $hash) {\n"},{"id":"25423","messageId":"20060816200557.GB9575@c165.ib.student.liu.se","threadId":"5294","inReplyTo":"ebuvok$vnv$1@sea.gmane.org","subject":"Re: gitweb / cg-export","fromName":"Fredrik Kuivinen","fromEmail":"freku045@student.liu.se","sentAt":"2006-08-16T20:05:57Z","receivedAt":"2006-08-16T20:05:57Z","isPatch":false,"sender":{"key":"frekui@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13770967?v=4"},"body":"On Wed, Aug 16, 2006 at 05:02:36PM +0530, Aneesh Kumar K.V wrote:\n> Aneesh Kumar K.V wrote:\n> >Jakub Narebski wrote:\n> >>Toby White wrote:\n> >>\n> >>>I was wondering if a feature like the following would be of\n> >>>use to anyone except me: I'd like to be able to download\n> >>>the full source of a given tree from gitweb.\n> >>[...]\n> >>So you want to have snapshot of a tree. Why not snapshot of a commit, \n> >>or of a tag?\n> >>\n> >>>I've quickly hacked gitweb to do this for me - patch below.\n> >>>\n> >>>It adds an extra link to the 'commit' page. Next to the link\n> >>>that would lead you to 'tree', there is 'tar.gz' which simply\n> >>>returns the tar.gz of the same tree.\n> >>>\n> >>>The patch is against the version of gitweb currently in\n> >>>Debian, which is, erm, '264-1', apparently, because that's\n> >>>what I had to hand.\n> >>\n> >>It is really better to hack git with git. And you can use current gitweb\n> >>with old git (well, not always, as current gitweb requires --full-history\n> >>option to git-rev-list to be available).\n> >>\n> >\n> >How about the below on top of latest git\n> \n> Add it to git_commit too. The patch contains the pervious changes also.\n> \n\nNice.\n\n> +sub git_snapshot {\n> +\tif (!defined $hash) {\n> +\t\t$hash = git_get_head_hash($project);\n> +\t}\n> +\tprint $cgi->header(-type=>'application/x-tar',\n> +\t\t\t  -Content-Encoding=>'x-gzip', -status=> '200 OK');\n> +\topen my $fd, \"-|\", \"$GIT tar-tree $hash $project | gzip -c9\" or die_error(undef, \"Execute git-tar-tree failed.\");\n\nIt might be better to use -6 (the default compression/speed trade-off)\ninstead of using -9 (best but slowest compression) here.  Or maybe\neven make it configurable. On some servers it is probably preferable\nto make the snapshot (slightly) larger and gain some cpu time.\n\nTo get some numbers I made a small benchmark with the current git\ntree. I get the following on my machine:\n\nCompression/speed    Size   Time\n-1                   1.1M   0.16s\n-6                   923K   0.36s\n-9                   917K   0.50s  \n\n- Fredrik\n"},{"id":"25438","messageId":"20060816224000.GE14459@admingilde.org","threadId":"5294","inReplyTo":"44E2F911.6060002@gmail.com","subject":"Re: gitweb / cg-export","fromName":"Martin Waitz","fromEmail":"tali@admingilde.org","sentAt":"2006-08-16T22:40:00Z","receivedAt":"2006-08-16T22:40:00Z","isPatch":false,"sender":{"key":"tali@admingilde.org","avatar":"https://gravatar.com/avatar/3f89b03eee362187effabe257898735b475673a12265c398ea9161259ae91553?d=mp&s=160"},"body":"hoi :)\n\nOn Wed, Aug 16, 2006 at 04:23:05PM +0530, Aneesh Kumar K.V wrote:\n> @@ -1334,6 +1335,7 @@ sub git_shortlog_body {\n>  \t\t      \"<td class=\\\"link\\\">\" .\n>  \t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$commit)}, \"commit\") . \" | \" .\n>  \t\t      $cgi->a({-href => href(action=>\"commitdiff\", hash=>$commit)}, \"commitdiff\") .\n> +\t\t      \" | \" .$cgi->a({-href => \"$my_uri/$project.tar.gz?\" . esc_param(\"p=$project;a=snapshot;h=$commit\")}, \"snapshot\") .\n>  \t\t      \"</td>\\n\" .\n>  \t\t      \"</tr>\\n\";\n>  \t}\n\nIsn't there some other way to tell the webbroser how to name the file?\nI thought there is some HTML header to explicitly give one file name.\n\n-- \nMartin Waitz\n"},{"id":"25439","messageId":"1155768608.3386.1.camel@pim.off.vrfy.org","threadId":"5294","inReplyTo":"20060816224000.GE14459@admingilde.org","subject":"Re: gitweb / cg-export","fromName":"Kay Sievers","fromEmail":"kay.sievers@vrfy.org","sentAt":"2006-08-16T22:50:08Z","receivedAt":"2006-08-16T22:50:08Z","isPatch":false,"sender":{"key":"kay.sievers@vrfy.org","avatar":null},"body":"On Thu, 2006-08-17 at 00:40 +0200, Martin Waitz wrote:\n> hoi :)\n> \n> On Wed, Aug 16, 2006 at 04:23:05PM +0530, Aneesh Kumar K.V wrote:\n> > @@ -1334,6 +1335,7 @@ sub git_shortlog_body {\n> >  \t\t      \"<td class=\\\"link\\\">\" .\n> >  \t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$commit)}, \"commit\") . \" | \" .\n> >  \t\t      $cgi->a({-href => href(action=>\"commitdiff\", hash=>$commit)}, \"commitdiff\") .\n> > +\t\t      \" | \" .$cgi->a({-href => \"$my_uri/$project.tar.gz?\" . esc_param(\"p=$project;a=snapshot;h=$commit\")}, \"snapshot\") .\n> >  \t\t      \"</td>\\n\" .\n> >  \t\t      \"</tr>\\n\";\n> >  \t}\n> \n> Isn't there some other way to tell the webbroser how to name the file?\n> I thought there is some HTML header to explicitly give one file name.\n\nSomething like in line 1923?\n  $cgi->header(-type => \"$type\", '-content-disposition' => \"inline; filename=\\\"$save_as\\\"\");\n\nKay\n"},{"id":"25449","messageId":"44E40CB1.7040805@gmail.com","threadId":"5294","inReplyTo":"7v4pwc4l0y.fsf@assigned-by-dhcp.cox.net","subject":"gitweb: Support for snapshots in gitweb","fromName":"Aneesh Kumar K.V","fromEmail":"aneesh.kumar@gmail.com","sentAt":"2006-08-17T06:29:05Z","receivedAt":"2006-08-17T06:29:05Z","isPatch":false,"sender":{"key":"aneesh.kumar@gmail.com","avatar":"https://gravatar.com/avatar/0621fc0b2f14ead1e9024382f16053a808c148596da30c1b92572fa075621f68?d=mp&s=160"},"body":"\n\n\nThis add snapshot support to gitweb. This need to be enabled\nper project using config gitweb.snapshot = true\n\nSigned-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>\n---\n gitweb/gitweb.perl |   34 ++++++++++++++++++++++++++++++----\n 1 files changed, 30 insertions(+), 4 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 37a6284..4c78e80 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -175,6 +175,7 @@ my %actions = (\n \t\"tag\" => \\&git_tag,\n \t\"tags\" => \\&git_tags,\n \t\"tree\" => \\&git_tree,\n+\t\"snapshot\" => \\&git_snapshot,\n );\n \n $action = 'summary' if (!defined($action));\n@@ -1309,6 +1310,7 @@ sub git_difftree_body {\n sub git_shortlog_body {\n \t# uses global variable $project\n \tmy ($revlist, $from, $to, $refs, $extra) = @_;\n+\tmy $have_snapshot = git_get_project_config_bool ('snapshot');\n \t$from = 0 unless defined $from;\n \t$to = $#{$revlist} if (!defined $to || $#{$revlist} < $to);\n \n@@ -1333,8 +1335,11 @@ sub git_shortlog_body {\n \t\tprint \"</td>\\n\" .\n \t\t      \"<td class=\\\"link\\\">\" .\n \t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$commit)}, \"commit\") . \" | \" .\n-\t\t      $cgi->a({-href => href(action=>\"commitdiff\", hash=>$commit)}, \"commitdiff\") .\n-\t\t      \"</td>\\n\" .\n+\t\t      $cgi->a({-href => href(action=>\"commitdiff\", hash=>$commit)}, \"commitdiff\");\n+\t\tif ($have_snapshot) {\n+\t\t\tprint \" | \" .  $cgi->a({-href => href(action=>\"snapshot\", hash=>$commit)}, \"snapshot\");\n+\t\t}\n+\t\tprint \"</td>\\n\" .\n \t\t      \"</tr>\\n\";\n \t}\n \tif (defined $extra) {\n@@ -2097,6 +2102,23 @@ sub git_tree {\n \tgit_footer_html();\n }\n \n+sub git_snapshot {\n+\tif (!defined $hash) {\n+\t\t$hash = git_get_head_hash($project);\n+\t}\n+\tprint $cgi->header(-type=>'application/x-tar', -Content-Encoding=>'x-gzip',\n+\t\t'-content-disposition' => \"inline; filename=\\\"$project.tar.gz\\\"\",\n+\t\t-status=> '200 OK');\n+\n+\topen my $fd, \"-|\", \"$GIT tar-tree $hash \\'$project\\' | gzip -c6\" or die_error(undef, \"Execute git-tar-tree failed.\");\n+\tbinmode STDOUT, ':raw';\n+\tprint <$fd>;\n+\tbinmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi\n+\tclose $fd;\n+\n+\n+}\n+\n sub git_log {\n \tmy $head = git_get_head_hash($project);\n \tif (!defined $hash) {\n@@ -2191,6 +2213,7 @@ sub git_commit {\n \t}\n \tmy $refs = git_get_references();\n \tmy $ref = format_ref_marker($refs, $co{'id'});\n+\tmy $have_snapshot = git_get_project_config_bool ('snapshot');\n \tmy $formats_nav = '';\n \tif (defined $file_name && defined $co{'parent'}) {\n \t\tmy $parent = $co{'parent'};\n@@ -2226,8 +2249,11 @@ sub git_commit {\n \t      \"<td class=\\\"sha1\\\">\" .\n \t      $cgi->a({-href => href(action=>\"tree\", hash=>$co{'tree'}, hash_base=>$hash), class => \"list\"}, $co{'tree'}) .\n \t      \"</td>\" .\n-\t      \"<td class=\\\"link\\\">\" . $cgi->a({-href => href(action=>\"tree\", hash=>$co{'tree'}, hash_base=>$hash)}, \"tree\") .\n-\t      \"</td>\" .\n+\t      \"<td class=\\\"link\\\">\" . $cgi->a({-href => href(action=>\"tree\", hash=>$co{'tree'}, hash_base=>$hash)}, \"tree\");\n+\tif ($have_snapshot) {\n+\t      print \" | \" .  $cgi->a({-href => href(action=>\"snapshot\", hash=>$hash)}, \"snapshot\");\n+\t}\n+\tprint \"</td>\" .\n \t      \"</tr>\\n\";\n \tmy $parents = $co{'parents'};\n \tforeach my $par (@$parents) {\n-- \n1.4.2.rc1.g83e1-dirty\n\n"},{"id":"25451","messageId":"7vhd0bu873.fsf@assigned-by-dhcp.cox.net","threadId":"5294","inReplyTo":"44E40CB1.7040805@gmail.com","subject":"Re: gitweb: Support for snapshots in gitweb","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-17T07:34:24Z","receivedAt":"2006-08-17T07:34:24Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Aneesh Kumar K.V\" <aneesh.kumar@gmail.com> writes:\n\n> @@ -2097,6 +2102,23 @@ sub git_tree {\n>  \tgit_footer_html();\n>  }\n>  \n> +sub git_snapshot {\n> +\tif (!defined $hash) {\n> +\t\t$hash = git_get_head_hash($project);\n> +\t}\n> +\tprint $cgi->header(-type=>'application/x-tar', -Content-Encoding=>'x-gzip',\n> +\t\t'-content-disposition' => \"inline; filename=\\\"$project.tar.gz\\\"\",\n> +\t\t-status=> '200 OK');\n\nThese -Mixed-Case, '-sometimes-quoted', spaces sometimes around\ndouble-arrow sometimes missing, parameters bother me.  Perhaps:\n\n\tprint $cgi->header(-type => 'application/x-tar',\n                           -content-encoding => 'x-gzip',\n                           -content-disposition =>\n                               \"inline; filename=\\\"$project.tar.gz\\\"\",\n                           -status => '200 OK');\n\nRFC 2616 says that \"gzip\" content-coding is registered with\nIANA, so I do not think you need to say \"x-gzip\".\n\n> +\topen my $fd, \"-|\", \"$GIT tar-tree $hash \\'$project\\' | gzip -c6\" or die_error(undef, \"Execute git-tar-tree failed.\");\n\nI think this \"6\" is because somebody suggested to use the\ndefault \"6\" instead of \"9\" in your original and the suggestion\nwas because \"9\" tends to be too expensive.  \n\nBut if we do not have a good, specific, reason to use \"6\" (as\nopposed to, say, \"5\" or \"7\") and have \"6\" here only because we\nhappen to know \"6\" is the current gzip default, then probably we\nare better off just letting gzip decide what compression level\nto use without specifying it ourselves?\n"},{"id":"25452","messageId":"cc723f590608170048y44737ab3h497fb22db8605027@mail.gmail.com","threadId":"5294","inReplyTo":"7vhd0bu873.fsf@assigned-by-dhcp.cox.net","subject":"Re: gitweb: Support for snapshots in gitweb","fromName":"Aneesh Kumar","fromEmail":"aneesh.kumar@gmail.com","sentAt":"2006-08-17T07:48:22Z","receivedAt":"2006-08-17T07:48:22Z","isPatch":false,"sender":{"key":"aneesh.kumar@gmail.com","avatar":"https://gravatar.com/avatar/0621fc0b2f14ead1e9024382f16053a808c148596da30c1b92572fa075621f68?d=mp&s=160"},"body":"On 8/17/06, Junio C Hamano <junkio@cox.net> wrote:\n> \"Aneesh Kumar K.V\" <aneesh.kumar@gmail.com> writes:\n>\n> > @@ -2097,6 +2102,23 @@ sub git_tree {\n> >       git_footer_html();\n> >  }\n> >\n> > +sub git_snapshot {\n> > +     if (!defined $hash) {\n> > +             $hash = git_get_head_hash($project);\n> > +     }\n> > +     print $cgi->header(-type=>'application/x-tar', -Content-Encoding=>'x-gzip',\n> > +             '-content-disposition' => \"inline; filename=\\\"$project.tar.gz\\\"\",\n> > +             -status=> '200 OK');\n>\n> These -Mixed-Case, '-sometimes-quoted', spaces sometimes around\n> double-arrow sometimes missing, parameters bother me.  Perhaps:\n>\n>         print $cgi->header(-type => 'application/x-tar',\n>                            -content-encoding => 'x-gzip',\n>                            -content-disposition =>\n>                                \"inline; filename=\\\"$project.tar.gz\\\"\",\n>                            -status => '200 OK');\n>\n> RFC 2616 says that \"gzip\" content-coding is registered with\n> IANA, so I do not think you need to say \"x-gzip\".\n>\n\nPlease feel free to change the code. Or if you want me to send another\npatch with the changes suggested i can do the same. Let me know.\n\n\n\n> > +     open my $fd, \"-|\", \"$GIT tar-tree $hash \\'$project\\' | gzip -c6\" or die_error(undef, \"Execute git-tar-tree failed.\");\n>\n> I think this \"6\" is because somebody suggested to use the\n> default \"6\" instead of \"9\" in your original and the suggestion\n> was because \"9\" tends to be too expensive.\n>\n> But if we do not have a good, specific, reason to use \"6\" (as\n> opposed to, say, \"5\" or \"7\") and have \"6\" here only because we\n> happen to know \"6\" is the current gzip default, then probably we\n> are better off just letting gzip decide what compression level\n> to use without specifying it ourselves?\n\n\nyes that is correct. I  changed it because it was suggested.\n\n-aneesh\n"},{"id":"25475","messageId":"ec1e0j$bqr$1@sea.gmane.org","threadId":"5294","inReplyTo":"44E40CB1.7040805@gmail.com","subject":"Re: gitweb: Support for snapshots in gitweb","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-17T09:49:03Z","receivedAt":"2006-08-17T09:49:03Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Aneesh Kumar K.V wrote:\n\n> +       print $cgi->header(-type=>'application/x-tar', -Content-Encoding=>'x-gzip',\n> +               '-content-disposition' => \"inline; filename=\\\"$project.tar.gz\\\"\",\n> +               -status=> '200 OK');\n\nWouldn't it be better to put $hash somewhere in the name?\n\nAnd please remember that $project can contain slashes, so it should be processed\n(only basename of $project, perhaps).\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"}]}